StocksNew/Modules/Employee/app/Models/Employee.php
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

45 lines
1.1 KiB
PHP

<?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();
}
}