Passed
Push — master ( 537546...f6872a )
by Jianhua
06:02 queued 15s
created

LogController::edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * @author  Eddy <[email protected]>
4
 */
5
6
namespace App\Http\Controllers\Admin;
7
8
use App\Http\Controllers\Controller;
9
use App\Repository\Admin\LogRepository;
10
use Illuminate\Http\Request;
11
use Illuminate\View\View;
12
13
class LogController extends Controller
14
{
15
    protected $formNames = ['user_name', 'url', 'data'];
16
17
    public function __construct()
18
    {
19
        parent::__construct();
20
21
        $this->breadcrumb[] = ['title' => '日志列表', 'url' => route('admin::log.index')];
22
    }
23
24
    /**
25
     * 日志管理-日志列表
26
     *
27
     */
28
    public function index()
29
    {
30
        $this->breadcrumb[] = ['title' => '日志列表', 'url' => ''];
31
        return view('admin.log.index', ['breadcrumb' => $this->breadcrumb]);
32
    }
33
34
    /**
35
     * 日志管理-日志列表数据接口
36
     *
37
     * @param Request $request
38
     * @return array
39
     */
40
    public function list(Request $request)
41
    {
42
        $perPage = (int) $request->get('limit', 50);
43
        $this->formNames[] = 'created_at';
44
        $condition = $request->only($this->formNames);
45
46
        $data = LogRepository::list($perPage, $condition);
47
48
        return $data;
49
    }
50
51
    /**
52
     * 编辑日志
53
     *
54
     * @param int $id
55
     * @return View
56
     */
57
    public function edit($id)
58
    {
59
        $this->breadcrumb[] = ['title' => '编辑日志', 'url' => ''];
60
61
        $model = LogRepository::find($id);
62
        return view('admin.log.add', ['id' => $id, 'model' => $model, 'breadcrumb' => $this->breadcrumb]);
63
    }
64
}
65