| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- use Illuminate\Database\Eloquent\Relations\HasOne;
- use Illuminate\Support\Str;
- use App\Traits\ModelLogChanging;
- class Log extends Model
- {
- use ModelTimeFormat;
- protected $fillable = [
- 'description','type','method', 'class', 'ip','id_user','created_at','updated_at'
- ];
- function user(): HasOne
- {
- return $this->hasOne(User::class, 'id','id_user');
- }
- public function getExceptionMarkAttribute(){
- if (Str::upper(substr($this->method,0,1)) != 'E')return 'N';
- if (Str::upper(substr($this->method,0,5)) == 'ERROR' || Str::upper(substr($this->method,0,9)) == 'EXCEPTION')
- return 'Y';
- return 'N';
- }
- // public function getDescriptionAttribute($value): string
- // {
- // return str_replace(
- // ["\n","\r\n"],
- // ' ',
- // $value);
- // }
- public function scopeFilter($query, $filters)
- {
- return $filters->apply($query);
- }
- }
|