Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 728 | Revision 1482 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 728 Revision 1334
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
Zeile -... Zeile 3...
-
 
3
namespace App\Http\Controllers;
-
 
4
 
-
 
5
use App\Http\Requests\ActionRequest;
-
 
6
use App\Models\Action;
-
 
7
use Illuminate\Contracts\Foundation\Application;
-
 
8
use Illuminate\Contracts\View\Factory;
3
namespace App\Http\Controllers;
9
use Illuminate\Contracts\View\View;
Zeile 4... Zeile 10...
4
 
10
use Illuminate\Http\RedirectResponse;
5
use Illuminate\Http\Request;
11
use Illuminate\Http\Request;
-
 
12
 
-
 
13
class ActionController extends Controller
-
 
14
{
-
 
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();
-
 
23
        return view( 'admin/actions', [ "actions" => $actions, ] );
-
 
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.
6
 
100
     *
-
 
101
     * @param int $id
-
 
102
     * @return RedirectResponse
-
 
103
     */
-
 
104
    public function destroy( int $id ): RedirectResponse
-
 
105
    {
-
 
106
        //
-
 
107
        $bu = Action::find( $id );
7
class ActionController extends Controller
108
        $bu->delete();