app/Http/Controllers/Admin/vendorController.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(VendorValidator $request, $id)
    {
        $vendor = Vendor::findorfail($id);
        if ($request->hasFile('image')) {
            $new_img = $request->file('image');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/vendor/',$name);
            $vendor->image = $name;    
        }else{
            $vendor->image =$image;
        }
        if ($request->hasFile('resume')) {
            $new_resume = $request->file('resume');
            $vendorresume = "resume-" . time() .'.'. $new_resume->getClientOriginalExtension();
            $new_resume->move('images/vendor/',$vendorresume);
            $vendor->resume = $vendorresume;    
        }else{
            $vendor->resume = $resume;
        }
        if ($request->hasFile('ctzn_front')) {
            $new_ctzn_front = $request->file('ctzn_front');
            $vendorctzn_front = "citizenfront-" . time() .'.'. $new_ctzn_front->getClientOriginalExtension();
            $new_ctzn_front->move('images/vendor/',$vendorctzn_front);
            $vendor->ctzn_front = $vendorctzn_front;    
        }else{
            $vendor->ctzn_front = $ctzn_front;
        }
        if ($request->hasFile('ctzn_back')) {
            $new_ctzn_back = $request->file('ctzn_back');
            $vendorctzn_back = "citizenback-" . time() .'.'. $new_ctzn_back->getClientOriginalExtension();
            $new_ctzn_back->move('images/vendor/',$vendorctzn_back);
            $vendor->ctzn_back = $vendorctzn_back;    
        }else{
            $vendor->ctzn_back = $ctzn_back;
        }
        if ($request->hasFile('offer_letter')) {
            $new_offer_letter = $request->file('offer_letter');
            $offer= "appointment-" . time() .'.'. $new_offer_letter->getClientOriginalExtension();
            $new_offer_letter->move('images/vendor/',$offer);
            $vendor->offer_letter = $offer;    
        }else{
            $vendor->offer_letter = $offer_letter;
        }
        if ($request->hasFile('joining_letter')) {
            $new_joining_letter = $request->file('joining_letter');
            $join = "appointment-" . time() .'.'. $new_joining_letter->getClientOriginalExtension();
            $new_joining_letter->move('images/vendor/',$join);
            $vendor->joining_letter = $join;    
        }else{
            $vendor->joining_letter = $joining_letter;
        }
        if ($request->hasFile('contract_agreement')) {
            $new_contract_agreement = $request->file('contract_agreement');
            $contract= "contract-" . time() .'.'. $new_contract_agreement->getClientOriginalExtension();
            $new_contract_agreement->move('images/vendor/',$contract);
            $vendor->contract_agreement = $contract;    
        }else{
            $vendor->contract_agreement = $contract_agreement;
        }
        $vendor->fname = $request->input('fname');
        $vendor->lname = $request->input('lname');
        $vendor->dob = $request->input('dob');
        $vendor->email = $request->input('email');
        $vendor->mobileno = $request->input('mobileno');
        $vendor->phoneno = $request->input('phoneno');
        $vendor->registrationnumber = $request->input('registrationnumber');
        $vendor->panvatnumber = $request->input('panvatnumber');
        $vendor->firstcontactperson = $request->input('firstcontactperson');
        $vendor->firstemail = $request->input('firstemail');
        $vendor->firstphone = $request->input('firstphone');
        $vendor->secondcontactperson = $request->input('secondcontactperson');
        $vendor->secondemail = $request->input('secondemail');
        $vendor->secondphone = $request->input('secondphone');
        $vendor->vendor_type = $request->input('vendor_type');
        $vendor->city = $request->input('city');
        $vendor->district = $request->input('district');
        $vendor->permanent_address = $request->input('permanent_address');
        $vendor->temporary_address = $request->input('temporary_address');
        $vendor->gender = $request->input('gender');
        $vendor->save();
        return redirect()->route('Vendors.index')->with('success', 'Vendor Updated Successfully');
    }
