app/Http/Controllers/Admin/EssayAssignmentsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Essay_Assignment  $essay_Assignment
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, EssayAssignment $essayassignment)
    {
        $validator = Validator::make($request->all(), [
            'assignment_num'    => ['required', 'integer'],
            'tutor_id'          => ['nullable', 'int'],
            'student_id'        => ['nullable', 'int'],
            'topic'             => ['required', 'string'],
            'description'       => ['required', 'string'],
            'file_format'       => ['nullable', 'string'],
            'paid_to_tutor'     => ['nullable', 'string'],
            'price_owed'        => ['nullable', 'string'],
            'date_assigned'     => ['nullable', 'date'],
            'date_completed'    => ['nullable', 'date'],
            'date_due'          => ['nullable', 'date'],
            'status_id'         => ['nullable', 'integer'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('admin.essayassignments.edit', $essayassignment);
        }
        $data = $request->all();
        $essayassignment->assignment_num = $data['assignment_num'];
        $essayassignment->tutor_id = $data['tutor_id'];
        $essayassignment->student_id = $data['student_id'];
        $essayassignment->topic = $data['topic'];
        $essayassignment->description = $data['description'];
        $essayassignment->format = $data['file_format'];
        $essayassignment->paid = $data['paid_to_tutor'];
        $essayassignment->owed = $data['price_owed'];
        $essayassignment->date_assigned = $data['date_assigned'];
        $essayassignment->date_completed = $data['date_completed'];
        $essayassignment->date_due = $data['date_due'];
        $essayassignment->status_id = $data['status_id'];
        if($essayassignment->save()){
            $request->session()->flash('success', 'The Homework Assignmnet has been updated successfully');
            return redirect()->route('admin.essayassignments.index');
        }
        $request->session()->flash('error', 'There was an error updating the homework assignment');
        return redirect()->route('admin.essayassignments.edit');
    }
public function update ( Request $ request , EssayAssignment $ essayassignment ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'assignment_num' => [ 'required' , 'integer' ] , 'tutor_id' => [ 'nullable' , 'int' ] , 'student_id' => [ 'nullable' , 'int' ] , 'topic' => [ 'required' , 'string' ] , 'description' => [ 'required' , 'string' ] , 'file_format' => [ 'nullable' , 'string' ] , 'paid_to_tutor' => [ 'nullable' , 'string' ] , 'price_owed' => [ 'nullable' , 'string' ] , 'date_assigned' => [ 'nullable' , 'date' ] , 'date_completed' => [ 'nullable' , 'date' ] , 'date_due' => [ 'nullable' , 'date' ] , 'status_id' => [ 'nullable' , 'integer' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'admin.essayassignments.edit' , $ essayassignment ) ; } $ data = $ request -> all ( ) ; $ essayassignment -> assignment_num = $ data [ 'assignment_num' ] ; $ essayassignment -> tutor_id = $ data [ 'tutor_id' ] ; $ essayassignment -> student_id = $ data [ 'student_id' ] ; $ essayassignment -> topic = $ data [ 'topic' ] ; $ essayassignment -> description = $ data [ 'description' ] ; $ essayassignment -> format = $ data [ 'file_format' ] ; $ essayassignment -> paid = $ data [ 'paid_to_tutor' ] ; $ essayassignment -> owed = $ data [ 'price_owed' ] ; $ essayassignment -> date_assigned = $ data [ 'date_assigned' ] ; $ essayassignment -> date_completed = $ data [ 'date_completed' ] ; $ essayassignment -> date_due = $ data [ 'date_due' ] ; $ essayassignment -> status_id = $ data [ 'status_id' ] ; if ( $ essayassignment -> save ( ) ) { $ request -> session ( ) -> flash ( 'success' , 'The Homework Assignmnet has been updated successfully' ) ; return redirect ( ) -> route ( 'admin.essayassignments.index' ) ; } $ request -> session ( ) -> flash ( 'error' , 'There was an error updating the homework assignment' ) ; return redirect ( ) -> route ( 'admin.essayassignments.edit' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .