title: Laravel - generate unique order number
body: <p>I'm currently trying to generate a unique order number when the user reaches the create method. The order numbers are generated like this in the seed and need to look like this as well</p>
  
  <p><strong>Seed</strong></p>
  
  <pre><code>foreach(range(1,25) as $index)
      {
          DB::table('orders')-&gt;insert([
  
              'user_id' =&gt; rand(1,25),
              'order_nr' =&gt; '#' . sprintf("%08d", $index),
              'price_sum' =&gt; $faker-&gt;randomNumber($nbDigits = 4, $strict = false) . '.' . $faker-&gt;randomNumber($nbDigits = 2, $strict = false),
              'status' =&gt; $faker-&gt;randomElement(['paid', 'pending', 'failed']),
              'created_at' =&gt; Carbon::now(),
              'updated_at' =&gt; Carbon::now(),
  
          ]);
      }
  </code></pre>
  
  <p>The order numbers look like this <code>#00000001</code> or <code>#00000002</code>. Now when the user reaches the create method in my controller a new unique order number in this sequence needs to be created. How can I achieve that? The controller currently looks like this:</p>
  
  <pre><code> public function create()
  {
      $order = new Order;
  
      $order-&gt;user_id = Auth()-&gt;id();
      $order-&gt;order_nr = 
  
  
      dd($order);
  
  
      return view('steps.order');
  }
  </code></pre>
  
  <p>It needs to check the latest order number and create one with +1 on that order number. Say for instance there are 25 orders and the last one is #00000025 the one that needs to be created next needs to be #00000026. How can I achieve that?</p>