I'm trying to generate an invoice number, but I'm getting A non-numeric value encountered
.
I think I'm missing something but I'm not sure what it is.
Here is the invoiceNumber() code in my helpers.php
function invoiceNumber()
{
$orders = App\Order::all();
if($orders->isEmpty())
{
$invoice = 'arm0001';
return $invoice;
}
foreach($orders as $order)
{
$latest = App\Order::latest()->first();
if($latest->invoice_number == true)
{
$invoice = 'arm'.$latest->invoice_number+1;
return $invoice;
}
}
}
and this is where I'm trying to get it to be taken
public function deliveryConfirmation()
{
$menus_child = Menu::where('menu_id', 0)->with('menusP')->get();
$contacts = Contact::all();
if(!Session::has('cart'))
{
return view('public.shopping-cart', compact('menus_child', 'contacts'));
}
$oldCart = Session::get('cart');
$cart = new Cart($oldCart);
$invoice_number = invoiceNumber();
dd($invoice_number);
return view('public.delivery-confirmation', ['products' => $cart->items, 'totalPrice' => $cart->totalPrice, 'menus_child' => $menus_child, 'contacts' => $contacts, 'invoice_number' => $invoice_number]);
}
I would really like to keep the 'ARM' in the database as well