Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1334 | Revision 1486 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
108 lars 1
<?php
2
 
3
namespace App\Http\Controllers;
4
 
1334 lars 5
use App\Http\Requests\ActionRequest;
6
use App\Models\Action;
7
use Illuminate\Contracts\Foundation\Application;
8
use Illuminate\Contracts\View\Factory;
9
use Illuminate\Contracts\View\View;
10
use Illuminate\Http\RedirectResponse;
108 lars 11
use Illuminate\Http\Request;
12
 
728 lars 13
class ActionController extends Controller
108 lars 14
{
1334 lars 15
    /**
16
     * Display a listing of the resource.
17
     *
18
     */
19
    public function index(): Factory|View|Application
20
    {
21
        //
22
        $actions = Action::orderBy( "rank" )->get();
1482 lars 23
        return view( 'admin/actions', [ "aktionen" => $actions, ] );
1334 lars 24
    }
25
 
26
    /**
27
     * Show the form for creating a new resource.
28
     *
29
     */
30
    public function create(): Factory|View|Application
31
    {
32
        //
33
        return view( 'admin/action' );
34
    }
35
 
36
    /**
37
     * Store a newly created resource in storage.
38
     *
39
     * @param Request $request
40
     * @return RedirectResponse
41
     */
42
    public function store( Request $request ): RedirectResponse
43
    {
44
        //
45
        $rules = [
46
            'name'   => 'bail|max:255',
47
        ];
48
        $request->validate( $rules );
49
        $bu = new Action();
50
        $bu->update( $request->validated() );
51
        return redirect( "/backend/actions" );
52
    }
53
 
54
    /**
55
     * Display the specified resource.
56
     *
57
     * @param int $id
58
     */
59
    public function show( int $id )
60
    {
61
        //
62
    }
63
 
64
    /**
65
     * Show the form for editing the specified resource.
66
     *
67
     * @param int $id
68
     * @return Factory|View|Application
69
     */
70
    public function edit( int $id ): Factory|View|Application
71
    {
72
        //
73
        $action = Action::find( $id );
74
        return view( 'admin/action', [ "action" => $action, ] );
75
    }
76
 
77
 
78
    /**
79
     * Update the specified resource in storage.
80
     *
81
     * @param ActionRequest $request
82
     * @param int $id
83
     * @return RedirectResponse
84
     */
85
    public function update( ActionRequest $request, int $id ): RedirectResponse
86
    {
87
        //
88
        $rules = [
89
            'name'   => 'bail|max:255',
90
        ];
91
        $request->validate( $rules );
92
        $bu = Action::find( $id );
93
        $data = $request->validated();
94
        $bu->update( $data );
95
        return redirect( "/backend/actions" );
96
    }
97
 
98
    /**
99
     * Remove the specified resource from storage.
100
     *
101
     * @param int $id
102
     * @return RedirectResponse
103
     */
104
    public function destroy( int $id ): RedirectResponse
105
    {
106
        //
107
        $bu = Action::find( $id );
108
        $bu->delete();
109
        return redirect( "/backend/actions" );
110
    }
108 lars 111
}