### Install Filament Quick Create Source: https://github.com/awcodes/filament-quick-create/blob/5.x/README.md Install the package using Composer. This is the initial step for integrating the plugin into your Filament project. ```bash composer require awcodes/filament-quick-create ``` -------------------------------- ### Hide Quick Create Until User Completes Setup Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/usage-examples.md Make the Quick Create dropdown visible only after a user has completed their setup process. ```php QuickCreatePlugin::make() ->hidden(fn () => ! auth()->user()->hasCompletedSetup()) ``` -------------------------------- ### Customized Translation Example Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md An example of a customized translation file for the Quick Create plugin, showing how to change the button label. ```php return [ 'button_label' => 'Create New', ]; ``` -------------------------------- ### QuickCreatePlugin Return Type Example Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/README.md Demonstrates that most configuration methods on the QuickCreatePlugin return the plugin instance itself, enabling method chaining for fluent configuration. ```php QuickCreatePlugin::make() ->includes([...]) // returns QuickCreatePlugin ->label('New') // returns QuickCreatePlugin ->keyBindings([...]) // returns QuickCreatePlugin ``` -------------------------------- ### Complete Quick Create Plugin Configuration Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md A comprehensive example demonstrating various configuration options for the Quick Create plugin, including resource filtering, display settings, sorting, form display, modal customization, keyboard shortcuts, and visibility. ```php use Awcodes\QuickCreate\QuickCreatePlugin; use Filament\View\PanelsRenderHook; QuickCreatePlugin::make() // Resource filtering ->includes([ UserResource::class, AuthorResource::class, ]) // Display ->rounded() ->label('New') ->hiddenIcons(false) ->tooltip('Quick create (Cmd+Shift+A)') // Sorting ->sort(true) ->sortBy('label') // Form display ->slideOver() ->alwaysShowModal(false) ->createAnother(null) // Use resource default // Modal customization ->modalWidths('2xl') ->modalHeading('Create New :label') ->modalDescription('Fill in the details to create a new :label') ->modalExtraAttributes([ 'data-testid' => 'quick-create-modal', ]) // Keyboard shortcuts ->keyBindings(['cmd+shift+a', 'ctrl+shift+a']) // Visibility ->hidden(false) ->renderUsingHook(PanelsRenderHook::USER_MENU_BEFORE) ``` -------------------------------- ### Dynamically Set Key Bindings Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/README.md Configure keyboard shortcuts for the quick create feature dynamically based on user privileges. This example sets different shortcuts for admin users. ```php ->keyBindings(fn () => auth()->user()->isAdmin() ? ['cmd+shift+a'] : null) ``` -------------------------------- ### Register QuickCreatePlugin with Filament Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-service-provider.md Example of registering the QuickCreatePlugin within a Filament panel provider. ```php use Awcodes\QuickCreate\QuickCreatePlugin; // In your AdminPanelProvider or similar public function panel(Panel $panel): Panel { return $panel ->plugins([ QuickCreatePlugin::make(), ]) // ... other configuration ; } ``` -------------------------------- ### Rendering Livewire Component in View Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/architecture.md Example of how to render the QuickCreateMenu Livewire component in a Blade view. ```php // In view: @livewire('quick-create-menu') ``` -------------------------------- ### Icon Type Examples Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/types-and-constants.md Examples of Heroicon class names used for icons, including outline and solid styles. ```php 'heroicon-o-user' 'heroicon-o-plus' 'heroicon-o-star' 'heroicon-s-pencil' ``` -------------------------------- ### Closure Evaluation Example Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/architecture.md Demonstrates how configuration properties can be dynamic closures and how the `evaluate()` method is used to resolve their values. ```php protected bool|Closure $hidden = false; // Store either: $this->hidden = true; // Static boolean $this->hidden = fn() => auth()->admin(); // Dynamic closure ``` ```php public function shouldBeHidden(): bool { return $this->evaluate($this->hidden) ?? false; } ``` -------------------------------- ### QuickCreateMenu bootedInteractsWithActions() Method Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-menu-component.md Finalizes action setup after Livewire initializes the component. It caches actions and validates their types, ensuring they are instances of Action or ActionGroup. ```php public function bootedInteractsWithActions(): void ``` -------------------------------- ### QuickCreateMenu getActions() Method Example Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-menu-component.md Illustrates how the getActions() method generates a collection of CreateAction instances for each resource. This method is typically understood conceptually rather than called directly in user code. ```php // Typically not called directly in user code, but understood as: $actions = $component->getActions(); // Returns: Collection of CreateAction objects ready to mount in Livewire ``` -------------------------------- ### Accessing Translations Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-service-provider.md Example of how to access package translations using the __() helper function. ```php __('quick-create::quick-create.button_label') ``` -------------------------------- ### Dynamic Configuration Closures Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/types-and-constants.md Examples of closures used for dynamic boolean, string, nullable string, array, and nullable array configurations. ```php // Boolean configuration fn (): bool => auth()->user()->isAdmin() ``` ```php // String configuration fn (): string => auth()->user()->locale === 'es' ? 'Crear' : 'New' ``` ```php // Nullable string fn (): ?string => auth()->user()->theme === 'dark' ? 'dark' : null ``` ```php // Array configuration fn (): array => ['cmd+shift+a', 'ctrl+shift+a'] ``` ```php // Nullable array fn (): ?array => auth()->user()->powerUser ? ['cmd+shift+a'] : null ``` -------------------------------- ### Conditionally Hide Quick Create Source: https://github.com/awcodes/filament-quick-create/blob/5.x/README.md Hide the Quick Create button based on a condition. The example shows hiding it if the tenant requires onboarding. ```php use Awcodes\QuickCreate\QuickCreatePlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ QuickCreatePlugin::make() ->hidden(fn() => Filament::getTenant()->requiresOnboarding()), ]) } ``` -------------------------------- ### Get Registered QuickCreatePlugin Instance Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Retrieve the plugin instance from the Filament container for the current panel. Useful for accessing plugin configurations after it has been registered. ```php $plugin = QuickCreatePlugin::get(); $resources = $plugin->getResources(); ``` -------------------------------- ### Get Filtered Resources Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Builds and returns the filtered list of resources available for quick creation, applying authorization checks and filters. Returns an array with resource metadata. ```php public function getResources(): array ``` ```php $plugin = QuickCreatePlugin::get(); $resources = $plugin->getResources(); // Example output: // [ // [ // 'resource_name' => 'App\Filament\Resources\UserResource', // 'label' => 'User', // 'model' => 'App\Models\User', // 'icon' => 'heroicon-o-user', // 'action_name' => 'create_user', // 'action' => "mountAction('create_user')", // 'url' => null, // 'navigation' => 0, // ], // // ... more resources // ] ``` -------------------------------- ### Dynamically Hide Quick Create Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/README.md Conditionally hide the quick create button based on runtime logic, such as user roles. This example hides it for non-admin users. ```php ->hidden(fn () => !auth()->admin()) ``` -------------------------------- ### Method Chaining in Quick Create Plugin Configuration Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md Illustrates how to chain configuration methods in the Quick Create plugin, as all methods return the plugin instance. ```php QuickCreatePlugin::make() ->includes([UserResource::class]) ->label('New') ->keyBindings('cmd+shift+a') ->slideOver() ``` -------------------------------- ### getId Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Gets the unique identifier for this plugin instance. ```APIDOC ## getId() ### Description Get the unique identifier for this plugin. ### Method `getId(): string` ### Parameters None ### Request Example None provided. ### Response #### Success Response (200) * **string** - Always returns 'quick-create'. #### Response Example None provided. ``` -------------------------------- ### Configure Quick Create Plugin Options Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/README.md Set various options for the Quick Create plugin, such as included/excluded resources, sorting, labels, keyboard shortcuts, and modal behavior. Use this in your Filament service provider's boot method. ```php QuickCreatePlugin::make() ->includes([UserResource::class]) // Show only these resources ->excludes([AdminResource::class]) // Hide these resources ->sortBy('label') // Sort alphabetically or by navigation ->label('New') // Custom button label ->rounded() // Button border radius ->keyBindings(['cmd+shift+a']) // Keyboard shortcuts ->alwaysShowModal() // Force modals for all resources ->slideOver() // Use slide-over instead of modal ->hidden(fn () => !auth()->admin()) // Conditional visibility ``` -------------------------------- ### Get Plugin ID Method Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/INDEX.md Method to retrieve the unique identifier for the plugin. ```php getId() ``` -------------------------------- ### QuickCreateMenu mount() Method Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-menu-component.md Initializes the QuickCreateMenu component by populating its properties from the QuickCreatePlugin configuration. This method is called automatically during component mounting. ```php public function mount(): void ``` -------------------------------- ### Get Current Sort Field Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Retrieves the current sort field, which can be 'label' or 'navigation'. ```php public function getSortField(): string ``` -------------------------------- ### Create New QuickCreatePlugin Instance Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Use the factory method to create a new instance of the plugin. This is the recommended way to instantiate the plugin. ```php use Awcodes\QuickCreate\QuickCreatePlugin; $plugin = QuickCreatePlugin::make(); ``` -------------------------------- ### Get Actions for Livewire Component Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/INDEX.md Retrieves the collection of CreateActions available in the Livewire component. ```php QuickCreateMenu::getActions() ``` -------------------------------- ### Initialize and Render Quick Create Menu Component Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/README.md Instantiate the QuickCreateMenu Livewire component, retrieve its actions, and render the associated Blade template. This is typically handled by Filament's Livewire rendering process. ```php $component = new QuickCreateMenu(); $component->mount() // Initialize component $component->getActions() // Get CreateAction collection $component->render() // Render Blade template $component->toggleDropdown() // Toggle dropdown visibility ``` -------------------------------- ### CreateAction Initialization Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/types-and-constants.md Demonstrates how to initialize a CreateAction with a name. ```php use Filament\Actions\CreateAction; CreateAction::make($name) ``` -------------------------------- ### HasActions Interface Contract Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/types-and-constants.md Defines methods for components that manage actions, including getting actions and mounting/calling them. ```php use Filament\Actions\Contracts\HasActions; interface HasActions { public function getActions(): Collection; public function mountAction($name, $arguments = []): void; public function callAction($name, $arguments = []): mixed; // ... other methods } ``` -------------------------------- ### Conditional Quick Create Plugin Configuration Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md Demonstrates how to conditionally configure Quick Create plugin options using Closures based on user roles, locale, or device type. ```php QuickCreatePlugin::make() // Only show for admins ->hidden(fn () => ! auth()->user()->isAdmin()) // Different label per user ->label(fn () => auth()->user()->locale === 'es' ? 'Crear' : 'New') // Enable key bindings for power users ->keyBindings(fn () => auth()->user()->powerUser ? ['cmd+shift+a', 'ctrl+shift+a'] : null ) // Conditional slide-over for mobile ->slideOver(fn () => request()->header('User-Agent') =~ /Mobile/) // Use different modals on smaller screens ->modalWidths(fn () => request()->header('User-Agent') =~ /Mobile/ ? 'full' : 'lg' ) ``` -------------------------------- ### Configure Resource Inclusion Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md Specify which resources should be available in the Quick Create dropdown. Use either `includes` or `excludes`, but not both. `includes` takes precedence. ```php ->includes([ App\Filament\Resources\UserResource::class, App\Filament\Resources\RoleResource::class, ]) ``` ```php ->excludes([ App\Filament\Resources\TeamResource::class, ]) ``` -------------------------------- ### Configure Keybindings for Quick Create Source: https://github.com/awcodes/filament-quick-create/blob/5.x/README.md Assign keyboard shortcuts to trigger the Quick Create dropdown. This allows for faster access to the creation menu via keyboard commands. ```php use Awcodes\QuickCreate\QuickCreatePlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ QuickCreatePlugin::make() ->keyBindings(['command+shift+a', 'ctrl+shift+a']), ]) } ``` -------------------------------- ### Generating Resource Metadata Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/architecture.md Example of how the resource metadata array is generated programmatically, extracting details from a resource instance. ```php $resource = app($resourceName); [ 'resource_name' => $resourceName, 'label' => Str::ucfirst($resource->getModelLabel()), 'model' => $resource->getModel(), 'icon' => $resource->getNavigationIcon(), 'action_name' => 'create_' . Str::of($resource->getModel())->replace('\\', '')->snake(), 'action' => $shouldUseModal ? "mountAction('$actionName')" : null, 'url' => $shouldUseModal ? null : $resource::getUrl('create'), 'navigation' => $resource->getNavigationSort(), ] ``` -------------------------------- ### getSortField() Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/quick-create-plugin.md Get the current sort field being used by the plugin. This will be either 'label' for alphabetical sorting or 'navigation' for sort order. ```APIDOC ## getSortField() ### Description Get the current sort field ('label' or 'navigation'). ### Returns `string` — The current sort field ### Example ```php $sortField = $plugin->getSortField(); ``` ``` -------------------------------- ### Multi-Tenant Configuration for Quick Create Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/usage-examples.md Configure Quick Create to be hidden when no tenant is selected in a multi-tenant application. Resources will be automatically scoped to the current tenant. ```php QuickCreatePlugin::make() ->hidden(fn () => ! Filament::getTenant()) ``` -------------------------------- ### QuickCreatePlugin API Reference Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/MANIFEST.md This section details the QuickCreatePlugin class, including its static and instance methods for configuring resource filtering, sorting, display, modal behavior, and more. ```APIDOC ## QuickCreatePlugin API Reference ### Description Provides a complete reference for the QuickCreatePlugin class, covering its static and instance methods for customizing the quick creation functionality. ### Class Methods - **make()**: Static method to instantiate the plugin. - **get()**: Static method to retrieve an instance of the plugin. ### Instance Methods - **Resource Filtering**: - `excludes(array $resources)`: Excludes specified resources. - `includes(array $resources)`: Includes only specified resources. - `getResources()`: Retrieves the list of resources to be displayed. - **Sorting**: - `sort(array $sorts)`: Sets custom sorting options. - `sortBy(string $column, string $direction = 'asc')`: Sets a default sort column and direction. - `isSortable(bool $sortable)`: Enables or disables sorting. - **Display**: - `rounded()`: Applies rounded styling. - `label(string $label)`: Sets a custom label. - `hiddenIcons()`: Hides icons. - `tooltip(string $tooltip)`: Sets a tooltip. - **Modal/Form Configuration**: - `alwaysShowModal()`: Configures the modal to always be shown. - `slideOver()`: Configures the modal to be a slide-over. - `modalWidths(string $width)`: Sets the modal width. - `etc()`: (Placeholder for other modal/form related methods) - **Create Another**: - `createAnother()`: Enables the 'Create Another' functionality. - `canCreateAnother(bool $condition)`: Controls the ability to create another record. - **Keyboard Shortcuts**: - `keyBindings(array $bindings)`: Defines custom keyboard bindings. - `getKeyBindings()`: Retrieves the defined keyboard bindings. - **Visibility**: - `hidden(bool $condition)`: Hides the plugin based on a condition. - `shouldBeHidden()`: Determines if the plugin should be hidden. - **Rendering**: - `renderUsingHook(string $hookName)`: Renders using a specific hook. - `getRenderHook()`: Retrieves the render hook configuration. - **Helper**: - `getId()`: Retrieves the unique identifier for the plugin. ### Parameters Parameters vary per method. Refer to individual method documentation for details on types, requirements, and descriptions. ``` -------------------------------- ### Configure Keyboard Shortcuts Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/configuration.md Define keyboard shortcuts to toggle the Quick Create dropdown. Accepts a single string or an array of strings. Defaults to `null`. ```php ->keyBindings('cmd+shift+a') ``` ```php ->keyBindings(['cmd+shift+a', 'ctrl+shift+a']) ``` ```php ->keyBindings(fn () => auth()->user()->isAdmin() ? ['cmd+shift+a'] : null) ``` -------------------------------- ### Render Resources in Slide Over Source: https://github.com/awcodes/filament-quick-create/blob/5.x/README.md Configure Quick Create to render simple resources in a slide-over panel instead of a standard modal. Use the `slideOver()` modifier for this behavior. ```php use Awcodes\QuickCreate\QuickCreatePlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ QuickCreatePlugin::make() ->slideOver(), ]) } ``` -------------------------------- ### HasForms Interface Contract Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/types-and-constants.md Defines methods for components that manage forms, including getting the form schema, form instance, and form actions. ```php use Filament\Forms\Contracts\HasForms; interface HasForms { public function getFormSchema($formStatePath = 'data'): array; public function getForm($formStatePath = 'data'): Form; public function getFormActions($formStatePath = 'data'): array; // ... other methods } ``` -------------------------------- ### Create with Default Settings Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/usage-examples.md Use the plugin with its default behavior, displaying all creatable resources sorted alphabetically and using modals for resources without create pages. ```php use Awcodes\QuickCreate\QuickCreatePlugin; QuickCreatePlugin::make() ``` -------------------------------- ### Hide Quick Create During Onboarding Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/usage-examples.md Control the visibility of the Quick Create dropdown based on tenant onboarding status. ```php use Filament\Facades\Filament; QuickCreatePlugin::make() ->hidden(fn () => Filament::getTenant()?->requiresOnboarding()) ``` -------------------------------- ### QuickCreateMenuComponent Reference Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/MANIFEST.md This section covers the QuickCreateMenu Livewire component, detailing its public properties, lifecycle methods, and primary methods for action retrieval and rendering. ```APIDOC ## QuickCreateMenuComponent Reference ### Description Reference for the QuickCreateMenu Livewire component, including its public properties, lifecycle methods, and core functionalities for managing actions and rendering. ### Public Properties - (Details on public properties would be listed here if available in source) ### Lifecycle Methods - **mount()**: Initializes the component. - **bootedInteractsWithActions()**: Handles interactions related to actions after booting. ### Primary Methods - **getActions()**: Retrieves the available actions for the component. - **render()**: Renders the component's view. - **toggleDropdown()**: Toggles the visibility of the dropdown menu. ### Protected Methods - **cacheActions()**: Caches the actions for performance. ### Other Details - Explains the record creation flow. - Details JavaScript integration, form integration, and configuration properties. - Covers view rendering details. ``` -------------------------------- ### Adding Custom CSS Classes to Buttons Source: https://github.com/awcodes/filament-quick-create/blob/5.x/_autodocs/blade-template.md Shows how to add custom CSS classes to a button element for styling. This example adds 'shadow-lg' and 'border-2 border-primary-500' classes. ```blade {{-- Original button --}}