app/Http/Controllers/MedicineController.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(Request $request)
    {
        $this->validate($request, [
            'name'        => 'required|max:255',
            'description' => 'required',
            'amount' => 'required',
            'price' => 'required',
            'storedDate' => 'required'
        ]);
        $medicine = Medincine::create([
            'name'        => request('name'),
            'description' => request('description'),
            'amount'        => request('amount'),
            'price'        => request('price'),
            'storedDate'        => request('storedDate'),
            'user_id'     => Auth::user()->id
        ]);
        return response()->json([
            'medicine'    => $medicine,
            'message' => 'Success'
        ], 200);
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|max:255' , 'description' => 'required' , 'amount' => 'required' , 'price' => 'required' , 'storedDate' => 'required' ] ) ; $ medicine = Medincine :: create ( [ 'name' => request ( 'name' ) , 'description' => request ( 'description' ) , 'amount' => request ( 'amount' ) , 'price' => request ( 'price' ) , 'storedDate' => request ( 'storedDate' ) , 'user_id' => Auth :: user ( ) -> id ] ) ; return response ( ) -> json ( [ 'medicine' => $ medicine , 'message' => 'Success' ] , 200 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .