app/Http/Controllers/Tutor/ReportCardsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\ProgressReport  $progressReport
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, ProgressReport $reportcard)
    {
        $validator = Validator::make($request->all(), [
            'sname'                 => ['required', 'integer'],
            'student_prepared'      => ['required', 'integer'],
            'questions_ready'       => ['required', 'integer'],
            'pay_attention'         => ['required', 'integer'],
            'weaknesses'            => ['required', 'string'],
            'listen_to_suggestions' => ['required', 'integer'],
            'improvements'          => ['required', 'string'],
            'other_comments'        => ['required', 'string'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('tutor.reportcards.edit', $reportcard);
        }
        $data = $request->all();
        $reportcard['student_id']               = $data['sname'];
        $reportcard['student_prepared']         = $data['student_prepared'];
        $reportcard['questions_ready']          = $data['questions_ready'];
        $reportcard['pay_attention']            = $data['pay_attention'];
        $reportcard['weaknesses']               = $data['weaknesses'];
        $reportcard['listen_to_suggestions']    = $data['listen_to_suggestions'];
        $reportcard['improvements']             = $data['improvements'];
        $reportcard['other_comments']           = $data['other_comments'];
        if (!$reportcard -> save())
        {
            $request->session()->flash('error', "There is an error updaing Report card.");
            return redirect()->route('tutor.reportcards.edit', $reportcard);
        }
        $request->session()->flash('success', "Report card updated successfully.");
        return redirect()->route('tutor.reportcards.index');
    }
public function update ( Request $ request , ProgressReport $ reportcard ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'sname' => [ 'required' , 'integer' ] , 'student_prepared' => [ 'required' , 'integer' ] , 'questions_ready' => [ 'required' , 'integer' ] , 'pay_attention' => [ 'required' , 'integer' ] , 'weaknesses' => [ 'required' , 'string' ] , 'listen_to_suggestions' => [ 'required' , 'integer' ] , 'improvements' => [ 'required' , 'string' ] , 'other_comments' => [ 'required' , 'string' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'tutor.reportcards.edit' , $ reportcard ) ; } $ data = $ request -> all ( ) ; $ reportcard [ 'student_id' ] = $ data [ 'sname' ] ; $ reportcard [ 'student_prepared' ] = $ data [ 'student_prepared' ] ; $ reportcard [ 'questions_ready' ] = $ data [ 'questions_ready' ] ; $ reportcard [ 'pay_attention' ] = $ data [ 'pay_attention' ] ; $ reportcard [ 'weaknesses' ] = $ data [ 'weaknesses' ] ; $ reportcard [ 'listen_to_suggestions' ] = $ data [ 'listen_to_suggestions' ] ; $ reportcard [ 'improvements' ] = $ data [ 'improvements' ] ; $ reportcard [ 'other_comments' ] = $ data [ 'other_comments' ] ; if ( ! $ reportcard -> save ( ) ) { $ request -> session ( ) -> flash ( 'error' , " There is an error updaing Report card. " ) ; return redirect ( ) -> route ( 'tutor.reportcards.edit' , $ reportcard ) ; } $ request -> session ( ) -> flash ( 'success' , " Report card updated successfully. " ) ; return redirect ( ) -> route ( 'tutor.reportcards.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .