plan options
This commit is contained in:
1 parent
8463f50f6b
commit
ecb66a76b5
14 files changed
+277
-303
No files matched your search
@@ -2,15 +2,20 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos\Schemas;
|
||||
|
||||
use Alkoumi\FilamentImageRadioButton\Forms\Components\ImageRadioGroup;
|
||||
use App\Models\Konto;
|
||||
use App\Models\Plan;
|
||||
use Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Filament\Support\Enums\IconPosition;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use JaOcero\RadioDeck\Forms\Components\RadioDeck;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class KontoForm
|
||||
@@ -20,57 +25,77 @@ class KontoForm
|
||||
return $schema
|
||||
->components([
|
||||
|
||||
// Radio Cards with default features
|
||||
|
||||
// ImageRadioGroup::make('plan_id')
|
||||
// ->animation(true)
|
||||
// ->disk('promotion')
|
||||
// ->label('Plan')
|
||||
// ->required()
|
||||
// ->columnSpanFull()
|
||||
// ->options(fn () => Plan::pluck('promotion', 'id')->toArray()),
|
||||
Section::make('Firma')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('company')
|
||||
->label('Firma')
|
||||
->required(),
|
||||
TextInput::make('uid_number')
|
||||
->label('UID Nummer')
|
||||
->rules([new VatNumber])
|
||||
->required(),
|
||||
Textarea::make('address')
|
||||
->label('Adresse')
|
||||
->required(),
|
||||
TextInput::make('country')
|
||||
->label('Land')
|
||||
->default('Österreich')
|
||||
->required(),
|
||||
])->columnSpanFull(),
|
||||
Section::make('Kontaktperson')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Title')
|
||||
->required(),
|
||||
Select::make('gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label('E-Mail')
|
||||
->unique(table: Konto::class)
|
||||
->required(),
|
||||
PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make('Zahlungsplan')
|
||||
->schema([
|
||||
RadioDeck::make('plan_id')
|
||||
->label('Wählen sie eine Option')
|
||||
->options(fn () => Plan::pluck('name', 'id')->toArray())
|
||||
->descriptions(Plan::options())
|
||||
->icons(fn () => Plan::pluck('icon', 'id')->toArray())
|
||||
->required()
|
||||
->iconPosition(IconPosition::Before) // Before | After
|
||||
->iconSize(IconSize::TwoExtraLarge)
|
||||
->alignment(Alignment::Center) // Start | Center | End
|
||||
->padding('px-4 py-6') // Padding around the deck
|
||||
->extraCardsAttributes([ // Extra attributes for card elements
|
||||
'class' => 'rounded-xl drop-shadow-xl mt-1',
|
||||
])
|
||||
->extraOptionsAttributes([ // Extra attributes for option elements
|
||||
'class' => 'text-2xl md:text-3xl font-black tracking-tight lg:text-4xl',
|
||||
])
|
||||
// ->extraDescriptionsAttributes([ // Extra attributes for description elements
|
||||
// 'class' => 'text-sm font-light',
|
||||
// ])
|
||||
->colors('primary')
|
||||
->columns(3)
|
||||
->columnSpanFull(),
|
||||
])->columnSpanFull(),
|
||||
Tab::make('Firma')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('company')
|
||||
->label('Firma')
|
||||
->required(),
|
||||
TextInput::make('uid_number')
|
||||
->label('UID Nummer')
|
||||
->rules([new VatNumber])
|
||||
->required(),
|
||||
Textarea::make('address')
|
||||
->label('Adresse')
|
||||
->required(),
|
||||
TextInput::make('country')
|
||||
->label('Land')
|
||||
->default('Österreich')
|
||||
->required(),
|
||||
])->columnSpanFull(),
|
||||
Tab::make('Kontaktperson')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Title')
|
||||
->required(),
|
||||
Select::make('gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label('E-Mail')
|
||||
->unique(table: Konto::class)
|
||||
->required()
|
||||
->prefixIcon(Heroicon::Envelope),
|
||||
PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
])->columnSpanFull(),
|
||||
])->columnSpanFull(),
|
||||
|
||||
]);
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos\Tables;
|
||||
|
||||
use App\Forms\Components\PlanRadioGroup;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -20,6 +21,13 @@ class KontosTable
|
||||
->columns([
|
||||
TextColumn::make('company')->label('Firma')
|
||||
->description(fn ($record): string => $record->address),
|
||||
IconColumn::make('plan.icon')
|
||||
->width('30px')
|
||||
->label('')
|
||||
->size(IconSize::TwoExtraLarge)
|
||||
->color('primary')
|
||||
->icon(fn (string $state): string => $state)
|
||||
->extraAttributes(['class' => 'rounded-xl border border-gray-200 dark:border-gray-700 drop-shadow-xl']),
|
||||
|
||||
TextColumn::make('plan.name')
|
||||
->label('Zahlungs Plan')
|
||||
@@ -28,7 +36,7 @@ class KontosTable
|
||||
TextColumn::make('guthaben')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->label('Fertig')
|
||||
->label('Erstellt')
|
||||
->color('primary')
|
||||
->description('Gutachten')
|
||||
->alignCenter(),
|
||||
@@ -43,20 +51,6 @@ class KontosTable
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton()->color('gray'),
|
||||
Action::make('Konto')
|
||||
->iconButton()
|
||||
->color('gray')
|
||||
->icon('lucide-plane-takeoff')
|
||||
->schema([
|
||||
PlanRadioGroup::make('plan_id')
|
||||
->label('Plan')
|
||||
->options(fn () => Plan::pluck('name', 'id')->toArray()),
|
||||
// ->options([
|
||||
// '1' => 'Basic',
|
||||
// '2' => 'Smart',
|
||||
// '3' => 'Premium',
|
||||
// ]),
|
||||
]),
|
||||
Action::make('Bezahlen')
|
||||
->iconButton()
|
||||
->color('gray')
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Resources\Plans\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -18,10 +17,8 @@ class PlanForm
|
||||
Textarea::make('description')->label('Beschreibung')->required(),
|
||||
TextInput::make('preis')->required()->numeric(),
|
||||
TextInput::make('limit_user')->required()->label('Anzahl Benutzer')->numeric(),
|
||||
TextInput::make('limit_auftraggeber')->required()->label('Anzahl Auftraggeber')->numeric(),
|
||||
TextInput::make('limit_gutachter')->required()->label('Anzahl Gutachter')->numeric(),
|
||||
TextInput::make('limit_gutachten')->required()->label('Anzahl Projekte')->numeric(),
|
||||
FileUpload::make('promotion')->disk('promotion'),
|
||||
TextInput::make('icon'),
|
||||
])->inlineLabel()->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
namespace App\Filament\Resources\Plans\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -13,15 +14,17 @@ class PlansTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('promotion')->imageHeight(100)->disk('promotion'),
|
||||
IconColumn::make('icon')
|
||||
->label('')
|
||||
->size(IconSize::TwoExtraLarge)
|
||||
->color('primary')
|
||||
->icon(fn (string $state): string => $state),
|
||||
TextColumn::make('name')
|
||||
->description(fn ($record): string => $record->description)
|
||||
->wrap(),
|
||||
TextColumn::make('payment')->label('Plan'),
|
||||
TextColumn::make('limit_user')->label('B')->tooltip('Benutzer')->badge(),
|
||||
TextColumn::make('limit_auftraggeber')->label('A')->tooltip('Auftraggeber')->badge(),
|
||||
TextColumn::make('limit_gutachter')->label('G')->tooltip('Gutachter')->badge(),
|
||||
TextColumn::make('limit_gutachten')->label('P')->tooltip('Projekte')->badge(),
|
||||
TextColumn::make('limit_user')->label('Benutzer')->badge(),
|
||||
TextColumn::make('limit_gutachter')->label('Gutachter')->badge(),
|
||||
TextColumn::make('preis')->money('EUR'),
|
||||
])
|
||||
->recordActions([
|
||||
@@ -29,9 +32,3 @@ class PlansTable
|
||||
]);
|
||||
}
|
||||
}
|
||||
// `file` varchar(255) DEFAULT NULL,
|
||||
// `preis` int(11) NOT NULL DEFAULT 0,
|
||||
// `limit_user` int(11) NOT NULL DEFAULT 1,
|
||||
// `limit_auftraggeber` int(11) NOT NULL DEFAULT 1,
|
||||
// `limit_gutachter` int(11) NOT NULL DEFAULT 1,
|
||||
// `limit_gutachten` int(11) D
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Components;
|
||||
|
||||
use Filament\Forms\Components\Field;
|
||||
|
||||
class PlanRadioGroup extends Field
|
||||
{
|
||||
protected string $view = 'forms.components.custom-radio-group';
|
||||
|
||||
protected array $options = []; // Property to store options
|
||||
|
||||
public function options(array $options): static
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->evaluate($this->options);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentPlan extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
+18
-1
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
@@ -20,6 +21,22 @@ class Plan extends Model
|
||||
'limit_auftraggeber',
|
||||
'limit_gutachter',
|
||||
'limit_gutachten',
|
||||
'promotion',
|
||||
'icon',
|
||||
];
|
||||
|
||||
public static function options()
|
||||
{
|
||||
$arr = Plan::all()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$str = '<div class="text-primary-500 text-lg">'.$value['payment'].'</div>';
|
||||
$str .= '<div class="text-xl font-black">'.number_format($value['preis'], 2).'€</div>';
|
||||
$str .= '<ol class="font-light text-xs leading-3 m-0 p-3">';
|
||||
$str .= '<li>'.$value['limit_user'].' Benutzer</li>';
|
||||
$str .= '<li>'.$value['limit_gutachter'].' Gutachter</li>';
|
||||
$str .= '</ol>';
|
||||
$arr[$key + 1] = new HtmlString($str);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user