StocksNew/Modules/Employee/app/Models/Employee.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?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();
}
}