BusinessSchool.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Repositories\Models\Dwbs;
  3. use App\Repositories\Models\Model;
  4. class BusinessSchool extends Model
  5. {
  6. /**
  7. * @var string
  8. */
  9. protected $table = 'dwbs_business_school';
  10. protected $guarded = [];
  11. /**
  12. * The attributes excluded from the model's JSON form.
  13. *
  14. * @var array
  15. */
  16. protected $hidden = [];
  17. protected $casts = [];
  18. public function category()
  19. {
  20. return $this->belongsTo(BusinessCategory::class, 'category_id')->select(['id', 'name']);
  21. }
  22. public function getCoverAttribute($val)
  23. {
  24. if (empty($val)) {
  25. return config('app.url') . '/default/headimg.png';
  26. }
  27. return path_to_url($val);
  28. }
  29. public function setCoverAttribute($val)
  30. {
  31. $this->attributes['cover'] = url_to_path($val);
  32. }
  33. public function getPathAttribute($val)
  34. {
  35. if (empty($val)) {
  36. return null;
  37. }
  38. return path_to_url($val);
  39. }
  40. public function setPathAttribute($val)
  41. {
  42. $this->attributes['path'] = url_to_path($val);
  43. }
  44. }