feat: Implement comprehensive product management, including categories, pricing, and integration into the order system.

This commit is contained in:
pbao9
2026-02-12 14:29:29 +07:00
parent 3b1beef66e
commit f3a679d7f3
25 changed files with 577 additions and 692 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Str;
use App\Models\Order;
class OrderHelper
{
/**
* Generate a unique order number with prefix.
*
* @param string $prefix
* @return string
*/
public static function generateOrderNumber(string $prefix = 'ORD'): string
{
do {
// Generate a random string of 8 uppercase characters/numbers
$random = strtoupper(Str::random(8));
$orderNum = $prefix . '-' . $random;
if ($prefix === 'INV') {
$exists = \App\Models\Invoice::where('order_num', $orderNum)->exists();
} else {
$exists = Order::where('order_num', $orderNum)->exists();
}
} while ($exists);
return $orderNum;
}
}