47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Modules\Admin\Models;
|
||
|
|
||
|
use App\Observers\PromotionDemotionObserver;
|
||
|
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Modules\Employee\Models\Employee;
|
||
|
|
||
|
#[ObservedBy([PromotionDemotionObserver::class])]
|
||
|
class PromotionDemotion extends Model
|
||
|
{
|
||
|
use HasFactory;
|
||
|
|
||
|
protected $table = "tbl_promotion_demotions";
|
||
|
|
||
|
/**
|
||
|
* The attributes that are mass assignable.
|
||
|
*/
|
||
|
protected $fillable = [
|
||
|
'employee_id',
|
||
|
'title',
|
||
|
'type',
|
||
|
'old_designation_id',
|
||
|
'new_designation_id',
|
||
|
'status',
|
||
|
'description',
|
||
|
'remarks',
|
||
|
];
|
||
|
|
||
|
public function employee()
|
||
|
{
|
||
|
return $this->belongsTo(Employee::class, 'employee_id');
|
||
|
}
|
||
|
|
||
|
public function oldDesignation()
|
||
|
{
|
||
|
return $this->belongsTo(Designation::class, 'old_designation_id')->withDefault(['name' => '-']);
|
||
|
}
|
||
|
|
||
|
public function newDesignation()
|
||
|
{
|
||
|
return $this->belongsTo(Designation::class, 'new_designation_id')->withDefault(['name' => '-']);
|
||
|
}
|
||
|
}
|