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.

79 lines
1.7 KiB

7 years ago
  1. <?php
  2. namespace App\Http\Model;
  3. use App\Common\ReturnData;
  4. use DB;
  5. class GoodsBrand extends BaseModel
  6. {
  7. //商品品牌
  8. protected $table = 'goods_brand';
  9. public $timestamps = false;
  10. protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
  11. const UN_SHOW = 1; // 不显示
  12. const IS_SHOW = 0; // 显示
  13. public static function getList(array $param)
  14. {
  15. extract($param); //参数:group_id,limit,offset
  16. $limit = isset($limit) ? $limit : 10;
  17. $offset = isset($offset) ? $offset : 0;
  18. $where['status'] = self::IS_SHOW;
  19. $model = new self;
  20. if($where){$model = $model->where($where);}
  21. $res['count'] = $model->count();
  22. $res['list'] = array();
  23. if($res['count']>0)
  24. {
  25. $res['list'] = $model->orderBy('listorder', 'asc')->skip($offset)->take($limit)->get();
  26. }
  27. else
  28. {
  29. return false;
  30. }
  31. return $res;
  32. }
  33. public static function getOne(array $where)
  34. {
  35. extract($where);
  36. return self::where($where)->first();
  37. }
  38. public static function add(array $data)
  39. {
  40. if ($id = self::insertGetId($data))
  41. {
  42. return $id;
  43. }
  44. return false;
  45. }
  46. public static function modify($where, array $data)
  47. {
  48. if (self::where($where)->update($data) !== false)
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. public static function remove($id)
  55. {
  56. if (!self::whereIn('id', explode(',', $id))->delete())
  57. {
  58. return false;
  59. }
  60. return true;
  61. }
  62. }