Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Not storing the data into database If I add few more input fields to signup form

    Knowledge Base
    3
    5
    876
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Keerthi last edited by

      Hi,

      I have added few more input fields to signup page like phone, house_no, street, etc. Later I have added these fields to validate method in RegistrationController.php file and then I have created few more columns in database for which I have created sign up page like phone, house_no, street, etc. The problem is only phone number only storing along with first_name, last_name, etc. in database but not storing house_no, street, etc. Please find below is the code for controller and see the screenshot for signup page, thank you.

        public function create(Request $request)
          {
              $request->validate([
                  'first_name' => 'string|required',
                  'last_name' => 'string|required',
                  'phone' => 'string|required',
                  'house_no' => 'string|required',
                  'street' => 'string|required',
                  'area' => 'string|required',
                  'city' => 'string|required',
                  'pincode' => 'string|required',
                  'landmark' => 'string|required',
                  'email' => 'email|required|unique:customers,email',
                  'password' => 'confirmed|min:6|required',
              ]);
      
              $data = request()->input();
           
              $data['password'] = bcrypt($data['password']);
      
              $data['channel_id'] = core()->getCurrentChannel()->id;
      
              if (core()->getConfigData('customer.settings.email.verification')) {
                  $data['is_verified'] = 0;
              } else {
                  $data['is_verified'] = 1;
              }
      
              $data['customer_group_id'] = $this->customerGroup->findOneWhere(['code' => 'general'])->id;
      
              $verificationData['email'] = $data['email'];
              $verificationData['token'] = md5(uniqid(rand(), true));
              $data['token'] = $verificationData['token'];
      
              Event::fire('customer.registration.before');
      
              $customer = $this->customer->create($data);
      
              Event::fire('customer.registration.after', $customer);
      
              if ($customer) {
                  if (core()->getConfigData('customer.settings.email.verification')) {
                      try {
                          Mail::queue(new VerificationEmail($verificationData));
      
                          session()->flash('success', trans('shop::app.customer.signup-form.success-verify'));
                      } catch (\Exception $e) {
                          session()->flash('info', trans('shop::app.customer.signup-form.success-verify-email-unsent'));
                      }
                  } else {
                      session()->flash('success', trans('shop::app.customer.signup-form.success'));
                  }
      
                  return redirect()->route($this->_config['redirect']);
              } else {
                  session()->flash('error', trans('shop::app.customer.signup-form.failed'));
      
                  return redirect()->back();
              }
          }
      

      screencapture-localhost-bagisto-socialite-master-customer-register-2019-07-17-10_23_30.png

      1 Reply Last reply Reply Quote 0
      • R
        rahul last edited by

        Hi @Keerthi

        Did you mentioned your fillable attribute in customer model ?

         protected $fillable = ['first_name', 'channel_id', 'last_name', 'gender', 'date_of_birth', 'email', 'phone', 'password', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'notes', 'status'];
        

        If not then please do it & then check.

        Thanks

        1 Reply Last reply Reply Quote 1
        • K
          Keerthi last edited by

          Hi,

          Thank you, now It is working fine. Actually I forgot to update in model, once again thank you so much.

          1 Reply Last reply Reply Quote 0
          • A
            aroobaarooj499 last edited by

            hi! @rahul i want to add few more fields along with product quantity to add some necessary data in order but i am unable to do that ...can you please guide me ?

            1 Reply Last reply Reply Quote 0
            • R
              rahul last edited by

              Hi @aroobaarooj499

              Create your package, override model in your package, add fields in this model, override the same name route for the order which calls your controller and through your controller, calls your repository ( Order repository, which you need to create in your package) and save data accordingly.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post