backoffice first commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\ClienteResource\Pages;
|
||||
use App\Models\Cliente;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ClienteResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Cliente::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-users';
|
||||
|
||||
protected static ?string $navigationLabel = 'Clienti';
|
||||
|
||||
protected static ?string $modelLabel = 'cliente';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'clienti';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form->schema([
|
||||
Forms\Components\TextInput::make('nome')->label('Nome')->required(),
|
||||
Forms\Components\TextInput::make('cognome')->label('Cognome'),
|
||||
Forms\Components\TextInput::make('ragione_sociale')->label('Ragione sociale'),
|
||||
Forms\Components\TextInput::make('email')->label('Email')->email()->required(),
|
||||
Forms\Components\TextInput::make('telefono')->label('Telefono')->tel(),
|
||||
Forms\Components\TextInput::make('indirizzo')->label('Indirizzo'),
|
||||
Forms\Components\TextInput::make('cap')->label('CAP')->maxLength(10),
|
||||
Forms\Components\TextInput::make('citta')->label('Città'),
|
||||
Forms\Components\TextInput::make('provincia')->label('Provincia')->maxLength(5),
|
||||
Forms\Components\Textarea::make('note')->label('Note')->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('nominativo')->label('Nominativo')->searchable(['nome', 'cognome', 'ragione_sociale']),
|
||||
Tables\Columns\TextColumn::make('email')->label('Email')->searchable()->copyable(),
|
||||
Tables\Columns\TextColumn::make('telefono')->label('Telefono')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('citta')->label('Città')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('preventivi_count')->label('Preventivi')->counts('preventivi'),
|
||||
Tables\Columns\TextColumn::make('created_at')->label('Registrato')->dateTime('d/m/Y')->sortable(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListClientes::route('/'),
|
||||
'edit' => Pages\EditCliente::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user