69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Admin\Models;
|
|
|
|
use App\Traits\StatusTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Modules\Employee\Models\Employee;
|
|
|
|
class Transfer extends Model
|
|
{
|
|
use HasFactory, StatusTrait;
|
|
|
|
protected $table = 'tbl_transfers';
|
|
protected $primaryKey = 'transfer_id';
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'employee_id',
|
|
'old_department_id',
|
|
'new_department_id',
|
|
'status',
|
|
'transfer_date',
|
|
'transfer_type',
|
|
'progress_status_id',
|
|
'approved_by',
|
|
'approved_date',
|
|
'description',
|
|
'remarks',
|
|
'createdBy',
|
|
'updatedBy',
|
|
];
|
|
|
|
public $appends = ['status_name'];
|
|
|
|
public const PROGRESS_STATUS = [
|
|
1 => 'Pending',
|
|
2 => 'Approved',
|
|
3 => 'Rejected',
|
|
];
|
|
|
|
public const TRANSFER_TYPE = [
|
|
1 => 'Internal',
|
|
2 => 'External',
|
|
3 => 'Temporary',
|
|
];
|
|
|
|
public function oldDepartment()
|
|
{
|
|
return $this->belongsTo(Department::class, 'old_department_id')->withDefault();
|
|
}
|
|
|
|
public function newDepartment()
|
|
{
|
|
return $this->belongsTo(Department::class, 'new_department_id')->withDefault();
|
|
}
|
|
|
|
public function employee()
|
|
{
|
|
return $this->belongsTo(Employee::class, 'employee_id')->withDefault();
|
|
}
|
|
|
|
public function approver()
|
|
{
|
|
return $this->belongsTo(Employee::class, 'approved_by')->withDefault();
|
|
}
|
|
}
|