News.php 695 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Repositories\Models\Info;
  3. use App\Repositories\Models\Base\Admin;
  4. use App\Repositories\Models\Model;
  5. class News extends Model
  6. {
  7. /**
  8. * @var string
  9. */
  10. protected $table = 'info_news';
  11. protected $guarded = [];
  12. /**
  13. * The attributes excluded from the model's JSON form.
  14. *
  15. * @var array
  16. */
  17. protected $hidden = [];
  18. public function getCoverAttribute()
  19. {
  20. if (array_key_exists('cover_path', $this->attributes)) return path_to_url($this->attributes['cover_path']);
  21. return '';
  22. }
  23. public function admin()
  24. {
  25. return $this->belongsTo(Admin::class)->select(['id', 'name', 'username']);
  26. }
  27. }