app/Http/Controllers/AssetsController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(AssetsRequest $request)
    {
        $asset = new Asset();
        $asset->name  = $request->name;
        $asset->descr  = $request->descr;
        $asset->stock = $request->stock;
        $asset->danger_level = $request->danger_level;
        $asset->hospital_id = auth()->user()->hospital_id;
        $asset->save();
        return response()->json(['content' => $asset, 'state' => 200]);
    }
public function store ( AssetsRequest $ request ) { $ asset = new Asset ( ) ; $ asset -> name = $ request -> name ; $ asset -> descr = $ request -> descr ; $ asset -> stock = $ request -> stock ; $ asset -> danger_level = $ request -> danger_level ; $ asset -> hospital_id = auth ( ) -> user ( ) -> hospital_id ; $ asset -> save ( ) ; return response ( ) -> json ( [ 'content' => $ asset , 'state' => 200 ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .