| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\common\model;
- class CustomerModel extends BaseModel
- {
- protected $table = 'erp_customer';
- public function getSexAttr($value) {
- return ['', '男', '女', '未知'][$value];
- }
- protected function genSchema(array $schema)
- {
- // TODO: Implement genSchema() method.
- }
- //for ($i = 2; $i< 10; $i++) {
- //$this->saveAll([
- //[
- //'name' => '佩佩'.$i,
- //'mobile' => '1557692025'.$i,
- //'sex'=> 1,
- //'sun_calendar' => '2020-'.$i.'-11',
- //'lunar_calendar' => '2020-'.($i-1).'-19',
- //'user_id' => 100000,
- //'username' => 'Caviar.',
- //'relation' => '朋友'.$i,
- //'address' => '巴西'.$i,
- //'email' => $i.'@163.com',
- //'store_id' => 1,
- //'linkman' => 'A_Caviar'
- //]
- //]);
- //}
- /**
- * @param array $params
- * @return \think\Paginator
- * @throws \think\db\exception\DbException
- */
- public function findCustomerPage(array $params) {
- $where = [];
- if(isset($params['name'])) {
- array_push($where,['name', 'like', "%".$params['name']."%"]);
- }
- if(count($where) > 0) {
- return $this->where($where)->paginate(10);
- }
- return $this->paginate(10);
- }
- }
|