56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\Admin\Models;
|
|
|
|
use App\Observers\AppreciationObserver;
|
|
use App\Traits\StatusTrait;
|
|
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Modules\Admin\Database\factories\AppreciationFactory;
|
|
use Modules\Employee\Models\Employee;
|
|
|
|
#[ObservedBy([AppreciationObserver::class])]
|
|
class Appreciation extends Model
|
|
{
|
|
use HasFactory, StatusTrait, Notifiable;
|
|
|
|
protected $table = 'tbl_appreciations';
|
|
protected $primaryKey = 'appreciation_id';
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'title',
|
|
'alias',
|
|
'type',
|
|
'employee_id',
|
|
'appreciated_by',
|
|
'appreciated_date',
|
|
'status',
|
|
'description',
|
|
'remarks',
|
|
];
|
|
|
|
public $appends = ['status_name'];
|
|
|
|
public const APPRECIATION_TYPE = [
|
|
1 => 'Employee of the Month',
|
|
2 => 'Best Manager',
|
|
3 => 'Dedicated Employeer',
|
|
4 => 'Hard Working Employee',
|
|
];
|
|
|
|
public function appreciatee()
|
|
{
|
|
return $this->belongsTo(Employee::class, 'employee_id')->withDefault();
|
|
}
|
|
|
|
public function appreciator()
|
|
{
|
|
return $this->belongsTo(Employee::class, 'appreciated_by')->withDefault();
|
|
}
|
|
|
|
}
|