phpcollective /
menumaker
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace PhpCollective\MenuMaker\Http\Controllers; |
||||
| 4 | |||||
| 5 | use Illuminate\Routing\Controller; |
||||
| 6 | use PhpCollective\MenuMaker\Storage\Menu; |
||||
| 7 | use PhpCollective\MenuMaker\Http\Requests\MenuRequest as Request; |
||||
| 8 | |||||
| 9 | class SectionController extends Controller |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * Display a listing of the resource. |
||||
| 13 | * |
||||
| 14 | * @return \Illuminate\Http\Response |
||||
| 15 | */ |
||||
| 16 | public function index() |
||||
| 17 | { |
||||
| 18 | $sections = Menu::sections()->paginate(); |
||||
| 19 | return view('menu-maker::sections.index', compact('sections')); |
||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
| 20 | } |
||||
| 21 | |||||
| 22 | /** |
||||
| 23 | * Show the form for creating a new resource. |
||||
| 24 | * |
||||
| 25 | * @return \Illuminate\Http\Response |
||||
| 26 | */ |
||||
| 27 | public function create() |
||||
| 28 | { |
||||
| 29 | return view('menu-maker::sections.create'); |
||||
|
0 ignored issues
–
show
|
|||||
| 30 | } |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * Store a newly created resource in storage. |
||||
| 34 | * |
||||
| 35 | * @param Request $request |
||||
| 36 | * @return \Illuminate\Http\Response |
||||
| 37 | */ |
||||
| 38 | public function store(Request $request) |
||||
| 39 | { |
||||
| 40 | Menu::create($request->only('name', 'alias')); |
||||
| 41 | return redirect() |
||||
|
0 ignored issues
–
show
|
|||||
| 42 | ->route('menu-maker::sections.index') |
||||
| 43 | ->withMessage(__('menu-maker::alerts.created', ['name' => $request->name])); |
||||
| 44 | } |
||||
| 45 | |||||
| 46 | /** |
||||
| 47 | * Display the specified resource. |
||||
| 48 | * |
||||
| 49 | * @param Menu $section |
||||
| 50 | * @return \Illuminate\Http\Response |
||||
| 51 | */ |
||||
| 52 | public function show(Menu $section) |
||||
| 53 | { |
||||
| 54 | return view('menu-maker::sections.show', compact('section')); |
||||
|
0 ignored issues
–
show
|
|||||
| 55 | } |
||||
| 56 | |||||
| 57 | /** |
||||
| 58 | * Show the form for editing the specified resource. |
||||
| 59 | * |
||||
| 60 | * @param Menu $section |
||||
| 61 | * @return \Illuminate\Http\Response |
||||
| 62 | */ |
||||
| 63 | public function edit(Menu $section) |
||||
| 64 | { |
||||
| 65 | return view('menu-maker::sections.edit', compact('section')); |
||||
|
0 ignored issues
–
show
|
|||||
| 66 | } |
||||
| 67 | |||||
| 68 | /** |
||||
| 69 | * Update the specified resource in storage. |
||||
| 70 | * |
||||
| 71 | * @param Request $request |
||||
| 72 | * @param Menu $section |
||||
| 73 | * @return \Illuminate\Http\Response |
||||
| 74 | */ |
||||
| 75 | public function update(Request $request, Menu $section) |
||||
| 76 | { |
||||
| 77 | $section->update($request->all()); |
||||
| 78 | return redirect() |
||||
|
0 ignored issues
–
show
|
|||||
| 79 | ->to($request->redirects_to) |
||||
| 80 | ->withMessage(__('menu-maker::alerts.updated', ['name' => $request->name])); |
||||
| 81 | } |
||||
| 82 | |||||
| 83 | /** |
||||
| 84 | * Remove the specified resource from storage. |
||||
| 85 | * |
||||
| 86 | * @param Menu $section |
||||
| 87 | * @return \Illuminate\Http\Response |
||||
| 88 | */ |
||||
| 89 | public function destroy(Menu $section) |
||||
| 90 | { |
||||
| 91 | $name = $section->name; |
||||
| 92 | $section->delete(); |
||||
| 93 | return redirect() |
||||
|
0 ignored issues
–
show
|
|||||
| 94 | ->to(request('redirects_to')) |
||||
|
0 ignored issues
–
show
It seems like
request('redirects_to') can also be of type array; however, parameter $path of Illuminate\Routing\Redirector::to() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 95 | ->withMessage(__('menu-maker::alerts.deleted', ['name' => $name])); |
||||
| 96 | } |
||||
| 97 | } |
||||
| 98 |