mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 21:37:50 +08:00
47 lines
830 B
PHP
47 lines
830 B
PHP
<?php
|
|
|
|
namespace App\Common\Trait;
|
|
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
trait HttpMethodTrait
|
|
{
|
|
/**
|
|
* @var RequestInterface
|
|
*/
|
|
#[Inject]
|
|
protected readonly RequestInterface $request;
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isCreate(): bool
|
|
{
|
|
return $this->request->isMethod('POST');
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isUpdate(): bool
|
|
{
|
|
return $this->request->isMethod('PATCH') || $this->request->isMethod('PUT');
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isDelete(): bool
|
|
{
|
|
return $this->request->isMethod('DELETE');
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function isSearch(): bool
|
|
{
|
|
return $this->request->isMethod('GET');
|
|
}
|
|
} |