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

Revision

Revision 222 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

    namespace App\Http\Controllers\bestellwesen;

    use App\Http\Controllers\Controller;
    use App\Http\Requests\StoreSupplierRequest;
    use App\Http\Requests\UpdateSupplierRequest;
    use App\Models\Supplier;
    use Illuminate\Contracts\Foundation\Application;
    use Illuminate\Contracts\View\Factory;
    use Illuminate\Contracts\View\View;
    use Illuminate\Support\Facades\Schema;

    class SupplierController extends Controller
    {

        public function __construct()
        {
            $vk = false;
            if ( Schema::hasColumn( 'shippings', 'supplier_id' ) )
            {
                $vk = true;
            }
            \View::share( 'vk', $vk );
        }

        /**
         * Display a listing of the resource.
         *
         * @return Application|Factory|View
         */
        public function index(): View|Factory|Application
        {
            //
            return view( "bestellwesen.supplierList", [ "lieferanten" => Supplier::all() ] );
        }

        /**
         * Show the form for creating a new resource.
         *
         * @return Application|Factory|View
         */
        public function create(): View|Factory|Application
        {
            //
            return view( "bestellwesen.supplier" );
        }

        /**
         * Store a newly created resource in storage.
         *
         * @param StoreSupplierRequest $request
         * @return string
         */
        public function store( StoreSupplierRequest $request ): string
        {
            //
            $data = $request->validated();
            Supplier::create( $data );
            return "{}";
        }

        /**
         * Display the specified resource.
         *
         * @param Supplier $supplier
         * @return void
         */
        public function show( Supplier $supplier ): void
        {
            //
            echo $supplier->name;
        }

        /**
         * Show the form for editing the specified resource.
         *
         * @param Supplier $supplier
         * @return Application|Factory|View
         */
        public function edit( Supplier $supplier ): View|Factory|Application
        {
            //
            return view( "bestellwesen.supplier", [ "lieferant" => $supplier ] );
        }

        /**
         * Update the specified resource in storage.
         *
         * @param UpdateSupplierRequest $request
         * @param Supplier $supplier
         * @return string
         */
        public function update( UpdateSupplierRequest $request, Supplier $supplier ): string
        {
            //
            $data = $request->validated();
            $supplier->update( $data );
            return "{}";
        }

        /**
         * Remove the specified resource from storage.
         *
         * @param Supplier $supplier
         * @return string
         */
        public function destroy( Supplier $supplier ): string
        {
            //
            $supplier->delete();
            return "{}";
        }
    }