Skip to content

Commit d0bd30b

Browse files
authored
Update and rename README.md to LaravelReadme.md
1 parent 01050d2 commit d0bd30b

File tree

2 files changed

+94
-63
lines changed

2 files changed

+94
-63
lines changed

LaravelReadme.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<h1 style="text-align: center;"> support </h1>
2+
3+
## 安装
4+
5+
```shell
6+
$ composer require zhenmu/support -vvv
7+
```
8+
9+
## 使用
10+
11+
### 控制器
12+
13+
```php
14+
<?php
15+
16+
namespace App\Http\Controllers;
17+
18+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
19+
use Illuminate\Foundation\Bus\DispatchesJobs;
20+
use Illuminate\Foundation\Validation\ValidatesRequests;
21+
use Illuminate\Routing\Controller as BaseController;
22+
use ZhenMu\Support\Traits\ResponseTrait; // here
23+
24+
class Controller extends BaseController
25+
{
26+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
27+
use ResponseTrait; // here
28+
}
29+
30+
```
31+
32+
33+
### 错误处理
34+
35+
```php
36+
<?php
37+
38+
namespace App\Exceptions;
39+
40+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
41+
use Throwable;
42+
use ZhenMu\Support\Traits\ResponseTrait; // here
43+
44+
class Handler extends ExceptionHandler
45+
{
46+
use ResponseTrait; // here
47+
48+
/**
49+
* A list of exception types with their corresponding custom log levels.
50+
*
51+
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
52+
*/
53+
protected $levels = [
54+
//
55+
];
56+
57+
/**
58+
* A list of the exception types that are not reported.
59+
*
60+
* @var array<int, class-string<\Throwable>>
61+
*/
62+
protected $dontReport = [
63+
//
64+
];
65+
66+
/**
67+
* A list of the inputs that are never flashed for validation exceptions.
68+
*
69+
* @var array<int, string>
70+
*/
71+
protected $dontFlash = [
72+
'current_password',
73+
'password',
74+
'password_confirmation',
75+
];
76+
77+
/**
78+
* Register the exception handling callbacks for the application.
79+
*
80+
* @return void
81+
*/
82+
public function register()
83+
{
84+
$this->reportable(function (Throwable $e) {
85+
//
86+
});
87+
88+
$this->renderable($this->renderableHandle()); // here
89+
}
90+
}
91+
92+
```
93+
94+
**注意:头请求未声明此次请求需要返回 json 数据时,`$this->fail($message, $err_code)` 的错误码需要符合 http status_code 响应码**

README.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)