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.
52 lines
1.1 KiB
52 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Models\v3;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class GoodsCategory extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'lanzu_goods_category';
|
|
protected $dateFormat = 'U';
|
|
/* 查询记录数 limit */
|
|
protected $perPage = 10;
|
|
|
|
/**
|
|
* 获取单个信息
|
|
* @param int $id
|
|
* @param string $field
|
|
* @return string
|
|
*/
|
|
public static function getInfo($id,$field = '*')
|
|
{
|
|
return self::select($field)->find($id);
|
|
}
|
|
|
|
/**
|
|
* 获取二级分类数组
|
|
* id为键,title为值
|
|
* @return array
|
|
*/
|
|
public static function getArray($where = [],$options = [])
|
|
{
|
|
$model = self::where('status',1)
|
|
->whereNull('deleted_at');
|
|
|
|
if(count($where) > 0){
|
|
$model->where($where);
|
|
}
|
|
$list = $model->pluck('id','title')->toArray();
|
|
if(!empty($options)){
|
|
$new = array_merge($options,$list);
|
|
return array_flip($new);
|
|
}else{
|
|
return $list;
|
|
}
|
|
}
|
|
|
|
}
|