mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 15:57:50 +08:00
fix : update path And request
This commit is contained in:
47
app/Common/Trait/HttpMethodTrait.php
Normal file
47
app/Common/Trait/HttpMethodTrait.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user