components([ Section::make('Feedback Information') ->schema([ Select::make('customer_id') ->relationship('customer', 'name') ->searchable() ->preload() ->required() ->live(), Toggle::make('is_general') ->label('General feedback (not related to a product)') ->default(false) ->live(), Select::make('customer_product_id') ->label('Product') ->options(function ($get): array { $customerId = $get('customer_id'); if (! $customerId) { return []; } return CustomerProduct::where('customer_id', $customerId) ->with('product') ->get() ->pluck('product.name', 'id') ->toArray(); }) ->visible(fn ($get): bool => ! $get('is_general')) ->nullable() ->searchable(), Select::make('feedback_channel_id') ->relationship('feedbackChannel', 'name') ->required() ->preload(), TextInput::make('title') ->required() ->maxLength(255), Textarea::make('content') ->required() ->rows(6) ->columnSpanFull(), Select::make('attachment_collection') ->label('Attachment Collection') ->options([ 'general' => 'General', 'proof_of_resolution' => 'Proof of Resolution', 'customer_evidence' => 'Customer Evidence', ]) ->default('general'), FileUpload::make('attachments') ->label('Attachments') ->multiple() ->disk('local') ->directory('feedback-attachments') ->columnSpanFull() ->dehydrated(false), Select::make('tags') ->relationship('tags', 'name') ->multiple() ->preload() ->createOptionForm([ TextInput::make('name')->required(), TextInput::make('slug')->required(), TextInput::make('color')->type('color'), ]), Select::make('status') ->options([ 'pending' => 'Pending', 'processing' => 'Processing', 'resolved' => 'Resolved', 'closed' => 'Closed', ]) ->default('pending') ->required(), Select::make('assigned_to') ->relationship('assignedTo', 'name') ->searchable() ->preload() ->nullable(), Select::make('current_department_id') ->label('Department') ->options(Department::pluck('name', 'id')->toArray()) ->searchable() ->nullable(), Toggle::make('is_escalated') ->label('Escalated') ->visible(fn (): bool => auth()->user()?->hasRole(['admin', 'manager']) ?? false), ]) ->columns(2), ]); } }