feat: Implement product and product category management with dedicated CRUD operations, services, and repositories.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class AdminBadge extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public $variant;
|
||||
public $icon;
|
||||
public $class;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @param string $variant
|
||||
* @param string $icon
|
||||
*/
|
||||
public function __construct($variant = 'info', $icon = 'circle')
|
||||
{
|
||||
$this->variant = $variant;
|
||||
|
||||
$styles = [
|
||||
'success' => 'bg-success-subtle text-success border border-success-subtle',
|
||||
'danger' => 'bg-danger-subtle text-danger border border-danger-subtle',
|
||||
'warning' => 'bg-warning-subtle text-warning border border-warning-subtle',
|
||||
'info' => 'bg-info-subtle text-info border border-info-subtle',
|
||||
'secondary' => 'bg-secondary-subtle text-secondary border border-secondary-subtle',
|
||||
];
|
||||
|
||||
// Status aliases
|
||||
$aliases = [
|
||||
1 => 'success',
|
||||
0 => 'danger',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
'active' => 'success',
|
||||
'inactive' => 'danger',
|
||||
'pending' => 'warning'
|
||||
];
|
||||
|
||||
// Resolve alias if exists
|
||||
$resolvedVariant = $aliases[$variant] ?? $variant;
|
||||
|
||||
// Auto-icon logic if default 'circle' is used and we have a specific mapping
|
||||
if ($icon === 'circle') {
|
||||
$iconMap = [
|
||||
'success' => 'check-circle',
|
||||
'danger' => 'x-circle',
|
||||
'warning' => 'alert-circle',
|
||||
'info' => 'info',
|
||||
];
|
||||
$this->icon = $iconMap[$resolvedVariant] ?? 'circle';
|
||||
} else {
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
$this->class = $styles[$resolvedVariant] ?? $styles['info'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.admin-badge');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user