feat:dish depot
This commit is contained in:
64
app/Service/Admin/Good/DishService.php
Normal file
64
app/Service/Admin/Good/DishService.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Good;
|
||||
|
||||
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
|
||||
->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);
|
||||
})
|
||||
->paginate($limit)->toArray();
|
||||
|
||||
return $this->return->success('success',$list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user