title: Laravel Special Token to Register
body: <p>I been trynna make a token system / invite code system for my laravel application but i am having some trobules since im new to laravel.</p>
  <p>Anyways this is my RegisterController.php (i am using the default on, but i've added onto it)</p>
  <pre><code>    /**
       * Get a validator for an incoming registration request.
       *
       * @param  array  $data
       * @return \Illuminate\Contracts\Validation\Validator
       */
      protected function validator(array $data)
      {
          return Validator::make($data, [
              'name' =&gt; ['required', 'string', 'max:255', 'unique:users'],
              'email' =&gt; ['required', 'string', 'email', 'max:255', 'unique:users'],
              'password' =&gt; ['required', 'string', 'min:8', 'confirmed'],
              'code' =&gt; ['required', 'required', 'string', 'exists:codes,code',]
          ]);
      }
  
      /**
       * Create a new user instance after a valid registration.
       *
       * @param  array  $data
       * @return \App\User
       */
      protected function create(array $data)
      {
          $usedcode = $data['code'];
          $code = DB::table('codes')-&gt;where('code', $usedcode)-&gt;first();
          $invby = $code-&gt;by;
          return User::create([
              'name' =&gt; $data['name'],
              'email' =&gt; $data['email'],
              'password' =&gt; Hash::make($data['password']),
              'by' =&gt; $invby,
          ]);
          $code-&gt;user = $usedcode;
          $code-&gt;save();
      }
  </code></pre>
  <p>As you can see from the above code, currently it does work to validate invite code but the thing is it skips to update the other stuff.</p>
  <p>Basically i am trynna make it so after it creates the user it also updates the &quot;codes&quot; table to set the &quot;user&quot; column to the newly registered users ID, and then also trying to update the users table to set the column &quot;by&quot; to the ID that is in the codes table under the column &quot;by&quot;</p>
  <p>So all in all, im trynna grab the new users ID, then insert it into users column in &quot;codes&quot; table.</p>
  <p>Then i am also trying to grab the &quot;by&quot; column from &quot;codes&quot; to then update it into &quot;users&quot; tables column &quot;by&quot; aswell.</p>
  <p>I've tried reforming it, googling and this is my last resort.</p>
  <p>Regards.</p>