diff --git a/app/Http/Controllers/SaleController.php b/app/Http/Controllers/SaleController.php new file mode 100644 index 0000000..4735389 --- /dev/null +++ b/app/Http/Controllers/SaleController.php @@ -0,0 +1,26 @@ +withCount(['items']); + + return inertia('Sale/Index', [ + 'query' => $query->paginate(), + ]); + } + + public function show(Sale $sale) + { + return inertia('Sale/Detail', [ + 'sale' => $sale->load(['items.voucher', 'customer.level']), + ]); + } +} diff --git a/app/Models/Sale.php b/app/Models/Sale.php index e4ef796..a6ffbb5 100644 --- a/app/Models/Sale.php +++ b/app/Models/Sale.php @@ -42,6 +42,11 @@ class Sale extends Model return $this->hasMany(SaleItem::class); } + public function customer() + { + return $this->belongsTo(Customer::class); + } + public function formatHumanCreatedAt(): Attribute { return Attribute::make(get: function () { diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 8b0d2de..49c1080 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -64,10 +64,10 @@ class PermissionSeeder extends Seeder ['id' => Str::ulid(), 'label' => 'View Coin', 'name' => 'view-coin'], ['id' => Str::ulid(), 'label' => 'Update Coin', 'name' => 'update-coin'], - ['id' => Str::ulid(), 'label' => 'Create Sale', 'name' => 'create-sale'], - ['id' => Str::ulid(), 'label' => 'Update Sale', 'name' => 'update-sale'], + // ['id' => Str::ulid(), 'label' => 'Create Sale', 'name' => 'create-sale'], + // ['id' => Str::ulid(), 'label' => 'Update Sale', 'name' => 'update-sale'], ['id' => Str::ulid(), 'label' => 'View Sale', 'name' => 'view-sale'], - ['id' => Str::ulid(), 'label' => 'Delete Sale', 'name' => 'delete-sale'], + // ['id' => Str::ulid(), 'label' => 'Delete Sale', 'name' => 'delete-sale'], ['id' => Str::ulid(), 'label' => 'Create Coin Reward', 'name' => 'create-coin-reward'], ['id' => Str::ulid(), 'label' => 'Update Coin Reward', 'name' => 'update-coin-reward'], diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js index 5f6792e..6561bd6 100644 --- a/resources/js/Layouts/Partials/routes.js +++ b/resources/js/Layouts/Partials/routes.js @@ -45,12 +45,12 @@ export default [ permission: 'view-voucher', }, { - name: 'Sale', //TODO + name: 'Sale', show: true, icon: HiCreditCard, - route: route('deposit.index'), - active: 'deposit.*', - permission: 'view-deposit', + route: route('sale.index'), + active: 'sale.*', + permission: 'view-sale', }, { name: 'Deposit', diff --git a/resources/js/Pages/Customer/Index.jsx b/resources/js/Pages/Customer/Index.jsx index 8348c15..180c621 100644 --- a/resources/js/Pages/Customer/Index.jsx +++ b/resources/js/Pages/Customer/Index.jsx @@ -111,7 +111,7 @@ export default function Customer(props) { scope="col" className="py-3 px-6" > - Referal Code + Referral Code
+ # + | ++ Customer + | ++ Tanggal + | ++ Voucher + | ++ Total + | ++ |
---|---|---|---|---|---|
+ {sale.code} + | ++ {sale.customer.name} + | ++ {sale.format_created_at} + | ++ {formatIDR( + sale.items_count + )} + | ++ {formatIDR(sale.amount)} + | +
+ router.get(
+ route(
+ 'sale.show',
+ sale
+ )
+ )
+ }
+ >
+ Lihat
+ |
+