app/Http/Controllers/ItemController.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)
    {
        $date = Carbon::today()->addWeeks(2)->toDateString();
        $this->validate($request, [
            'batchNo' => 'required',
            'name' => 'required',
            'qty' => 'required|integer|gt:0',
            'unitPrice' => 'required|numeric|gt:0',
            'exp' => 'required|date|after_or_equal:' . $date
        ]);
        $item = new Item;
        $item->batchNo = $request->input('batchNo');
        $item->name = $request->input('name');
        $item->qty = $request->input('qty');
        $item->unitPrice = $request->input('unitPrice');
        $item->exp = $request->input('exp');
        $item->save();
        return redirect('/')->with('success', 'Item Added');
    }
public function store ( Request $ request ) { $ date = Carbon :: today ( ) -> addWeeks ( 2 ) -> toDateString ( ) ; $ this -> validate ( $ request , [ 'batchNo' => 'required' , 'name' => 'required' , 'qty' => 'required|integer|gt:0' , 'unitPrice' => 'required|numeric|gt:0' , 'exp' => 'required|date|after_or_equal:' . $ date ] ) ; $ item = new Item ; $ item -> batchNo = $ request -> input ( 'batchNo' ) ; $ item -> name = $ request -> input ( 'name' ) ; $ item -> qty = $ request -> input ( 'qty' ) ; $ item -> unitPrice = $ request -> input ( 'unitPrice' ) ; $ item -> exp = $ request -> input ( 'exp' ) ; $ item -> save ( ) ; return redirect ( '/' ) -> with ( 'success' , 'Item Added' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//VALIDATION //CREATE ITEM