62 lines
1.1 KiB
PHP
62 lines
1.1 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||
use OwenIt\Auditing\Auditable;
|
||
|
||
class FloorLayout extends Model
|
||
{
|
||
// use Auditable;
|
||
|
||
protected $table = 'floor_layouts';
|
||
|
||
/**
|
||
* Mass‐assignable attributes
|
||
*/
|
||
protected $fillable = [
|
||
'layout_name',
|
||
'room_id',
|
||
'layout_bg_file',
|
||
'data',
|
||
'user_id',
|
||
];
|
||
|
||
/**
|
||
* Cast `data` JSON column to array
|
||
*/
|
||
protected $casts = [
|
||
'data' => 'array',
|
||
];
|
||
|
||
/**
|
||
* Always record the currently authenticated user
|
||
* for the audit and the user_id column.
|
||
*/
|
||
public static function boot()
|
||
{
|
||
parent::boot();
|
||
|
||
static::saving(function ($model) {
|
||
$model->user_id = auth()->id();
|
||
});
|
||
}
|
||
|
||
|
||
/**
|
||
* Relationship to the user who last saved
|
||
*/
|
||
public function user()
|
||
{
|
||
return $this->belongsTo(User::class);
|
||
}
|
||
/**
|
||
* Relationship to the user who last saved
|
||
*/
|
||
public function room()
|
||
{
|
||
return $this->belongsTo(StockRoom::class, 'room_id');
|
||
}
|
||
}
|