Add navigation sorting to SettingsCluster, enhance CurrencyRate model with table association and name attribute, and update Turkish translations for currency terms
This commit is contained in:
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages\CreateCurrencyRate;
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages\EditCurrencyRate;
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages\ListCurrencyRates;
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\Schemas\CurrencyRateForm;
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\Tables\CurrencyRatesTable;
|
||||||
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||||
|
use App\Modules\CurrencyRate\Models\CurrencyRate;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class CurrencyRateResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = CurrencyRate::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCurrencyDollar;
|
||||||
|
|
||||||
|
protected static ?string $cluster = SettingsCluster::class;
|
||||||
|
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): ?string
|
||||||
|
{
|
||||||
|
return __('Currencies');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('Currency rate');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('Currency rates');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return CurrencyRateForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return CurrencyRatesTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListCurrencyRates::route('/'),
|
||||||
|
'create' => CreateCurrencyRate::route('/create'),
|
||||||
|
'edit' => EditCurrencyRate::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\CurrencyRateResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateCurrencyRate extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CurrencyRateResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\CurrencyRateResource;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditCurrencyRate extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CurrencyRateResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Resources\CurrencyRates\CurrencyRateResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListCurrencyRates extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = CurrencyRateResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates\Schemas;
|
||||||
|
|
||||||
|
use App\Modules\CurrencyRate\Models\CurrencyRate;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class CurrencyRateForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Select::make('currency_from')
|
||||||
|
->label(__('Currency from'))
|
||||||
|
->native(false)
|
||||||
|
->searchable()
|
||||||
|
->options(CurrencyRate::currencies())
|
||||||
|
->rules('required')
|
||||||
|
->belowLabel('1 möçberi'),
|
||||||
|
|
||||||
|
Select::make('currency_to')
|
||||||
|
->label(__('Currency to'))
|
||||||
|
->native(false)
|
||||||
|
->searchable()
|
||||||
|
->options(CurrencyRate::currencies())
|
||||||
|
->rules('required')
|
||||||
|
->belowLabel('1 möçberi'),
|
||||||
|
|
||||||
|
TextInput::make('value')
|
||||||
|
->label(__('Currency value'))
|
||||||
|
->required()
|
||||||
|
->numeric()
|
||||||
|
->belowLabel('Bitin däl sanlary "." bilen ýazmaly'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Resources\CurrencyRates\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class CurrencyRatesTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('currency_from')
|
||||||
|
->label(__('Currency from'))
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('currency_to')
|
||||||
|
->label(__('Currency to'))
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('value')
|
||||||
|
->label(__('Currency value'))
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ use Filament\Support\Icons\Heroicon;
|
|||||||
|
|
||||||
class SettingsCluster extends Cluster
|
class SettingsCluster extends Cluster
|
||||||
{
|
{
|
||||||
|
protected static ?int $navigationSort = 100;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCog8Tooth;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCog8Tooth;
|
||||||
|
|
||||||
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::End;
|
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::End;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Modules\CurrencyRate\Models;
|
namespace App\Modules\CurrencyRate\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -14,6 +15,20 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class CurrencyRate extends Model
|
class CurrencyRate extends Model
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*/
|
||||||
|
protected $table = 'currency_rates';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user's first name.
|
||||||
|
*/
|
||||||
|
protected function name(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn () => $this->currency_from . '-' . $this->currency_to,
|
||||||
|
);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Currencies
|
* Currencies
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -705,5 +705,9 @@
|
|||||||
"Name, Surname, Patronic name": "Ady, Familiýasy, Atasynyň ady",
|
"Name, Surname, Patronic name": "Ady, Familiýasy, Atasynyň ady",
|
||||||
"Deposit account": "Goýum hasaby",
|
"Deposit account": "Goýum hasaby",
|
||||||
"Files": "Faýllar",
|
"Files": "Faýllar",
|
||||||
"Payment type": "Töleg görnüşi"
|
"Payment type": "Töleg görnüşi",
|
||||||
|
"Currency from": "Walýuta girişi",
|
||||||
|
"Currency to": "Walýuta çykýan",
|
||||||
|
"Currency value": "Kursy",
|
||||||
|
"Currency rates": "Walýuta kurslary"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user