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