Passed
Push — main ( 0c0937...7a01df )
by PRATIK
03:45
created

BlockController::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Adminetic\Website\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Adminetic\Website\Models\Admin\Block;
7
use Adminetic\Website\Http\Requests\BlockRequest;
8
use Adminetic\Website\Contracts\BlockRepositoryInterface;
9
10
11
12
class BlockController extends Controller
13
{
14
    protected $blockRepositoryInterface;
15
16
    public function __construct(BlockRepositoryInterface $blockRepositoryInterface)
17
    {
18
        $this->blockRepositoryInterface = $blockRepositoryInterface;
19
        $this->authorizeResource(Block::class, 'block');
20
    }
21
22
23
    /**
24
     * Display a listing of the resource.
25
     *
26
     * @return \Illuminate\Http\Response
27
     */
28
    public function index()
29
    {
30
        return view('website::admin.block.index', $this->blockRepositoryInterface->indexBlock());
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...nterface->indexBlock()) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
31
    }
32
33
    /**
34
     * Show the form for creating a new resource.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function create()
39
    {
40
        return view('website::admin.block.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::admin.block.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
41
    }
42
43
    /**
44
     * Store a newly created resource in storage.
45
     *
46
     * @param  \Adminetic\Website\Http\Requests\BlockRequest  $request
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function store(BlockRequest $request)
50
    {
51
        $this->blockRepositoryInterface->storeBlock($request);
52
        return redirect(adminRedirectRoute('block'))->withSuccess('Block Created Successfully.');
0 ignored issues
show
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('block'))->withSuccess('Block Created Successfully.');
Loading history...
Bug Best Practice introduced by
The expression return redirect(adminRed...Created Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
53
    }
54
55
    /**
56
     * Display the specified resource.
57
     *
58
     * @param  \Adminetic\Website\Models\Admin\Block  $block
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function show(Block $block)
62
    {
63
        return view('website::admin.block.show', $this->blockRepositoryInterface->showBlock($block));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...ace->showBlock($block)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
64
    }
65
66
    /**
67
     * Show the form for editing the specified resource.
68
     *
69
     * @param  \Adminetic\Website\Models\Admin\Block  $block
70
     * @return \Illuminate\Http\Response
71
     */
72
    public function edit(Block $block)
73
    {
74
        return view('website::admin.block.edit', $this->blockRepositoryInterface->editBlock($block));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('website::ad...ace->editBlock($block)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
75
    }
76
77
    /**
78
     * Update the specified resource in storage.
79
     *
80
     * @param  \Adminetic\Website\Http\Requests\BlockRequest  $request
81
     * @param  \Adminetic\Website\Models\Admin\Block  $block
82
     * @return \Illuminate\Http\Response
83
     */
84
    public function update(BlockRequest $request, Block $block)
85
    {
86
        $this->blockRepositoryInterface->updateBlock($request, $block);
87
        return redirect(adminRedirectRoute('block'))->withInfo('Block Updated Successfully.');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect(adminRed...Updated Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

87
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('block'))->withInfo('Block Updated Successfully.');
Loading history...
88
    }
89
90
    /**
91
     * Remove the specified resource from storage.
92
     *
93
     * @param  \Adminetic\Website\Models\Admin\Block  $block
94
     * @return \Illuminate\Http\Response
95
     */
96
    public function destroy(Block $block)
97
    {
98
        $this->blockRepositoryInterface->destroyBlock($block);
99
        return redirect(adminRedirectRoute('block'))->withFail('Block Deleted Successfully.');
0 ignored issues
show
Bug introduced by
The function adminRedirectRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
        return redirect(/** @scrutinizer ignore-call */ adminRedirectRoute('block'))->withFail('Block Deleted Successfully.');
Loading history...
Bug Best Practice introduced by
The expression return redirect(adminRed...Deleted Successfully.') also could return the type Illuminate\Http\Redirect...nate\Routing\Redirector which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
100
    }
101
}
102