Completed
Push — master ( 86fd56...98623b )
by wen
02:52
created

BaseController::buildFailedValidationResponse()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 6
nc 3
nop 2
crap 30
1
<?php
2
3
4
namespace Sco\Admin\Http\Controllers;
5
6
use Auth;
7
use Route;
8
use Breadcrumbs;
9
use Event;
10
use Illuminate\Auth\Events\Authenticated;
11
use Illuminate\Auth\Events\Login;
12
use Illuminate\Routing\Controller;
13
use Illuminate\Foundation\Validation\ValidatesRequests;
14
use Illuminate\Http\Request;
15
use Illuminate\Http\JsonResponse;
16
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
17
18
/**
19
 * 后台基础控制器
20
 * 所有后台控制器都应继承该类
21
 *
22
 */
23
class BaseController extends Controller
24
{
25
26
    use ValidatesRequests;
27
28
    /**
29
     * 后台入口页(控制台)
30
     *
31
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
32
     */
33
    public function index()
34
    {
35
        return view('admin::index');
36
    }
37
38
    /**
39
     * 后台视图输出
40
     *
41
     * @param string $view
42
     * @param array  $params
43
     *
44
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
45
     */
46
    protected function render($view, $params = [])
47
    {
48
        return view('admin::' . $view, $params);
49
    }
50
51
52
    /**
53
     * 重构验证响应方法(主要针对ajax|json)
54
     *
55
     * @param \Illuminate\Http\Request $request
56
     * @param array                    $errors
57
     *
58
     * @return \Illuminate\Http\JsonResponse
59
     */
60
    /*protected function buildFailedValidationResponse(Request $request, array $errors)
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
    {
62
        if (($request->ajax() && !$request->pjax()) || $request->wantsJson()) {
63
            $error = array_shift($errors);
64
            $error = is_array($error) ? current($error) : $error;
65
            return new JsonResponse(error($error));
66
        }
67
        return parent::buildFailedValidationResponse($request, $errors);
68
    }*/
69
}
70