[wip] create main tables relation
This commit is contained in:
46
app/Models/Pengajuan.php
Normal file
46
app/Models/Pengajuan.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user