PHP code example of tareq-alqadi / filament-flatpickr

1. Go to this page and download the library: Download tareq-alqadi/filament-flatpickr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tareq-alqadi / filament-flatpickr example snippets


use TareqAlqadi\FilamentFlatpickr\Forms\Components\DatePicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\DateRangePicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\DateTimePicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\MonthPicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\MultiDatePicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\TimePicker;
use TareqAlqadi\FilamentFlatpickr\Forms\Components\WeekPicker;

DatePicker::make('published_on');
DateTimePicker::make('starts_at');
TimePicker::make('opens_at');
DateRangePicker::make('period');
MultiDatePicker::make('holidays');
MonthPicker::make('billing_month');
WeekPicker::make('sprint_week');

DatePicker::make('date')
    ->minDate('today')
    ->maxDate(now()->addMonth())
    ->minDate(fn (Get $get) => $get('starts_on'));

->disabledDates(['2024-12-25', ['from' => '2024-12-30', 'to' => '2025-01-01']])
->enabledDates([...]) // only these days can be picked

TimePicker::make('opens_at')->minTime('09:00')->maxTime('17:00');
TimePicker::make('night_shift')->minTime('22:00')->maxTime('06:00'); // a span over midnight

DateRangePicker::make('period')
    ->clearable()        // an × in the field that clears it
    ->presets()          // quick picks beside the calendar: Last 7 days, This month, …
    ->footerActions();   // Today, Clear and Apply buttons under the calendar

->presets([
    ['label' => 'Launch day', 'date' => '2024-12-25'],
    ['label' => 'Next sprint', 'start' => now()->next('Monday'), 'end' => now()->next('Monday')->addDays(13)],
])

DatePicker::make('date')
    ->numberOfMonths(2)
    ->weekNumbers()
    ->firstDayOfWeek(1)   // Monday
    ->inline()            // always open, under the field
    ->static();           // opens under the field instead of over the page, for scrolling containers

BasePicker::configureUsing(fn (BasePicker $picker) => $picker->calendarDirection(null));

DatePicker::make('date')->options(['position' => 'above', 'closeOnSelect' => false]);
bash
php artisan vendor:publish --tag=tareq-alqadi-filament-flatpickr-translations