Log.php 922 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. use Illuminate\Database\Eloquent\Relations\HasOne;
  6. use Illuminate\Support\Str;
  7. class Log extends Model
  8. {
  9. use ModelTimeFormat;
  10. protected $fillable = [
  11. 'operation', 'description','method', 'class', 'ip','id_user','created_at','updated_at'
  12. ];
  13. function user(): HasOne
  14. {
  15. return $this->hasOne(User::class, 'id','id_user');
  16. }
  17. public function getExceptionMarkAttribute(){
  18. if (Str::upper(substr($this->method,0,1)) != 'E')return 'N';
  19. if (Str::upper(substr($this->method,0,5)) == 'ERROR' || Str::upper(substr($this->method,0,9)) == 'EXCEPTION')
  20. return 'Y';
  21. return 'N';
  22. }
  23. // public function getDescriptionAttribute($value): string
  24. // {
  25. // return str_replace(
  26. // ["\n","\r\n"],
  27. // ' ',
  28. // $value);
  29. // }
  30. }