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

49 lines
1.1 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 GoodsBanners extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. // use SoftDeletes;
  10. protected $table = 'lanzu_goods_banners';
  11. protected $dateFormat = 'U';
  12. protected $fillable = ['path', 'id', 'goods_id','type','url'];
  13. /**
  14. * 获取单个信息
  15. * @param int $id
  16. * @param string $field
  17. * @return string
  18. */
  19. public static function getInfo($id,$field = '*')
  20. {
  21. return self::select($field)->find($id);
  22. }
  23. /**
  24. * 获取二级分类数组
  25. * id为键,path为值
  26. * @return array
  27. */
  28. public static function getArray($where = [],$options = [])
  29. {
  30. $model = self::whereNull('deleted_at');
  31. if(count($where) > 0){
  32. $model->where($where);
  33. }
  34. $list = $model->pluck('id','path')->toArray();
  35. if(!empty($options)){
  36. $new = array_merge($options,$list);
  37. return array_flip($new);
  38. }else{
  39. return array_flip($list);
  40. }
  41. }
  42. }