Product.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Product extends Model
  5. {
  6. public function getSonList($condition)
  7. {
  8. $result = $this
  9. ->where($condition)
  10. ->paginate(10);
  11. return $result;
  12. }
  13. public function getFartherList()
  14. {
  15. $result = $this
  16. ->where(['product_pid' => 0])
  17. ->select();
  18. return $result;
  19. }
  20. public function findProduct($condition)
  21. {
  22. $result = $this
  23. ->where($condition)
  24. ->find();
  25. return $result;
  26. }
  27. public function updateProduct($id, $data)
  28. {
  29. $result = $this
  30. ->where(['product_id' => $id])
  31. ->update($data);
  32. return $result;
  33. }
  34. public function addProduct($data)
  35. {
  36. $result = $this
  37. ->insert($data);
  38. return $result;
  39. }
  40. public function deleteProduct($condition)
  41. {
  42. $result = $this
  43. ->where($condition)
  44. ->delete();
  45. return $result;
  46. }
  47. }