Issues (84)

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

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Association;
6
use App\Venue;
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 VenuesController extends Controller
11
{
12
13
    public function create(Association $association) {
14
        return view('venue.create', [
15
            'association' => $association,
16
        ]);
17
    }
18
19
    public function store(Association $association, Request $request) {
20
        if (Bouncer::can('create', Venue::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
            $venue = new venue;
26
27
            $venue->name = $request->name;
28
            $venue->association_id = $association->id;
29
30
            $venue->save();
31
32
            return redirect()->route('association.venues', ['association' => $association]);
33
        }
34
        else {
35
            return view('denied');
36
        }
37
    }
38
39
    public function edit(Association $association, Venue $venue) {
40
        if (Bouncer::can('edit', Venue::class)) {
41
            return view('venue.edit', ['venue' => $venue]);
42
        }
43
        else {
44
            return view('denied');
45
        }
46
    }
47
48
    public function update(Venue $venue, Request $request) {
49
        if (Bouncer::can('update', Venue::class)) {
50
            $validatedData = $request->validate([
0 ignored issues
show
The assignment to $validatedData is dead and can be removed.
Loading history...
51
                'name' => 'required|max:255',
52
            ]);
53
54
            $venue = Venue::where(['id' => $venue->id])->first();
55
56
            $venue->name = $request->name;
57
58
            $venue->save();
59
60
            return redirect()->route('association.venues', ['association' => $venue->association]);
61
        }
62
        else {
63
            return view('denied');
64
        }
65
    }
66
67
    public function deleteConfirm(Venue $venue) {
68
        if (Bouncer::can('delete', $venue)) {
69
            return view('venue.delete', ['venue' => $venue]);
70
        }
71
        else {
72
            return view('denied');
73
        }
74
    }
75
76
    public function delete(Venue $venue) {
77
        if (Bouncer::can('delete', $venue)) {
78
            $association = $venue->association;
79
80
            $venue->delete();
81
82
            return redirect()->route('association.venues', ['association' => $association])->with('success', 'Venue deleted successfully.');
83
        }
84
        else {
85
            return view('denied');
86
        }
87
    }
88
89
}
90