UserMessage.php 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Repositories\Models\Inform;
  3. use App\Repositories\Models\Model;
  4. use Carbon\Carbon;
  5. use Prettus\Repository\Contracts\Transformable;
  6. use Prettus\Repository\Traits\TransformableTrait;
  7. /**
  8. * Class UserMessage.
  9. *
  10. * @package namespace App\Repositories\Models\Inform;
  11. */
  12. class UserMessage extends Model implements Transformable
  13. {
  14. use TransformableTrait;
  15. protected $table = 'inform_messages';
  16. protected $appends = ['created_at_text'];
  17. /**
  18. * The attributes that are mass assignable.
  19. *
  20. * @var array
  21. */
  22. protected $guarded = [];
  23. protected static function booted()
  24. {
  25. self::language();
  26. }
  27. public function information()
  28. {
  29. return $this->belongsTo(Information::class);
  30. }
  31. public function category()
  32. {
  33. return $this->belongsTo(Category::class);
  34. }
  35. public function getCreatedAtTextAttribute()
  36. {
  37. return Carbon::parse($this->attributes['created_at'])->diffForHumans();
  38. }
  39. }