链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.3 KiB

6 years ago
6 years ago
6 years ago
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Database\Eloquent\Model;
  6. class ImsCjdcMarket extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. use SoftDeletes;
  10. protected $table = 'lanzu_market';
  11. protected $dateFormat = 'U';
  12. public function setImgsAttribute($imgs)
  13. {
  14. if ($imgs){
  15. $this->attributes['imgs'] = implode(',',$imgs);
  16. }
  17. }
  18. public function getImgsAttribute($imgs)
  19. {
  20. return explode(',',$imgs);
  21. }
  22. public function getCoordinatesAttribute()
  23. {
  24. }
  25. public function mp(){
  26. return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id');
  27. }
  28. /**
  29. * 获取市场信息
  30. * @return \Illuminate\Http\JsonResponse
  31. */
  32. public static function getMarket()
  33. {
  34. $markets = self::select('id','name')
  35. ->where('status',1)
  36. ->whereNull('deleted_at')
  37. ->get();
  38. $item = [];
  39. foreach ($markets as $market) {
  40. $item[$market->id] = $market->name;
  41. }
  42. return $item;
  43. }
  44. /**
  45. * 获取单个市场信息
  46. */
  47. public static function getMarketInfo($id,$field = '*')
  48. {
  49. return self::select($field)->find($id);
  50. }
  51. }