uidaho /
smartsettia
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Http\Controllers; |
||||
| 4 | |||||
| 5 | use Illuminate\Http\Request; |
||||
| 6 | use App\DataTables\SiteDataTable; |
||||
| 7 | use App\Site; |
||||
| 8 | |||||
| 9 | class SiteController extends Controller |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Create a new controller instance. |
||||
| 13 | */ |
||||
| 14 | public function __construct() |
||||
| 15 | { |
||||
| 16 | $this->middleware('auth'); |
||||
| 17 | } |
||||
| 18 | |||||
| 19 | /** |
||||
| 20 | * Display a listing of the resource. |
||||
| 21 | * |
||||
| 22 | * @param SiteDataTable $dataTable |
||||
| 23 | * @return Response |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 24 | */ |
||||
| 25 | public function index(SiteDataTable $dataTable) |
||||
| 26 | { |
||||
| 27 | $this->authorize('index', Site::class); |
||||
| 28 | |||||
| 29 | return $dataTable->render('site.index'); |
||||
|
0 ignored issues
–
show
|
|||||
| 30 | } |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * Show the form for creating a new resource. |
||||
| 34 | * |
||||
| 35 | * @return \Illuminate\Http\Response |
||||
| 36 | */ |
||||
| 37 | public function create() |
||||
| 38 | { |
||||
| 39 | $this->authorize('create', Site::class); |
||||
| 40 | |||||
| 41 | return view('site.create'); |
||||
|
0 ignored issues
–
show
|
|||||
| 42 | } |
||||
| 43 | |||||
| 44 | /** |
||||
| 45 | * Store a newly created resource in storage. |
||||
| 46 | * |
||||
| 47 | * @param \Illuminate\Http\Request $request |
||||
| 48 | * @return \Illuminate\Http\RedirectResponse |
||||
| 49 | */ |
||||
| 50 | View Code Duplication | public function store(Request $request) |
|||
| 51 | { |
||||
| 52 | $this->authorize('store', Site::class); |
||||
| 53 | |||||
| 54 | $request->validate([ |
||||
| 55 | 'name' => 'required|min:2|max:190|name|unique:sites,name', |
||||
| 56 | ]); |
||||
| 57 | |||||
| 58 | $site = Site::create([ 'name' => $request->name ]); |
||||
| 59 | |||||
| 60 | return redirect()->route('site.show', $site->id) |
||||
|
0 ignored issues
–
show
$site->id of type integer is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 61 | ->with('success', 'Site created successfully'); |
||||
| 62 | } |
||||
| 63 | |||||
| 64 | /** |
||||
| 65 | * Display the specified resource. |
||||
| 66 | * |
||||
| 67 | * @param string $id |
||||
| 68 | * @return \Illuminate\Http\Response |
||||
| 69 | */ |
||||
| 70 | public function show($id) |
||||
| 71 | { |
||||
| 72 | $this->authorize('show', Site::class); |
||||
| 73 | |||||
| 74 | $site = Site::findOrFail($id); |
||||
| 75 | $locations = $site->locations()->orderBy('name', 'ASC')->paginate(15); |
||||
| 76 | |||||
| 77 | if (\Request::ajax()) |
||||
| 78 | return response()->json(['site' => $site, 'locations' => $locations]); |
||||
|
0 ignored issues
–
show
|
|||||
| 79 | else |
||||
| 80 | return view('site.show', [ 'site' => $site, 'locations' => $locations ]); |
||||
|
0 ignored issues
–
show
|
|||||
| 81 | } |
||||
| 82 | |||||
| 83 | /** |
||||
| 84 | * Show the form for editing the specified resource. |
||||
| 85 | * |
||||
| 86 | * @param string $id |
||||
| 87 | * @return \Illuminate\Http\Response |
||||
| 88 | */ |
||||
| 89 | public function edit($id) |
||||
| 90 | { |
||||
| 91 | $this->authorize('edit', Site::class); |
||||
| 92 | |||||
| 93 | $site = Site::findOrFail($id); |
||||
| 94 | return view('site.edit', [ 'site' => $site ]); |
||||
|
0 ignored issues
–
show
|
|||||
| 95 | } |
||||
| 96 | |||||
| 97 | /** |
||||
| 98 | * Update the specified resource in storage. |
||||
| 99 | * |
||||
| 100 | * @param \Illuminate\Http\Request $request |
||||
| 101 | * @param Site $site |
||||
| 102 | * @return \Illuminate\Http\RedirectResponse |
||||
| 103 | */ |
||||
| 104 | View Code Duplication | public function update(Request $request, Site $site) |
|||
| 105 | { |
||||
| 106 | $this->authorize('update', Site::class); |
||||
| 107 | |||||
| 108 | $request->validate([ |
||||
| 109 | 'name' => 'required|min:2|max:190|name|unique:sites,name,'.$site->id, |
||||
| 110 | ]); |
||||
| 111 | |||||
| 112 | $site->update([ 'name' => $request->name ]); |
||||
| 113 | |||||
| 114 | return redirect()->route('site.show', $site->id) |
||||
|
0 ignored issues
–
show
$site->id of type integer is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 115 | ->with('success', 'Site updated successfully'); |
||||
| 116 | } |
||||
| 117 | |||||
| 118 | /** |
||||
| 119 | * Remove the specified resource from storage. |
||||
| 120 | * |
||||
| 121 | * @param string $id |
||||
| 122 | * @return \Illuminate\Http\RedirectResponse |
||||
| 123 | */ |
||||
| 124 | public function destroy($id) |
||||
| 125 | { |
||||
| 126 | $this->authorize('destroy', Site::class); |
||||
| 127 | |||||
| 128 | Site::findOrFail($id)->delete(); |
||||
| 129 | return redirect()->route('site.index') |
||||
| 130 | ->with('success', 'Site deleted successfully'); |
||||
| 131 | } |
||||
| 132 | } |
||||
| 133 |