38 lines
929 B
PHP
38 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
class OperationLog extends Model
|
|
{
|
|
protected $table = 'admin_operation_logs';
|
|
protected $fillable = ['admin_id','admin_name','admin_mobile', 'method','describe', 'ip', 'input', 'details','url','route','route_title'];
|
|
public $timestamps = true;
|
|
|
|
protected function input(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn ($value) => json_decode($value,true),
|
|
set: fn ($value) => json_encode($value),
|
|
);
|
|
}
|
|
|
|
protected function serializeDate(\DateTimeInterface $date)
|
|
{
|
|
return $date->format('Y-m-d H:i:s');
|
|
}
|
|
|
|
/**
|
|
* Log belongs to users.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(Admin::class)->withTrashed();
|
|
}
|
|
}
|