BlockController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 95
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A index() 0 6 1
A create() 0 4 1
A store() 0 7 1
A edit() 0 4 1
A update() 0 12 2
A destroy() 0 7 1
1
<?php
2
3
namespace Modules\Block\Http\Controllers\Admin;
4
5
use Modules\Block\Entities\Block;
6
use Modules\Block\Http\Requests\CreateBlockRequest;
7
use Modules\Block\Http\Requests\UpdateBlockRequest;
8
use Modules\Block\Repositories\BlockRepository;
9
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
10
11
class BlockController extends AdminBaseController
12
{
13
    /**
14
     * @var BlockRepository
15
     */
16
    private $block;
17
18
    public function __construct(BlockRepository $block)
19
    {
20
        parent::__construct();
21
22
        $this->block = $block;
23
    }
24
25
    /**
26
     * Display a listing of the resource.
27
     *
28
     * @return Response
29
     */
30
    public function index()
31
    {
32
        $blocks = $this->block->all();
33
34
        return view('block::admin.blocks.index', compact('blocks'));
35
    }
36
37
    /**
38
     * Show the form for creating a new resource.
39
     *
40
     * @return Response
41
     */
42
    public function create()
43
    {
44
        return view('block::admin.blocks.create');
45
    }
46
47
    /**
48
     * Store a newly created resource in storage.
49
     *
50
     * @param  CreateBlockRequest $request
51
     * @return Response
52
     */
53
    public function store(CreateBlockRequest $request)
54
    {
55
        $this->block->create($request->all());
56
57
        return redirect()->route('admin.block.block.index')
58
            ->withSuccess(trans('block::blocks.messages.block created'));
59
    }
60
61
    /**
62
     * Show the form for editing the specified resource.
63
     *
64
     * @param  Block $block
65
     * @return Response
66
     */
67
    public function edit(Block $block)
68
    {
69
        return view('block::admin.blocks.edit', compact('block'));
70
    }
71
72
    /**
73
     * Update the specified resource in storage.
74
     *
75
     * @param  Block $block
76
     * @param  UpdateBlockRequest $request
77
     * @return Response
78
     */
79
    public function update(Block $block, UpdateBlockRequest $request)
80
    {
81
        $this->block->update($block, $request->all());
82
83
        if ($request->get('button') === 'index') {
84
            return redirect()->route('admin.block.block.index')
85
                ->withSuccess(trans('block::blocks.messages.block updated'));
86
        }
87
88
        return redirect()->back()
89
            ->withSuccess(trans('block::blocks.messages.block updated'));
90
    }
91
92
    /**
93
     * Remove the specified resource from storage.
94
     *
95
     * @param  Block $block
96
     * @return Response
97
     */
98
    public function destroy(Block $block)
99
    {
100
        $this->block->destroy($block);
101
102
        return redirect()->route('admin.block.block.index')
103
            ->withSuccess(trans('block::blocks.messages.block deleted'));
104
    }
105
}
106