app/Http/Controllers/Admin/RejectedTutorsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\User  $user
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, User $rejectedtutor)
    {
        $validator = Validator::make($request->all(), [
            'email'             => ['required', 'email','unique:users'],
            'fname'             => ['required', 'string'],
            'lname'             => ['required', 'string'],
            'home_phone'        => ['required', 'string'],
            'cell_phone'        => ['nullable', 'string'],
            'password'          => ['required', 'string', 'min:1', 'confirmed'],
            'address'           => ['required', 'string'],
            'city'              => ['required', 'string'],
            'state_id'          => ['required', 'integer'],
            'pcode'             => ['required', 'string'],
            'country_id'        => ['required', 'integer'],
            'other_notes'       => ['required', 'string'],
            'post_secondary_edu'=> ['required', 'string'],
            'area_of_concentration'=> ['required', 'string'],
            'tutoring_courses'  => ['required', 'string'],
            'sex_val'           => ['nullable', 'string'],
            'certified'         => ['required', 'string'],
            'cr_radio'          => ['required', 'string'],
            'cc_radio'          => ['required', 'string'],
            'status'            => ['nullable', 'integer'],
            'approved'          => ['nullable', 'integer'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('admin.rejectedtutors.edit', $rejectedtutor);
        }
        $data = $request->all();
        $rejectedtutor->email = $data['email'];
        $rejectedtutor->fname = $data['fname'];
        $rejectedtutor->lname = $data['lname'];
        $rejectedtutor->home_phone = $data['home_phone'];
        $rejectedtutor->cell_phone = $data['cell_phone'];
        $rejectedtutor->password = $data['password'];
        $rejectedtutor->address = $data['address'];
        $rejectedtutor->city = $data['city'];
        $rejectedtutor->state_id = $data['state_id'];
        $rejectedtutor->pcode = $data['pcode'];
        $rejectedtutor->country_id = $data['country_id'];
        $rejectedtutor->other_notes = $data['other_notes'];
        $rejectedtutor->post_secondary_edu = $data['post_secondary_edu'];
        $rejectedtutor->area_of_concentration = $data['area_of_concentration'];
        $rejectedtutor->tutoring_courses = $data['tutoring_courses'];
        $rejectedtutor->work_experience = $data['work_experience'];
        $rejectedtutor->tutoring_areas = $data['tutoring_areas'];
        $rejectedtutor->gender = $data['sex_val'];
        $rejectedtutor->certified_teacher = $data['certified'];
        $rejectedtutor->criminal_record = $data['cr_radio'];
        $rejectedtutor->criminal_check = $data['cc_radio'];
        $rejectedtutor->approved = $data['approved'];
        if($rejectedtutor->save()){
            $request->session()->flash('success', 'The tutor has been updated successfully');
            return redirect()->route('admin.rejectedtutors.index');
        }
        $request->session()->flash('error', 'There was an error updating the tutor');
        return redirect()->route('admin.rejectedtutors.edit', $rejectedtutor);
    }
public function update ( Request $ request , User $ rejectedtutor ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'email' => [ 'required' , 'email' , 'unique:users' ] , 'fname' => [ 'required' , 'string' ] , 'lname' => [ 'required' , 'string' ] , 'home_phone' => [ 'required' , 'string' ] , 'cell_phone' => [ 'nullable' , 'string' ] , 'password' => [ 'required' , 'string' , 'min:1' , 'confirmed' ] , 'address' => [ 'required' , 'string' ] , 'city' => [ 'required' , 'string' ] , 'state_id' => [ 'required' , 'integer' ] , 'pcode' => [ 'required' , 'string' ] , 'country_id' => [ 'required' , 'integer' ] , 'other_notes' => [ 'required' , 'string' ] , 'post_secondary_edu' => [ 'required' , 'string' ] , 'area_of_concentration' => [ 'required' , 'string' ] , 'tutoring_courses' => [ 'required' , 'string' ] , 'sex_val' => [ 'nullable' , 'string' ] , 'certified' => [ 'required' , 'string' ] , 'cr_radio' => [ 'required' , 'string' ] , 'cc_radio' => [ 'required' , 'string' ] , 'status' => [ 'nullable' , 'integer' ] , 'approved' => [ 'nullable' , 'integer' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'admin.rejectedtutors.edit' , $ rejectedtutor ) ; } $ data = $ request -> all ( ) ; $ rejectedtutor -> email = $ data [ 'email' ] ; $ rejectedtutor -> fname = $ data [ 'fname' ] ; $ rejectedtutor -> lname = $ data [ 'lname' ] ; $ rejectedtutor -> home_phone = $ data [ 'home_phone' ] ; $ rejectedtutor -> cell_phone = $ data [ 'cell_phone' ] ; $ rejectedtutor -> password = $ data [ 'password' ] ; $ rejectedtutor -> address = $ data [ 'address' ] ; $ rejectedtutor -> city = $ data [ 'city' ] ; $ rejectedtutor -> state_id = $ data [ 'state_id' ] ; $ rejectedtutor -> pcode = $ data [ 'pcode' ] ; $ rejectedtutor -> country_id = $ data [ 'country_id' ] ; $ rejectedtutor -> other_notes = $ data [ 'other_notes' ] ; $ rejectedtutor -> post_secondary_edu = $ data [ 'post_secondary_edu' ] ; $ rejectedtutor -> area_of_concentration = $ data [ 'area_of_concentration' ] ; $ rejectedtutor -> tutoring_courses = $ data [ 'tutoring_courses' ] ; $ rejectedtutor -> work_experience = $ data [ 'work_experience' ] ; $ rejectedtutor -> tutoring_areas = $ data [ 'tutoring_areas' ] ; $ rejectedtutor -> gender = $ data [ 'sex_val' ] ; $ rejectedtutor -> certified_teacher = $ data [ 'certified' ] ; $ rejectedtutor -> criminal_record = $ data [ 'cr_radio' ] ; $ rejectedtutor -> criminal_check = $ data [ 'cc_radio' ] ; $ rejectedtutor -> approved = $ data [ 'approved' ] ; if ( $ rejectedtutor -> save ( ) ) { $ request -> session ( ) -> flash ( 'success' , 'The tutor has been updated successfully' ) ; return redirect ( ) -> route ( 'admin.rejectedtutors.index' ) ; } $ request -> session ( ) -> flash ( 'error' , 'There was an error updating the tutor' ) ; return redirect ( ) -> route ( 'admin.rejectedtutors.edit' , $ rejectedtutor ) ; }
Update the specified resource in storage.
Update the specified resource in storage .