CustomerModel.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\common\model;
  3. class CustomerModel extends BaseModel
  4. {
  5. protected $table = 'erp_customer';
  6. public function getSexAttr($value) {
  7. return ['', '男', '女', '未知'][$value];
  8. }
  9. protected function genSchema(array $schema)
  10. {
  11. // TODO: Implement genSchema() method.
  12. }
  13. //for ($i = 2; $i< 10; $i++) {
  14. //$this->saveAll([
  15. //[
  16. //'name' => '佩佩'.$i,
  17. //'mobile' => '1557692025'.$i,
  18. //'sex'=> 1,
  19. //'sun_calendar' => '2020-'.$i.'-11',
  20. //'lunar_calendar' => '2020-'.($i-1).'-19',
  21. //'user_id' => 100000,
  22. //'username' => 'Caviar.',
  23. //'relation' => '朋友'.$i,
  24. //'address' => '巴西'.$i,
  25. //'email' => $i.'@163.com',
  26. //'store_id' => 1,
  27. //'linkman' => 'A_Caviar'
  28. //]
  29. //]);
  30. //}
  31. /**
  32. * @param array $params
  33. * @return \think\Paginator
  34. * @throws \think\db\exception\DbException
  35. */
  36. public function findCustomerPage(array $params) {
  37. $where = [];
  38. if(isset($params['name'])) {
  39. array_push($where,['name', 'like', "%".$params['name']."%"]);
  40. }
  41. if(count($where) > 0) {
  42. return $this->where($where)->paginate(10);
  43. }
  44. return $this->paginate(10);
  45. }
  46. }