schema([ Forms\Components\TextInput::make('name')->label('Nome')->required(), Forms\Components\FileUpload::make('profile_picture') ->label('Foto de Perfil') ->avatar() ->directory('profile-pictures') ->visibility('private') ->required(), Forms\Components\Select::make('city_id') ->label('Cidade') ->relationship(name: 'city', titleAttribute: 'name') ->searchable() ->required(), Forms\Components\Select::make('type')->label('Tipo') ->options(BusinessType::class)->required(), Forms\Components\TextInput::make('price')->label('Preço'), Forms\Components\TextInput::make('price_calculation')->label('Calculador de Preço'), Forms\Components\TextInput::make('address')->label('Endereço'), Forms\Components\RichEditor::make('description') ->label('Descrição') ->columnSpan('full') ->required(), FilamentJsonColumn::make('details') ->label('Detalhes') ->columnSpan('full'), Forms\Components\FileUpload::make('images') ->columnSpan('full') ->label('Imagens') ->visibility('private') ->directory('business-images') ->reorderable() ->multiple(), // Geocomplete::make('full_address') // ->isLocation() // ->geocodeOnLoad() // ->updateLatLng(), Geocomplete::make('details.location') ->isLocation() ->geocodeOnLoad() ->updateLatLng() ->columnSpan('full'), Map::make('location') ->label("Localização do negócio") ->columnSpan('full') ->autocomplete('details.location') ->autocompleteReverse(true) ->reverseGeocode([ 'street' => '%n %S', 'city' => '%L', 'state' => '%A1', 'zip' => '%z', ]), Forms\Components\Toggle::make('is_approved')->label('Aprovado') ->hidden(fn() => auth()->user()->type !== UserType::SuperUser->value), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name')->label('Nome'), ]) ->filters([ Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\RestoreBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ RelationManagers\PlaceRelationManager::class, BusinessRelationManager::class, RelationManagers\RelatedBusinessRelationManager::class, RelationManagers\TagsRelationManager::class, RelationManagers\ProductsRelationManager::class ]; } public static function getPages(): array { return [ 'index' => Pages\ListBusinesses::route('/'), 'create' => Pages\CreateBusiness::route('/create'), 'edit' => Pages\EditBusiness::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { $query = parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); if (!auth()->user()->isSuperUser()) { $query->where('owner_id', auth()->id()); } return $query; } }