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

60 lines
1.3 KiB

  1. <?php
  2. namespace App\Models\v3;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Database\Eloquent\Model;
  6. class Market 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. */
  28. public static function getMarketArray($where = [], $options = [])
  29. {
  30. $model = self::whereNull('deleted_at');
  31. // ->where('status',1)
  32. if(!empty($where)){
  33. $model->where($where);
  34. }
  35. $list = $model->pluck('id','name')->toArray();
  36. if(!empty($options)){
  37. $new = array_merge($options,$list);
  38. return array_flip($new);
  39. }else{
  40. return array_flip($list);
  41. }
  42. }
  43. /**
  44. * 获取单个市场信息
  45. */
  46. public static function getMarketInfo($id,$field = '*')
  47. {
  48. return self::select($field)->find($id);
  49. }
  50. }