PHP code example of sghazanfari / filament-persian
1. Go to this page and download the library: Download sghazanfari/filament-persian 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/ */
sghazanfari / filament-persian example snippets
use Sghazanfari\FilamentPersian\FilamentPersianPlugin;
use Sghazanfari\FilamentPersian\Auth\Login;
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login(Login::class)
->plugin(FilamentPersianPlugin::make())
->font('Vazirmatn', ...)
// ...
}
use Sghazanfari\FilamentPersian\Forms\Components\JalaliDatePicker;
use Sghazanfari\FilamentPersian\Forms\Components\IranianMobileInput;
use Sghazanfari\FilamentPersian\Forms\Components\PersianNumberInput;
JalaliDatePicker::make('delivery_date')
->label('تاریخ تحویل')
->withTime(),
IranianMobileInput::make('customer_mobile')
->label('موبایل مشتری'),
PersianNumberInput::make('total')
->label('مبلغ کل')
->money('IRT'),
use Sghazanfari\FilamentPersian\Tables\Columns\JalaliDateColumn;
use Sghazanfari\FilamentPersian\Tables\Columns\PersianMoneyColumn;
use Sghazanfari\FilamentPersian\Concerns\AutoJalaliDates;
class OrderResource extends Resource
{
use AutoJalaliDates;
public static function table(Table $table): Table
{
return static::autoJalaliDates(
$table->columns([
PersianTextColumn::make('order_number')->label('شماره'),
PersianMoneyColumn::make('total')->label('مبلغ')->currency('IRT'),
])
);
}
}
use Sghazanfari\FilamentPersian\Widgets\PersianStatsWidget;
class DashboardStats extends PersianStatsWidget
{
protected function getStats(): array
{
return [
$this->makeNumberStat('کاربران', User::count()),
$this->makeMoneyStat('درآمد', Order::sum('total')),
$this->makeDateStat('امروز', now(), 'l j F Y'),
];
}
}
use Sghazanfari\FilamentPersian\Concerns\HasPersianGlobalSearch;
class EventResource extends Resource
{
use HasPersianGlobalSearch;
public static function getGloballySearchableAttributes(): array
{
return ['title', 'body'];
}
}