app/Http/Controllers/RequestproController.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,[
            'request_by'       =>'required',
            'description'   =>'required'
        ],[
            'request_by.required' =>'Request by required',
            'description.required' =>'Description required'
        ]);
        $Req = new Requestpro();
        $Req->date = Carbon::now()->toDateString();
        $Req->request_by = Input::get('request_by');
        $Req->description = Input::get('description');
        $Req->user_id = Auth::user()->id;
        $Req->is_export = 0;
        $Req->save();
        $data = $request->session()->get('requestProduct');
        foreach ($data as $d) {
            $Req->products()->attach($d['id'],
                ['qty'=>$d['qty'],
                    'user_id'=>Auth::user()->id]);
        }
        $request->session()->forget('requestProduct');
        return redirect()->back();
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'request_by' => 'required' , 'description' => 'required' ] , [ 'request_by.required' => 'Request by required' , 'description.required' => 'Description required' ] ) ; $ Req = new Requestpro ( ) ; $ Req -> date = Carbon :: now ( ) -> toDateString ( ) ; $ Req -> request_by = Input :: get ( 'request_by' ) ; $ Req -> description = Input :: get ( 'description' ) ; $ Req -> user_id = Auth :: user ( ) -> id ; $ Req -> is_export = 0 ; $ Req -> save ( ) ; $ data = $ request -> session ( ) -> get ( 'requestProduct' ) ; foreach ( $ data as $ d ) { $ Req -> products ( ) -> attach ( $ d [ 'id' ] , [ 'qty' => $ d [ 'qty' ] , 'user_id' => Auth :: user ( ) -> id ] ) ; } $ request -> session ( ) -> forget ( 'requestProduct' ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .