app/Http/Controllers/Tutor/EssaysController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\EssayAssignment  $essayAssignment
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, EssayAssignment $essay)
    {
        $validator = Validator::make($request->all(), [
            'date_completed'    => ['required', 'date'],
            'status'            => ['required', 'integer']
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('tutor.essays.edit', $essay);
        }
        $data = $request->all();
        $essay->date_completed = $data['date_completed'];
        $essay->status_id = $data['status'];
        if (!$essay->save())
        {
            $request->session()->flash('error', "There is an error modifying Assignments!");
            return redirect()->route('tutor.essays.edit', $essay);
        }
        $request->session()->flash('success', "You have modified Assignments!");
        return redirect()->route('tutor.essays.index');
    }
public function update ( Request $ request , EssayAssignment $ essay ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'date_completed' => [ 'required' , 'date' ] , 'status' => [ 'required' , 'integer' ] ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'tutor.essays.edit' , $ essay ) ; } $ data = $ request -> all ( ) ; $ essay -> date_completed = $ data [ 'date_completed' ] ; $ essay -> status_id = $ data [ 'status' ] ; if ( ! $ essay -> save ( ) ) { $ request -> session ( ) -> flash ( 'error' , " There is an error modifying Assignments! " ) ; return redirect ( ) -> route ( 'tutor.essays.edit' , $ essay ) ; } $ request -> session ( ) -> flash ( 'success' , " You have modified Assignments! " ) ; return redirect ( ) -> route ( 'tutor.essays.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .