app/Http/Controllers/Admin/customerController.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(CustomerValidator $request, $id)
    {
        $customer = Customer::findorfail($id);
        if ($request->hasFile('image')) {
            $new_img = $request->file('image');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/customer/',$name);
            $customer->image = $name;    
        }else{
            $customer->image = Auth::user()->image;
        }
        if ($request->hasFile('frontcitizenshipimage')) {
            $new_front = $request->file('frontcitizenshipimage');
            $frontimage = "citizenfront-" . time() .'.'. $new_front->getClientOriginalExtension();
            $new_front->move('images/customer/',$frontimage);
            $customer->frontcitizenshipimage = $frontimage;    
        }else{
            $customer->frontcitizenshipimage = Auth::user()->frontcitizenshipimage;
        }
        if ($request->hasFile('backcitizenshipimage')) {
            $new_back = $request->file('backcitizenshipimage');
            $backimage = "citizenback-" . time() .'.'. $new_back->getClientOriginalExtension();
            $new_back->move('images/customer/',$backimage);
            $customer->backcitizenshipimage = $backimage;    
        }else{
            $customer->backcitizenshipimage = Auth::user()->backcitizenshipimage;
        }
        $customer->fname = $request->input('fname');
        $customer->lname = $request->input('lname');
        $customer->dob = $request->input('dob');
        $customer->phone = $request->input('phone');
        $customer->mobile = $request->input('mobile');
        $customer->city = $request->input('city');
        $customer->district = $request->input('district');
        $customer->permanent_address = $request->input('permanent_address');
        $customer->temporary_address = $request->input('temporary_address');
        $customer->customer_type = $request->input('customer_type');
        $customer->gender = $request->input('gender');
        $customer->save();
        return redirect()->route('customer.index')->with('success', 'Customer Updated Successfully');
    }
public function update ( CustomerValidator $ request , $ id ) { $ customer = Customer :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ new_img = $ request -> file ( 'image' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/customer/' , $ name ) ; $ customer -> image = $ name ; } else { $ customer -> image = Auth :: user ( ) -> image ; } if ( $ request -> hasFile ( 'frontcitizenshipimage' ) ) { $ new_front = $ request -> file ( 'frontcitizenshipimage' ) ; $ frontimage = " citizenfront- " . time ( ) . '.' . $ new_front -> getClientOriginalExtension ( ) ; $ new_front -> move ( 'images/customer/' , $ frontimage ) ; $ customer -> frontcitizenshipimage = $ frontimage ; } else { $ customer -> frontcitizenshipimage = Auth :: user ( ) -> frontcitizenshipimage ; } if ( $ request -> hasFile ( 'backcitizenshipimage' ) ) { $ new_back = $ request -> file ( 'backcitizenshipimage' ) ; $ backimage = " citizenback- " . time ( ) . '.' . $ new_back -> getClientOriginalExtension ( ) ; $ new_back -> move ( 'images/customer/' , $ backimage ) ; $ customer -> backcitizenshipimage = $ backimage ; } else { $ customer -> backcitizenshipimage = Auth :: user ( ) -> backcitizenshipimage ; } $ customer -> fname = $ request -> input ( 'fname' ) ; $ customer -> lname = $ request -> input ( 'lname' ) ; $ customer -> dob = $ request -> input ( 'dob' ) ; $ customer -> phone = $ request -> input ( 'phone' ) ; $ customer -> mobile = $ request -> input ( 'mobile' ) ; $ customer -> city = $ request -> input ( 'city' ) ; $ customer -> district = $ request -> input ( 'district' ) ; $ customer -> permanent_address = $ request -> input ( 'permanent_address' ) ; $ customer -> temporary_address = $ request -> input ( 'temporary_address' ) ; $ customer -> customer_type = $ request -> input ( 'customer_type' ) ; $ customer -> gender = $ request -> input ( 'gender' ) ; $ customer -> save ( ) ; return redirect ( ) -> route ( 'customer.index' ) -> with ( 'success' , 'Customer Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .