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.

76 lines
1.6 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. $model = new self;
  19. $res['count'] = $model->count();
  20. $res['list'] = array();
  21. if($res['count']>0)
  22. {
  23. $res['list'] = $model->orderBy('listorder', 'asc')->skip($offset)->take($limit)->get();
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29. return $res;
  30. }
  31. public static function getOne(array $where)
  32. {
  33. extract($where);
  34. return self::where($where)->first();
  35. }
  36. public static function add(array $data)
  37. {
  38. if ($id = self::insertGetId($data))
  39. {
  40. return $id;
  41. }
  42. return false;
  43. }
  44. public static function modify($where, array $data)
  45. {
  46. if (self::where($where)->update($data) !== false)
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. public static function remove($id)
  53. {
  54. if (!self::whereIn('id', explode(',', $id))->delete())
  55. {
  56. return false;
  57. }
  58. return true;
  59. }
  60. }