66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Admin\Material;
|
|
|
|
use App\Constants\Common\DishCode;
|
|
use App\Model\Dish;
|
|
use App\Service\Admin\BaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class DishService extends BaseService
|
|
{
|
|
|
|
/**
|
|
* @var Dish
|
|
*/
|
|
#[Inject]
|
|
protected Dish $DishModel;
|
|
|
|
public function handle()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function dishList(): array
|
|
{
|
|
$limit = (int)$this->request->input('limit', 10);
|
|
$id = (int)$this->request->input('query_id');
|
|
$cityId = (int)$this->request->input('query_city_id',0);
|
|
$dishName = $this->request->input('query_dish_name');
|
|
$dateId = (int)$this->request->input('query_date_id');
|
|
$status = (int)$this->request->input('query_status');
|
|
$chefId = (int)$this->request->input('query_chef_id',0);
|
|
|
|
$list = $this->DishModel
|
|
->leftJoin('cycle','dish.cycle_id','=','cycle.id')
|
|
->where('is_del',DishCode::IS_NO_DEL)
|
|
->when($id > 0, function ($query) use ($id) {
|
|
$query->where('id', $id);
|
|
})
|
|
->when($cityId > 0, function ($query) use ($cityId) {
|
|
$query->where('city_id', $cityId);
|
|
})
|
|
->when($dishName, function ($query) use ($dishName) {
|
|
$query->where('dish', 'like', "$dishName%");
|
|
})
|
|
->when($dateId, function ($query) use ($dateId) {
|
|
$query->where('cycle_id', $dateId);
|
|
})
|
|
->when($status, function ($query) use ($status) {
|
|
$query->where('status', $status);
|
|
})
|
|
->when($chefId, function ($query) use ($chefId) {
|
|
$query->where('chef_id', $chefId);
|
|
})
|
|
->orderBy('cycle.dates','desc')
|
|
->paginate($limit,['dish.*','cycle.dates'])->toArray();
|
|
|
|
return $this->return->success('success',$list);
|
|
}
|
|
|
|
} |