title: I want to limit user referral to 1 referral per device
body: <p>I am working on a referral program for my software, the referral itself works with all the benefits attached to it, but I want it to work like if you share your referral link you shouldn't be able to open more than 1 account per device.</p>
  <p>That is if open an account on my device that's it, any other account opened on that device shouldn't count. I am looking for a way to detect user or device IP so as to limit it to 1 per device, here is my middleware I am using to check for the referral at the point of registration.</p>
  <pre><code>public function handle($request, Closure $next)
  {
      $response = $next($request);
  
      if (!$request-&gt;hasCookie('referral') &amp;&amp; $request-&gt;query('ref')) {
          // Add a cookie to the response that lasts 5 years (in minutes)
          $response-&gt;cookie('referral', encrypt($request-&gt;query('ref')), 525600);
      }
  
      return $response;
  }
  </code></pre>
  <p>and here is my registration controller</p>
  <pre><code>protected function create(array $data)
  {
      $referred_by = Cookie::get('referral');
  
      $user = '';
  
      $data['password'] = Hash::make($data['password']);
  
      $user = User::create($data);
  
      Wallet::create([
          'user_id' =&gt; $user-&gt;id
      ]);
      Profile::create([
          'user_id' =&gt; $user-&gt;id,
          'referral' =&gt; Str::random(5)
      ]);
  
      if ($referred_by != null) {
          $encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
          $decryptedString = $encrypter-&gt;decrypt($referred_by);
          Referral::create([
              'user_id' =&gt; $user-&gt;id,
              'referred_by' =&gt;  $decryptedString
          ]);
      }
  
      Mail::to($user)-&gt;send(new NewUserEmail($user));
  
      return $user;
  }
  </code></pre>