Issues (84)

app/Http/Controllers/DivisionsController.php (3 issues)

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Association;
6
use App\Division;
7
use Bouncer;
0 ignored issues
show
The type Bouncer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Http\Request;
9
10
class DivisionsController extends Controller
11
{
12
13
    public function create(Association $association) {
14
        return view('division.create', [
15
            'association' => $association,
16
        ]);
17
    }
18
19
    public function store(Association $association, Request $request) {
20
        if (Bouncer::can('create', Division::class)) {
21
            $validatedData = $request->validate([
0 ignored issues
show
The assignment to $validatedData is dead and can be removed.
Loading history...
22
                'name' => 'required|max:255',
23
            ]);
24
25
            $division = new Division;
26
27
            $division->name = $request->name;
28
            $division->sequence = $request->sequence;
29
            $division->association_id = $association->id;
30
31
            $division->save();
32
33
            return redirect()->route('association.divisions', ['association' => $association]);
34
        }
35
        else {
36
            return view('denied');
37
        }
38
    }
39
40
    public function update(Association $association, Division $division, Request $request) {
41
        if (Bouncer::can('update', Division::class)) {
42
            $validatedData = $request->validate([
0 ignored issues
show
The assignment to $validatedData is dead and can be removed.
Loading history...
43
                'name' => 'required|max:255',
44
            ]);
45
46
            $division->name = $request->name;
47
            $division->sequence = $request->sequence;
48
            $division->association_id = $association->id;
49
50
            $division->save();
51
52
            return redirect()->route('association.divisions', ['association' => $association]);
53
        }
54
        else {
55
            return view('denied');
56
        }
57
    }
58
59
    public function edit(Association $association, Division $division) {
60
        if (Bouncer::can('edit', $division)) {
61
            return view('division.edit', [
62
                'association' => $association,
63
                'division' => $division,
64
            ]);
65
        }
66
        else {
67
            return view('denied');
68
        }
69
    }
70
71
    public function deleteConfirm(Association $association, Division $division) {
72
        if (Bouncer::can('delete', $division)) {
73
            return view('division.delete', ['division' => $division]);
74
        }
75
        else {
76
            return view('denied');
77
        }
78
    }
79
80
    public function delete(Association $association, Division $division) {
81
        if (Bouncer::can('delete', $division)) {
82
            $division->delete();
83
84
            return redirect()->route('association.divisions', ['association' => $association])->with('success', 'Division deleted successfully.');
85
        }
86
        else {
87
            return view('denied');
88
        }
89
    }
90
91
}
92