Installation:
composer require allyoullneed/advanced-controls
Ensure your project uses Laravel 10+ and Livewire 4 (verified compatibility in changelog).
First Use Case:
Replace a basic Blade <select> with the package’s enhanced <x-select> in a Livewire component:
<x-select wire:model="user.role" :options="$roles" placeholder="Choose a role" />
wire:model for Livewire reactivity.:options for dynamic data binding.filter (v1.1.0+) for searchable dropdowns:
<x-select wire:model="search" :options="$users" filter placeholder="Search users..." />
Where to Look First:
Tab, Avatar, Chart, MenuItem).wire:model support (e.g., Select, Tab, form fields).Livewire-Driven Components:
wire:model for components like Select, Checkbox, or Tab:
<x-tab wire:model="activeTab" :tabs="$tabs" />
<x-select :options="$dynamicOptions" wire:model="selectedOption" />
Form Integration:
<x-input wire:model="form.name" label="Name" />
<!-- Error state managed automatically -->
Nested Components:
MenuItem for hierarchical navigation:
<x-menu>
<x-menuItem title="Dashboard" href="/dashboard" />
<x-menuItem title="Settings">
<x-slot name="submenu">
<x-menuItem title="Profile" href="/profile" />
</x-slot>
</x-menuItem>
</x-menu>
Charts:
// config/advanced-controls.php
'charts' => [
'cdn' => 'https://cdn.jsdelivr.net/npm/chart.js',
],
<x-chart type="line" :data="$chartData" class="h-64" />
Tables of Contents (ToC):
<x-toc> for dynamic navigation:
<x-toc selector="h2,h3" class="bg-gray-100 p-4" />
Component Replacement Workflow:
<x-Component> tags, migrate props to attributes.- <div x-data="{ activeTab: 'home' }">
- <button @click="activeTab = 'home'">Home</button>
- </div>
+ <x-tab wire:model="activeTab" :tabs="['home', 'profile']" />
Livewire Component Pairing:
// app/Http/Livewire/UserSettings.php
public $role;
public $roles = ['admin', 'editor', 'user'];
protected $rules = ['role' => 'required'];
<x-select wire:model="role" :options="$roles" />
Theming:
class attribute:
<x-select class="bg-white border-gray-300" />
Statamic Projects:
<x-avatar :user="$entry->author()" size="md" />
$entry data for dynamic options:
<x-select :options="$entry->categories()->pluck('title', 'id')" />
Asset Pipeline:
Testing:
Livewire::test() to validate component interactions:
public function test_select_component()
{
Livewire::test(SelectComponent::class)
->set('value', 'option2')
->assertSet('value', 'option2');
}
@test directives.Fallbacks:
@if checks for unsupported environments:
@if (class_exists(\Allyoullneed\AdvancedControls\Select::class))
<x-select wire:model="value" :options="$options" />
@else
<select wire:model="value">
@foreach($options as $key => $value)
<option value="{{ $key }}">{{ $value }}</option>
@endforeach
</select>
@endif
Livewire Version Mismatch:
^4.0 in composer.json:
"require": {
"livewire/livewire": "^4.0"
}
Statamic-Specific Assumptions:
$entry data). Test in vanilla Laravel.Chart Loading:
@if(config('advanced-controls.charts.cdn'))
<x-chart type="line" :data="$data" />
@else
<div class="text-gray-500">Charts unavailable (CDN blocked)</div>
@endif
Accessibility (a11y):
Select fixes in v1.1.4). Screen reader testing recommended.<x-select aria-label="User role selection" wire:model="role" :options="$roles" />
Component Registration:
AdvancedControlsServiceProvider is loaded in config/app.php.Dynamic Options:
Select components may not update options reactively if :options is static.// Livewire class
public $options = [];
public function mount() {
$this->options = User::pluck('name', 'id');
}
<x-select wire:model="userId" :options="$options" />
Livewire Wire:Model Issues:
wire:model (e.g., wire:model="user.role" vs. wire:model="userrole").public $role;).{{ dd($this->role) }} in the Livewire class to inspect values.Component Not Rendering:
<x-select> instead of the component).How can I help you explore Laravel packages today?