IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Traits;
use Carbon\Carbon;
use Exception;
class Employee extends Model {
use Traits\AutoUpdateUserColumns;
protected $primaryKey = 'idEmployee';
protected $table = 'employees';
protected $fillable = ['idSchool','idDepartment','idDesignation' ,'firstName','enrollmentNo','middleName' ,'lastName',
'guardianName', 'photo', 'address','idState','city','pincode','landmark','telephone','contactPerson','contactPersonAddress'
,'contactPersonRelation','contactPersonTelephone','contactPersonMobile','aadhaarNo','panNo','accountNo','idBank','ifscCode','gender','bloodGroup',
'email','mobile' ,'dob', 'doj', 'password','pwd','dateOfRetirement','caste','otherInfo','qid_expiry','passport_issued_country','passport_expiry','passport','teacherQualification'];
public function setDobAttribute($date) {
if (strlen($date) > 0)
$this->attributes['dob'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['dob'] = null;
}
public function getDobAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}catch( Exception $e) {
try{
if ($date && $date != '0000-00-00' && $date != 'null')
{
$parseDate = Carbon::createFromFormat('d/m/Y', $date);
return Carbon::parse($parseDate)->format('d-m-Y');
}
}catch( Exception $e) {}
return '';
}
}
public function setDateOfRetirementAttribute($date) {
if (strlen($date) > 0)
$this->attributes['dateOfRetirement'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['dateOfRetirement'] = null;
}
public function getDateOfRetirementAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}catch( Exception $e) {
if ($date && $date != '0000-00-00' && $date != 'null')
{
$parseDate = Carbon::createFromFormat('d/m/Y', $date);
return Carbon::parse($parseDate)->format('d-m-Y');
}
return '';
}
}
public function setDojAttribute($date) {
if (strlen($date) > 0)
$this->attributes['doj'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['doj'] = null;
}
public function getDojAttribute($date) {
// dd($date);
try{
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}catch( Exception $e) {
try{
if ($date && $date != '0000-00-00' && $date != 'null')
{
$parseDate = Carbon::createFromFormat('d/m/Y', $date);
return Carbon::parse($parseDate)->format('d-m-Y');
}
}catch( Exception $e) {}
return '';
}
}
public function getNameAttribute() {
return $this->firstName . ' ' . $this->lastName .'('.$this->enrollmentNo.')';
}
public function department() {
return $this->belongsTo(Department::class,'idDepartment','idDepartment');
}
public function designation() {
return $this->belongsTo(Designation::class,'idDesignation','idDesignation');
}
public function other_accounts() {
return $this->hasMany(EmployeeOtherAccount::class,'idEmployee','idEmployee');
}
public function emptype() {
return $this->belongsTo(EmployeeType::class,'idType','idType');
}
public function attandance() {
return $this->hasMany(EmpAttendance::class, 'Enrollment_Number', 'enrollmentNo');
}
}
Copyright © 2021 -