app/Http/Controllers/PatientController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        DB::beginTransaction();
        try{
            $patient = Patient::find($id);
            $patient->title= $request->input('title');
            $patient->first_name= $request->input('first_name');
            $patient->last_name= $request->input('last_name');
            $patient->other_name= $request->input('other_name');
            $patient->date_of_birth= $request->input('date_of_birth');
            $patient->gender= $request->input('gender');
            $patient->age= Carbon::parse(str_replace('/','-',$request->input('date_of_birth')))->age;
            $patient->marital_status= $request->input('marital_status');
            $patient->other_information= $request->input('other_information');
            $patient->postal_address= $request->input('postal_address');
            $patient->house_number= $request->input('house_number');
            $patient->locality= $request->input('locality');
            $patient->phone_number= $request->input('phone_number');
            $patient->occupation= $request->input('occupation');
            $patient->religion= $request->input('religion');
            $patient->name_of_nearest_relative= $request->input('name_of_relative');
            $patient->number_of_nearest_relative= $request->input('relative_phone_number');
            $patient->user_id=Auth::user()->id;
            $patient->save();
            toastr()->success('Patient\'s Information Updated');
            return redirect()->route('patients.show',[$id]);
        }catch (\Exception $exception){
            DB::rollback();
            toastr()->warning('Something Went Wrong!');
            return back();
        }
    }
public function update ( Request $ request , $ id ) { DB :: beginTransaction ( ) ; try { $ patient = Patient :: find ( $ id ) ; $ patient -> title = $ request -> input ( 'title' ) ; $ patient -> first_name = $ request -> input ( 'first_name' ) ; $ patient -> last_name = $ request -> input ( 'last_name' ) ; $ patient -> other_name = $ request -> input ( 'other_name' ) ; $ patient -> date_of_birth = $ request -> input ( 'date_of_birth' ) ; $ patient -> gender = $ request -> input ( 'gender' ) ; $ patient -> age = Carbon :: parse ( str_replace ( '/' , '-' , $ request -> input ( 'date_of_birth' ) ) ) -> age ; $ patient -> marital_status = $ request -> input ( 'marital_status' ) ; $ patient -> other_information = $ request -> input ( 'other_information' ) ; $ patient -> postal_address = $ request -> input ( 'postal_address' ) ; $ patient -> house_number = $ request -> input ( 'house_number' ) ; $ patient -> locality = $ request -> input ( 'locality' ) ; $ patient -> phone_number = $ request -> input ( 'phone_number' ) ; $ patient -> occupation = $ request -> input ( 'occupation' ) ; $ patient -> religion = $ request -> input ( 'religion' ) ; $ patient -> name_of_nearest_relative = $ request -> input ( 'name_of_relative' ) ; $ patient -> number_of_nearest_relative = $ request -> input ( 'relative_phone_number' ) ; $ patient -> user_id = Auth :: user ( ) -> id ; $ patient -> save ( ) ; toastr ( ) -> success ( 'Patient\'s Information Updated' ) ; return redirect ( ) -> route ( 'patients.show' , [ $ id ] ) ; } catch ( \ Exception $ exception ) { DB :: rollback ( ) ; toastr ( ) -> warning ( 'Something Went Wrong!' ) ; return back ( ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .