aliqasemzadeh/fluxui-persian-date-picker
Installation:
composer require aliqasemzadeh/fluxui-persian-date-picker
No manual service provider registration needed (Laravel auto-discovers it).
Tailwind Configuration:
Update tailwind.config.js to include the package’s views:
content: [
'./vendor/aliqasemzadeh/fluxui-persian-date-picker/resources/views/**/*.blade.php',
// ... other paths
],
First Use Case: Drop the component in a Livewire blade view:
<x-persian-date-picker
label="تاریخ تولد"
wire:model="birthDate"
required
/>
Ensure your Livewire component has a public $birthDate property.
Livewire Integration:
wire:model for two-way binding (e.g., wire:model="eventDate").wire:model.live and wire:model.blur for real-time validation or delayed updates.Form Handling:
<form wire:submit.prevent="saveEvent">
<x-persian-date-picker
label="تاریخ رویداد"
wire:model="eventDate"
required
/>
<button type="submit">ذخیره</button>
</form>
In Livewire:
public $eventDate;
public function saveEvent() {
$this->validate(['eventDate' => 'required']);
// Convert to Gregorian if needed (e.g., using `jdate` package)
}
Dynamic Props:
<x-persian-date-picker
:label="$user->birthdayLabel"
wire:model="userBirthday"
/>
Alpine.js Extensions: Leverage Alpine.js for client-side logic (e.g., disable past dates):
<x-persian-date-picker
wire:model="expiryDate"
x-data="{ minDate: '1400/01/01' }"
x-init="$watch('wire:model', (value) => {
if (value < minDate) $wire.set('expiryDate', null);
})"
/>
Reusable Components: Create a wrapper component for consistency:
<!-- resources/views/components/persian-date.blade.php -->
<x-persian-date-picker
:label="$label"
wire:model="{{ $name }}"
:required="$required"
/>
Usage:
<x-persian-date label="تاریخ شروع" name="startDate" />
Date Format Mismatch:
Y/m/d format (e.g., 1400/05/10).Y-m-d), convert them before passing to the component:
// In Livewire
public function mount() {
$this->eventDate = \Jalali\Jalalian::fromGregorian($this->gregorianDate)->format('Y/m/d');
}
Tailwind Classes Stripped:
tailwind.config.js will strip custom Tailwind classes.npx tailwindcss -i input.css -o output.css --watch after updating config.Livewire Property Binding:
wire:model (case-sensitive).{{ dd($this->property) }} to verify data flow.Alpine.js Conflicts:
x-data or x-init conflicts with the component’s internals.Custom Validation: Add custom validation in Livewire:
protected $rules = [
'eventDate' => 'required|date_format:Y/m/d|after:1380/01/01',
];
Localization: Override labels dynamically:
<x-persian-date-picker
label="{{ __('custom.date_label') }}"
placeholder="{{ __('custom.placeholder') }}"
/>
Styling: Customize via Tailwind or publish the view:
php artisan vendor:publish --tag=persian-date-picker-views
Then modify resources/views/vendor/persian-date-picker/components/persian-date-picker.blade.php.
Performance: For large forms, lazy-load the component with Alpine.js:
<div x-data="{ showPicker: false }">
<button @click="showPicker = true">Select Date</button>
<x-persian-date-picker
x-show="showPicker"
wire:model="lazyDate"
@close="showPicker = false"
/>
</div>
Debugging:
Extension Points:
<x-persian-date-picker
:icon="$showIcon ? 'heroicon-o-calendar' : null"
/>
x-init="
$wire.on('persianDatePickerInit', (picker) => {
picker.minDate = '1400/01/01';
});
"
How can I help you explore Laravel packages today?