StocksNew/Modules/Admin/app/Models/PromotionDemotion.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2024-08-27 17:48:06 +05:45
<?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' => '-']);
}
}