[wip] create main tables relation

This commit is contained in:
gregorio
2022-07-26 07:01:25 +07:00
parent f98ca8d532
commit 5021507cf6
32 changed files with 1324 additions and 168 deletions

46
app/Models/Pengajuan.php Normal file
View 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)
);
}
}