fix: Forms\Get/Set->Schemas Get/Set on Central panel + rename Super-admini to Utilizatori
This commit is contained in:
@@ -11,6 +11,8 @@ use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
@@ -51,7 +53,7 @@ class SubscriptionResource extends Resource
|
||||
->label('Plan')
|
||||
->options(fn () => Plan::pluck('name', 'id'))
|
||||
->required()->searchable()->live()
|
||||
->afterStateUpdated(function ($state, Forms\Set $set, Forms\Get $get) {
|
||||
->afterStateUpdated(function ($state, Set $set, Get $get) {
|
||||
if (! $state) return;
|
||||
$plan = Plan::find($state);
|
||||
if (! $plan) return;
|
||||
@@ -61,7 +63,7 @@ class SubscriptionResource extends Resource
|
||||
}),
|
||||
Forms\Components\Select::make('period')
|
||||
->options(Subscription::PERIODS)->default('monthly')->required()->live()
|
||||
->afterStateUpdated(function ($state, Forms\Set $set, Forms\Get $get) {
|
||||
->afterStateUpdated(function ($state, Set $set, Get $get) {
|
||||
$plan = Plan::find($get('plan_id'));
|
||||
if (! $plan) return;
|
||||
$set('amount', $state === 'yearly' ? $plan->price_yearly : $plan->price_monthly);
|
||||
@@ -78,7 +80,7 @@ class SubscriptionResource extends Resource
|
||||
Schemas\Components\Section::make('Sumă')
|
||||
->columns(3)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('amount')->numeric()->required()->suffix(fn (Forms\Get $get) => $get('currency') ?? 'MDL'),
|
||||
Forms\Components\TextInput::make('amount')->numeric()->required()->suffix(fn (Get $get) => $get('currency') ?? 'MDL'),
|
||||
Forms\Components\Select::make('currency')->options(['MDL' => 'MDL', 'EUR' => 'EUR', 'USD' => 'USD'])->default('MDL'),
|
||||
Forms\Components\Select::make('payment_method')
|
||||
->options(Subscription::PAYMENT_METHODS),
|
||||
@@ -113,7 +115,7 @@ class SubscriptionResource extends Resource
|
||||
Tables\Columns\TextColumn::make('company.name')
|
||||
->label('Companie')
|
||||
->searchable()
|
||||
->url(fn ($r) => route('filament.central.resources.companies.edit', ['record' => $r->company_id])),
|
||||
->url(fn ($r) => \App\Filament\Central\Resources\CompanyResource::getUrl('view', ['record' => $r->company_id])),
|
||||
Tables\Columns\TextColumn::make('plan.name')->label('Plan')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('period')
|
||||
->formatStateUsing(fn ($s) => Subscription::PERIODS[$s] ?? $s)
|
||||
|
||||
Reference in New Issue
Block a user