Update CustomerResource.php
This commit is contained in:
parent
f0d88dfd7d
commit
61f7b704d7
1 changed files with 49 additions and 29 deletions
|
@ -4,6 +4,7 @@ namespace App\Filament\Resources;
|
|||
|
||||
use App\Filament\Resources\CustomerResource\Pages;
|
||||
use App\Models\Customer;
|
||||
use App\Models\PhyreServer;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
|
@ -22,36 +23,55 @@ class CustomerResource extends Resource
|
|||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
$phyreServers = [];
|
||||
$phyreServers[0] = 'Main Server';
|
||||
$getPhyreServers = PhyreServer::all();
|
||||
foreach ($getPhyreServers as $phyreServer) {
|
||||
$phyreServers[$phyreServer->id] = $phyreServer->name;
|
||||
}
|
||||
|
||||
$schema = [];
|
||||
if ($getPhyreServers->count() > 0) {
|
||||
$schema[] = Forms\Components\Select::make('server')
|
||||
->options($phyreServers)
|
||||
->default(0)
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
$schemaAppend = [
|
||||
|
||||
Forms\Components\TextInput::make('name')
|
||||
->prefixIcon('heroicon-s-user')
|
||||
->required()->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('username')
|
||||
->unique(Customer::class, 'username', ignoreRecord: true)
|
||||
->prefixIcon('heroicon-s-user')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->password()
|
||||
->prefixIcon('heroicon-s-lock-closed')
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('email')
|
||||
->prefixIcon('heroicon-s-envelope')
|
||||
->unique(Customer::class, 'email', ignoreRecord: true)
|
||||
->email()
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('phone'),
|
||||
Forms\Components\TextInput::make('address'),
|
||||
Forms\Components\TextInput::make('city'),
|
||||
Forms\Components\TextInput::make('state'),
|
||||
Forms\Components\TextInput::make('zip'),
|
||||
Forms\Components\TextInput::make('country'),
|
||||
Forms\Components\TextInput::make('company'),
|
||||
|
||||
];
|
||||
|
||||
$schema = array_merge($schema, $schemaAppend);
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
|
||||
Forms\Components\TextInput::make('name')
|
||||
->prefixIcon('heroicon-s-user')
|
||||
->required()->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('username')
|
||||
->unique(Customer::class, 'username', ignoreRecord: true)
|
||||
->prefixIcon('heroicon-s-user')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->password()
|
||||
->prefixIcon('heroicon-s-lock-closed')
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('email')
|
||||
->prefixIcon('heroicon-s-envelope')
|
||||
->unique(Customer::class, 'email', ignoreRecord: true)
|
||||
->email()
|
||||
->required(),
|
||||
|
||||
Forms\Components\TextInput::make('phone'),
|
||||
Forms\Components\TextInput::make('address'),
|
||||
Forms\Components\TextInput::make('city'),
|
||||
Forms\Components\TextInput::make('state'),
|
||||
Forms\Components\TextInput::make('zip'),
|
||||
Forms\Components\TextInput::make('country'),
|
||||
Forms\Components\TextInput::make('company'),
|
||||
|
||||
]);
|
||||
->schema($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
|
|
Loading…
Reference in a new issue