初始版本
This commit is contained in:
45
server/app/shopapi/lists/ShopCoachLists.php
Executable file
45
server/app/shopapi/lists/ShopCoachLists.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace app\shopapi\lists;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\skill\Skill;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class CoachController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class ShopCoachLists extends BaseShopApiDataLists{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['shop_id','=',$this->shopId];
|
||||
if(isset($this->params['keyword']) && $this->params['keyword']){
|
||||
$where[] = ['keyword','like','%'.$this->params['keyword'].'%'];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Coach::where($this->setWhere())
|
||||
->field('id,name,good_comment,work_photo,order_num,location')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
// $ids = array_column($lists,'coach_id');
|
||||
// $skillIds = array_column($lists,'skill_id');
|
||||
// $skillLists = Skill::where(['id'=>$skillIds])->column('name','id');
|
||||
foreach ($lists as $key => $coach){
|
||||
$lists[$key]['good_comment'] = $coach['good_comment'].'%';
|
||||
// $lists[$key]['skill_name'] = $skillLists[$coach['skill_id']] ?? '';
|
||||
}
|
||||
return $lists;
|
||||
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Coach::where($this->setWhere())
|
||||
->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user