<?php

namespace App;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OperatorLog extends Model
{
    use ModelLogChanging;

    const UPDATED_AT = null;
    protected $fillable=[
        'operator_logable_type','operator_logable_id','user_id','operation'
    ];
    protected $appends=[
        'user_name'
    ];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i');
    }
    public function user(){
        return $this->hasOne('App\User','id','user_id');
    }
    public function getUserNameAttribute()
    {
        return $this['user']['name'] ??'';
    }

}
