Subversion-Projekte lars-tiefland.webanos.marine-sales.de

Revision

Revision 266 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
176 lars 3
    namespace App\Http\Controllers\online_shop;
2 lars 4
 
234 lars 5
    use App\Http\Controllers\Controller;
262 lars 6
    use App\Http\Requests\StoreShippingRequest;
7
    use App\Http\Requests\UpdateShippingRequest;
2 lars 8
    use App\Models\Shipping;
250 lars 9
    use App\Models\ShippingGroup;
2 lars 10
    use Illuminate\Contracts\Foundation\Application;
11
    use Illuminate\Contracts\View\Factory;
12
    use Illuminate\Contracts\View\View;
13
 
14
    class ShippingController extends Controller
15
    {
16
 
249 lars 17
        public function __construct()
257 lars 18
        {
249 lars 19
            $inselversand = array(
20
                "keine Berücksichtigung",
21
                "kein Inselversand",
22
                "nur Inselversand",
257 lars 23
            );
249 lars 24
            \View::share( "inselversand", $inselversand );
25
            $shippingGroups = ShippingGroup::all();
26
            $versandgruppen = array();
257 lars 27
            foreach ( $shippingGroups as $shippingGroup )
249 lars 28
            {
29
                $versandgruppen[$shippingGroup->id] = $shippingGroup->name;
30
            }
31
            \View::share( "versandgruppen", $versandgruppen );
257 lars 32
        }
33
 
2 lars 34
        public function index(): Factory|View|Application
35
        {
266 lars 36
            $shipping = Shipping::with( "shipping_group" )->whereRaw("supplier_id IS NULL")->orderBy( "rank" )->get();
234 lars 37
            return View( "online_shop.shippingList", [ "shipping" => $shipping ] );
2 lars 38
        }
39
 
257 lars 40
        /**
41
         * Show the form for creating a new resource.
42
         *
43
         * @return Application|Factory|View
44
         */
45
        public function create(): View|Factory|Application
46
        {
47
            //
48
            return view( "online_shop.shipping" );
49
        }
50
 
51
        /**
52
         * Store a newly created resource in storage.
53
         *
262 lars 54
         * @param StoreShippingRequest $request
307 lars 55
         * @return string
257 lars 56
         */
307 lars 57
        public function store( StoreShippingRequest $request ): string
257 lars 58
        {
59
            //
60
            $data = $request->validated();
61
            Shipping::create( $data );
307 lars 62
            return "{}";
257 lars 63
        }
64
 
65
        public function show( Shipping $shipping ): void
66
        {
67
            echo $shipping->name;
68
        }
69
 
70
        /**
71
         * Show the form for editing the specified resource.
72
         *
73
         * @param Shipping $shipping
74
         * @return Application|Factory|View
75
         */
76
        public function edit( Shipping $shipping ): View|Factory|Application
77
        {
78
            //
79
            $shipping->load( 'shipping_group' );
80
            return view( "online_shop.shipping", [ "vk" => $shipping, ] );
81
        }
82
 
83
        /**
84
         * Update the specified resource in storage.
85
         *
262 lars 86
         * @param UpdateShippingRequest $request
257 lars 87
         * @param Shipping $shipping
307 lars 88
         * @return string
257 lars 89
         */
307 lars 90
        public function update( UpdateShippingRequest $request, Shipping $shipping ): string
257 lars 91
        {
92
            //
93
            $data = $request->validated();
94
            $shipping->update( $data );
307 lars 95
            return "{}";
257 lars 96
        }
97
 
98
        /**
99
         * Remove the specified resource from storage.
100
         *
101
         * @param Shipping $shipping
307 lars 102
         * @return string
257 lars 103
         */
307 lars 104
        public function destroy( Shipping $shipping ): string
257 lars 105
        {
106
            //
107
            $shipping->delete();
307 lars 108
            return "{}";
257 lars 109
        }
2 lars 110
    }