business.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class business extends Model
  5. {
  6. //
  7. public function setPicsAttribute($pics)
  8. {
  9. if (is_array($pics)) {
  10. $this->attributes['pics'] = json_encode($pics);
  11. }
  12. }
  13. public function getPicsAttribute($pics)
  14. {
  15. return json_decode($pics, true);
  16. }
  17. public function setFoodTypeAttribute($foodType)
  18. {
  19. if (is_array($foodType)) {
  20. $this->attributes['food_type'] = json_encode($foodType);
  21. }
  22. }
  23. public function getFoodTypeAttribute($foodType)
  24. {
  25. return json_decode($foodType, true);
  26. }
  27. public function setServeFacilityAttribute($serveFacility)
  28. {
  29. if (is_array($serveFacility)) {
  30. $this->attributes['serve_facility'] = json_encode($serveFacility);
  31. }
  32. }
  33. public function getServeFacilityAttribute($serveFacility)
  34. {
  35. return json_decode($serveFacility, true);
  36. }
  37. //与热点管理表关联
  38. // public function hotSpot()
  39. // {
  40. // return $this->hasOne(hot_spot::class);
  41. // }
  42. }