laravel-custom maintained by smallruraldog
Author
Last update
2019/01/24 09:39
(dev-master)
Downloads
1 032
laravel-custom
laravel 5.5+ 一些自定义的扩展帮助工具
安装
首先确保安装好了laravel
composer require smallruraldog/laravel-custom
然后运行下面的命令来发布资源:
php artisan vendor:publish --provider="SmallRuralDog\LaravelCustom\LaravelCustomServiceProvider"
生成配置文件
安装完成之后,所有的配置都在config/laravel-custom.php文件中。
功能列表
- api自定义返回工具
- API 资源扩展
api返回工具使用
App\Exceptions\Handler的render方法
public function render($request, Exception $exception)
{
$report = LaravelCustom::ExceptionReport($exception);
if ($report) {
return $report;
}
return parent::render($request, $exception);
}
异常拦截自定义
//[message:自定义消息,code:状态码,status:状态]
'do-report' => [
\Illuminate\Auth\AuthenticationException::class => ['用户未授权', 401, 'error']
]