colorful
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Feedback\Schemas;
|
||||
|
||||
use App\Models\CustomerProduct;
|
||||
use App\Models\Department;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -23,7 +24,6 @@ class FeedbackForm
|
||||
Select::make('customer_id')
|
||||
->relationship('customer', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->live(),
|
||||
|
||||
@@ -34,20 +34,26 @@ class FeedbackForm
|
||||
|
||||
Select::make('customer_product_id')
|
||||
->label('Product')
|
||||
->options(function ($get): array {
|
||||
->searchable()
|
||||
->getSearchResultsUsing(function (string $search, $get): array {
|
||||
$customerId = $get('customer_id');
|
||||
if (! $customerId) {
|
||||
return [];
|
||||
}
|
||||
$keyword = mb_strtolower($search);
|
||||
return CustomerProduct::where('customer_id', $customerId)
|
||||
->whereHas('product', fn ($q) => $q->whereRaw('LOWER(name) LIKE ?', ["%{$keyword}%"]))
|
||||
->with('product')
|
||||
->limit(50)
|
||||
->get()
|
||||
->pluck('product.name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->getOptionLabelUsing(fn ($value): ?string =>
|
||||
CustomerProduct::find($value)?->product?->name
|
||||
)
|
||||
->visible(fn ($get): bool => ! $get('is_general'))
|
||||
->nullable()
|
||||
->searchable()
|
||||
->live(),
|
||||
|
||||
Select::make('contract_id')
|
||||
@@ -135,7 +141,7 @@ class FeedbackForm
|
||||
->createOptionForm([
|
||||
TextInput::make('name')->required(),
|
||||
TextInput::make('slug')->required(),
|
||||
TextInput::make('color')->type('color'),
|
||||
ColorPicker::make('color')->default('#3b82f6'),
|
||||
]),
|
||||
|
||||
Select::make('status')
|
||||
@@ -151,7 +157,6 @@ class FeedbackForm
|
||||
Select::make('assigned_to')
|
||||
->relationship('assignedTo', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->nullable(),
|
||||
|
||||
Select::make('current_department_id')
|
||||
|
||||
@@ -39,7 +39,13 @@ class FeedbackTable
|
||||
->placeholder('-')
|
||||
->toggleable(),
|
||||
TextColumn::make('feedbackChannel.name')
|
||||
->label('Channel'),
|
||||
->label('Channel')
|
||||
->formatStateUsing(fn ($state, $record) => sprintf(
|
||||
'<span style="display:inline-block;background:%s;color:#fff;padding:2px 10px;border-radius:9999px;font-size:0.75rem;">%s</span>',
|
||||
$record->feedbackChannel?->color ?: '#6b7280',
|
||||
e($state)
|
||||
))
|
||||
->html(),
|
||||
TextColumn::make('tags.name')
|
||||
->badge()
|
||||
->separator(','),
|
||||
|
||||
Reference in New Issue
Block a user