44 lines
941 B
PHP
44 lines
941 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Api\Material;
|
|
|
|
use App\Constants\Common\MaterialCode;
|
|
use App\Model\Material;
|
|
use App\Service\Api\BaseService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
|
class MaterialService extends BaseService{
|
|
|
|
/**
|
|
* @var Material
|
|
*/
|
|
#[Inject]
|
|
protected Material $MaterialModel;
|
|
|
|
public function handle()
|
|
{
|
|
|
|
}
|
|
|
|
public function materialList(): array
|
|
{
|
|
$limit = (int)$this->request->input('limit', 10);
|
|
$name = $this->request->input('query_name');
|
|
|
|
$list = $this
|
|
->MaterialModel
|
|
->where('is_del',MaterialCode::IS_NO_DEL)
|
|
->where('status',MaterialCode::ENABLE)
|
|
->when(!empty($name), function ($query) use ($name) {
|
|
$query->where('name', 'like', "$name%");
|
|
})
|
|
->paginate($limit)->toArray();
|
|
|
|
return $this->return->success('success',$list);
|
|
}
|
|
|
|
|
|
|
|
} |