first commit
This commit is contained in:
0
Modules/Employee/app/Models/.gitkeep
Normal file
0
Modules/Employee/app/Models/.gitkeep
Normal file
44
Modules/Employee/app/Models/Employee.php
Normal file
44
Modules/Employee/app/Models/Employee.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Employee\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Modules\Admin\Models\Department;
|
||||
use Modules\Admin\Models\Designation;
|
||||
|
||||
class Employee extends Model
|
||||
{
|
||||
use Notifiable;
|
||||
protected $table = 'tbl_employees';
|
||||
protected $guarded = [];
|
||||
protected $appends = ['full_name', 'profile_pic'];
|
||||
|
||||
protected function getFullNameAttribute()
|
||||
{
|
||||
// return $this->first_name . ' ' . $this->middle_name . ' ' . $this->last_name;
|
||||
return $this->first_name . ' ' . $this->last_name;
|
||||
|
||||
}
|
||||
|
||||
protected function getProfilePicAttribute()
|
||||
{
|
||||
return $this->profile_picture ? asset('storage/' . $this->profile_picture) : asset('assets/images/task.png');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'users_id');
|
||||
}
|
||||
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class, 'department_id')->withDefault();
|
||||
}
|
||||
|
||||
public function designation()
|
||||
{
|
||||
return $this->HasOne(Designation::class, 'designation_id')->withDefault();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user