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

77 lines
1.7 KiB
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;
use Illuminate\Support\Arr;
class FormCuti extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'keterangan',
'data',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'data' => 'array',
];
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'form_cuti';
public function staff(): BelongsTo
{
return $this->belongsTo(User::class, 'staff_id');
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'creator_id');
}
// public function createRow(array $row): void
// {
// $row = Arr::only($row, ['tgl_mulai', 'tgl_selesai']);
// $row['form_cuti_id'] = $this->id;
// $row['supervisor'] = [
// 'id' => null,
// 'terima' => false,
// 'keterangan' => null,
// ];
// $row['personalia'] = [
// 'id' => $this->creator->id,
// 'terima' => false,
// 'keterangan' => null,
// ];
// // this runs setDataAttribute
// if (isset($this->attributes['data'])) {
// $this->data = array_merge($this->attributes['data'], [$row]);
// } else {
// $this->data = [$row];
// }
// }
}