链街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.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::where('status',1)
  31. ->whereNull('deleted_at');
  32. if(!empty($where)){
  33. $model->where($where);
  34. }
  35. $list = $model->pluck('name','id')->toArray();
  36. if(!empty($options)){
  37. return array_merge($options,$list);
  38. }else{
  39. return $list;
  40. }
  41. }
  42. /**
  43. * 获取单个市场信息
  44. */
  45. public static function getMarketInfo($id,$field = '*')
  46. {
  47. return self::select($field)->find($id);
  48. }
  49. }