vat_wms/app/Models/FloorLayout.php

62 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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';
/**
* Massassignable 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');
}
}