| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ProductsModel extends Model
- {
- protected $name = "products";
- const Stop = 0;
- const Normal = 1;
- //状态
- public $status_list = [
- '-1' => '全部',
- self::Stop => '停用',
- self::Normal => '正常'
- ];
- //产品
- public function productsList()
- {
- return $this->hasMany('ProductLists', 'type_id', 'id');
- }
- //分类
- public static function getProductTypeAll(string $lan)
- {
- return self::where('status', self::Normal)->order('sort desc')->column('id,'.$lan.'_title as title');
- }
- //分类
- public static function getProductTypeById(string $lan)
- {
- $result = self::where('status', self::Normal)->order('sort desc')->field('id,'.$lan.'_title as title')->select();
- return array_merge([0=>['id'=>0, 'title'=>'全部']], $result);
- }
- }
|