public function update ( VendorValidator $ request , $ id ) { $ vendor = Vendor :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ new_img = $ request -> file ( 'image' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/vendor/' , $ name ) ; $ vendor -> image = $ name ; } else { $ vendor -> image = $ image ; } if ( $ request -> hasFile ( 'resume' ) ) { $ new_resume = $ request -> file ( 'resume' ) ; $ vendorresume = " resume- " . time ( ) . '.' . $ new_resume -> getClientOriginalExtension ( ) ; $ new_resume -> move ( 'images/vendor/' , $ vendorresume ) ; $ vendor -> resume = $ vendorresume ; } else { $ vendor -> resume = $ resume ; } if ( $ request -> hasFile ( 'ctzn_front' ) ) { $ new_ctzn_front = $ request -> file ( 'ctzn_front' ) ; $ vendorctzn_front = " citizenfront- " . time ( ) . '.' . $ new_ctzn_front -> getClientOriginalExtension ( ) ; $ new_ctzn_front -> move ( 'images/vendor/' , $ vendorctzn_front ) ; $ vendor -> ctzn_front = $ vendorctzn_front ; } else { $ vendor -> ctzn_front = $ ctzn_front ; } if ( $ request -> hasFile ( 'ctzn_back' ) ) { $ new_ctzn_back = $ request -> file ( 'ctzn_back' ) ; $ vendorctzn_back = " citizenback- " . time ( ) . '.' . $ new_ctzn_back -> getClientOriginalExtension ( ) ; $ new_ctzn_back -> move ( 'images/vendor/' , $ vendorctzn_back ) ; $ vendor -> ctzn_back = $ vendorctzn_back ; } else { $ vendor -> ctzn_back = $ ctzn_back ; } if ( $ request -> hasFile ( 'offer_letter' ) ) { $ new_offer_letter = $ request -> file ( 'offer_letter' ) ; $ offer = " appointment- " . time ( ) . '.' . $ new_offer_letter -> getClientOriginalExtension ( ) ; $ new_offer_letter -> move ( 'images/vendor/' , $ offer ) ; $ vendor -> offer_letter = $ offer ; } else { $ vendor -> offer_letter = $ offer_letter ; } if ( $ request -> hasFile ( 'joining_letter' ) ) { $ new_joining_letter = $ request -> file ( 'joining_letter' ) ; $ join = " appointment- " . time ( ) . '.' . $ new_joining_letter -> getClientOriginalExtension ( ) ; $ new_joining_letter -> move ( 'images/vendor/' , $ join ) ; $ vendor -> joining_letter = $ join ; } else { $ vendor -> joining_letter = $ joining_letter ; } if ( $ request -> hasFile ( 'contract_agreement' ) ) { $ new_contract_agreement = $ request -> file ( 'contract_agreement' ) ; $ contract = " contract- " . time ( ) . '.' . $ new_contract_agreement -> getClientOriginalExtension ( ) ; $ new_contract_agreement -> move ( 'images/vendor/' , $ contract ) ; $ vendor -> contract_agreement = $ contract ; } else { $ vendor -> contract_agreement = $ contract_agreement ; } $ vendor -> fname = $ request -> input ( 'fname' ) ; $ vendor -> lname = $ request -> input ( 'lname' ) ; $ vendor -> dob = $ request -> input ( 'dob' ) ; $ vendor -> email = $ request -> input ( 'email' ) ; $ vendor -> mobileno = $ request -> input ( 'mobileno' ) ; $ vendor -> phoneno = $ request -> input ( 'phoneno' ) ; $ vendor -> registrationnumber = $ request -> input ( 'registrationnumber' ) ; $ vendor -> panvatnumber = $ request -> input ( 'panvatnumber' ) ; $ vendor -> firstcontactperson = $ request -> input ( 'firstcontactperson' ) ; $ vendor -> firstemail = $ request -> input ( 'firstemail' ) ; $ vendor -> firstphone = $ request -> input ( 'firstphone' ) ; $ vendor -> secondcontactperson = $ request -> input ( 'secondcontactperson' ) ; $ vendor -> secondemail = $ request -> input ( 'secondemail' ) ; $ vendor -> secondphone = $ request -> input ( 'secondphone' ) ; $ vendor -> vendor_type = $ request -> input ( 'vendor_type' ) ; $ vendor -> city = $ request -> input ( 'city' ) ; $ vendor -> district = $ request -> input ( 'district' ) ; $ vendor -> permanent_address = $ request -> input ( 'permanent_address' ) ; $ vendor -> temporary_address = $ request -> input ( 'temporary_address' ) ; $ vendor -> gender = $ request -> input ( 'gender' ) ; $ vendor -> save ( ) ; return redirect ( ) -> route ( 'Vendors.index' ) -> with ( 'success' , 'Vendor Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .