cuti-waf/app/Models/Pengajuan.php
2022-07-26 07:01:25 +07:00

47 lines
998 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Pengajuan extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'form_cuti';
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'tgl_mulai', 'tgl_selesai',
];
public function personalia(): BelongsTo
{
return $this->belongsTo(User::class, 'terima_personalia');
}
public function supervisor(): BelongsTo
{
return $this->belongsTo(User::class, 'terima_supervisor');
}
public function disetujuiOleh(): Attribute
{
return new Attribute(
get: fn ($value) => collect($this->personalia, $this->supervisor)
);
}
}