feat(barang): menambahakan kondisi untuk audit dan button, leader tidak bisa audit

This commit is contained in:
Yoga Pangestu 2025-11-14 09:03:43 +07:00
parent b629dee366
commit 878644c30d
4 changed files with 38 additions and 19 deletions

View File

@ -90,13 +90,18 @@ public function columns(): array
)
->outputFormat(function ($index, $value) {
$route = route('studio.catalog.bottle.audit', [$value['id'], $value['bottle_id']]);
$canAudit = auth()->user()->can('audit bottle');
return Blade::render('
<a href="{{ $route }}" wire:navigate
class="flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition">
<span class="font-medium text-gray-700">{{ $value["name"] }}</span>
<span class="text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5">{{ $value["stock"] }}</span>
</a>', [
$tag = $canAudit ? 'div' : 'a';
$attrs = $canAudit ? '' : 'href="'.$route.'" wire:navigate';
return Blade::render("
<{$tag} {$attrs}
class='flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition'>
<span class='font-medium text-gray-700'>{{ \$value['name'] }}</span>
<span class='text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5'>{{ \$value['stock'] }}</span>
</{$tag}>
", [
'value' => $value,
'route' => $route,
]);

View File

@ -93,13 +93,18 @@ public function columns(): array
)
->outputFormat(function ($index, $value) {
$route = route('studio.catalog.perfume.audit', [$value['id'], $value['perfume_id']]);
$canAudit = auth()->user()->can('audit perfume');
return Blade::render('
<a href="{{ $route }}" wire:navigate
class="flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition">
<span class="font-medium text-gray-700">{{ $value["name"] }}</span>
<span class="text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5">{{ $value["stock"] }}</span>
</a>', [
$tag = $canAudit ? 'div' : 'a';
$attrs = $canAudit ? '' : 'href="'.$route.'" wire:navigate';
return Blade::render("
<{$tag} {$attrs}
class='flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition'>
<span class='font-medium text-gray-700'>{{ \$value['name'] }}</span>
<span class='text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5'>{{ \$value['stock'] }}</span>
</{$tag}>
", [
'value' => $value,
'route' => $route,
]);
@ -126,7 +131,8 @@ class="flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg
return $actions;
})
->html(),
->html()
->hideIf(auth()->user()->cannot('update perfume', 'delete perfume')),
];
}

View File

@ -82,13 +82,18 @@ public function columns(): array
)
->outputFormat(function ($index, $value) {
$route = route('studio.catalog.product.audit', [$value['id'], $value['product_id']]);
$canAudit = auth()->user()->can('audit product');
return Blade::render('
<a href="{{ $route }}" wire:navigate
class="flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition">
<span class="font-medium text-gray-700">{{ $value["name"] }}</span>
<span class="text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5">{{ $value["stock"] }}</span>
</a>', [
$tag = $canAudit ? 'div' : 'a';
$attrs = $canAudit ? '' : 'href="'.$route.'" wire:navigate';
return Blade::render("
<{$tag} {$attrs}
class='flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs hover:bg-gray-100 transition'>
<span class='font-medium text-gray-700'>{{ \$value['name'] }}</span>
<span class='text-[10px] text-white bg-emerald-500 rounded px-1.5 py-0.5'>{{ \$value['stock'] }}</span>
</{$tag}>
", [
'value' => $value,
'route' => $route,
]);

View File

@ -215,14 +215,17 @@ public function run(): void
'create perfume',
'update perfume',
'delete perfume',
'audit perfume',
'create product',
'update product',
'delete product',
'audit product',
'create bottle',
'update bottle',
'delete bottle',
'audit bottle',
'view payroll',
'manage adjustment',