colorful
This commit is contained in:
@@ -21,12 +21,10 @@ class ContractForm
|
||||
Select::make('product_id')
|
||||
->relationship('product', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('customer_id')
|
||||
->relationship('customer', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('type')
|
||||
->options(ContractType::options())
|
||||
|
||||
@@ -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(','),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\FeedbackChannels\Schemas;
|
||||
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@@ -25,6 +26,8 @@ class FeedbackChannelForm
|
||||
TextInput::make('icon')
|
||||
->maxLength(255)
|
||||
->hint('Heroicon name or emoji'),
|
||||
ColorPicker::make('color')
|
||||
->label('Color'),
|
||||
Toggle::make('is_active')
|
||||
->default(true),
|
||||
])
|
||||
|
||||
@@ -17,9 +17,23 @@ class FeedbackChannelsTable
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
->sortable()
|
||||
->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->color ?: '#6b7280',
|
||||
e($state)
|
||||
))
|
||||
->html(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('color')
|
||||
->label('Color')
|
||||
->formatStateUsing(fn ($state) => sprintf(
|
||||
'<span style="display:inline-block;width:24px;height:24px;background:%s;border-radius:6px;border:1px solid #d1d5db;" title="%s"></span>',
|
||||
$state ?: '#6b7280',
|
||||
$state
|
||||
))
|
||||
->html(),
|
||||
IconColumn::make('is_active')
|
||||
->boolean()
|
||||
->label('Active'),
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\FeedbackTags\Schemas;
|
||||
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class FeedbackTagForm
|
||||
@@ -11,11 +13,19 @@ class FeedbackTagForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
TextInput::make('color'),
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('slug')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
ColorPicker::make('color')
|
||||
->label('Color')
|
||||
->default('#3b82f6'),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\FeedbackTags\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -15,19 +16,30 @@ class FeedbackTagsTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
->searchable()
|
||||
->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->color ?: '#6b7280',
|
||||
e($state)
|
||||
))
|
||||
->html(),
|
||||
TextColumn::make('slug')
|
||||
->searchable(),
|
||||
TextColumn::make('color')
|
||||
->searchable(),
|
||||
->label('Color')
|
||||
->formatStateUsing(fn ($state) => sprintf(
|
||||
'<span style="display:inline-block;width:24px;height:24px;background:%s;border-radius:6px;border:1px solid #d1d5db;" title="%s"></span>',
|
||||
$state ?: '#6b7280',
|
||||
$state
|
||||
))
|
||||
->html(),
|
||||
TextColumn::make('feedbacks_count')
|
||||
->counts('feedbacks')
|
||||
->label('Used'),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user