链街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.

59 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 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 mp(){
  23. return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id');
  24. }
  25. /**
  26. * 获取市场信息
  27. * @return \Illuminate\Http\JsonResponse
  28. */
  29. public static function getMarket()
  30. {
  31. $markets = self::select('id','name')
  32. //->where('status',1)
  33. ->whereNull('deleted_at')
  34. ->get();
  35. $item = [];
  36. foreach ($markets as $market) {
  37. $item[$market->id] = $market->name;
  38. }
  39. return $item;
  40. }
  41. /**
  42. * 获取单个市场信息
  43. */
  44. public static function getMarketInfo($id,$field = '*')
  45. {
  46. return self::select($field)->find($id);
  47. }
  48. }