diff --git a/app/Filament/Admin/Resources/Customers/CustomerResource.php b/app/Filament/Admin/Resources/Customers/CustomerResource.php new file mode 100644 index 0000000..5d0e3e0 --- /dev/null +++ b/app/Filament/Admin/Resources/Customers/CustomerResource.php @@ -0,0 +1,48 @@ + ListCustomers::route('/'), + 'create' => CreateCustomer::route('/create'), + 'edit' => EditCustomer::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php b/app/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php new file mode 100644 index 0000000..267a3d0 --- /dev/null +++ b/app/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php @@ -0,0 +1,11 @@ +components([ + \Filament\Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + \Filament\Forms\Components\TextInput::make('email') + ->email() + ->required() + ->unique(ignoreRecord: true) + ->maxLength(255), + \Filament\Forms\Components\TextInput::make('phone') + ->tel() + ->maxLength(255), + \Filament\Forms\Components\Textarea::make('address') + ->maxLength(65535) + ->columnSpanFull(), + \Filament\Forms\Components\TextInput::make('city') + ->maxLength(255), + \Filament\Forms\Components\TextInput::make('country') + ->maxLength(255), + \Filament\Forms\Components\Select::make('status') + ->options([ + 'active' => 'Active', + 'inactive' => 'Inactive', + 'pending' => 'Pending', + ]) + ->default('active') + ->required(), + \Filament\Forms\Components\Textarea::make('notes') + ->maxLength(65535) + ->columnSpanFull(), + ]); + } +} diff --git a/app/Filament/Admin/Resources/Customers/Tables/CustomersTable.php b/app/Filament/Admin/Resources/Customers/Tables/CustomersTable.php new file mode 100644 index 0000000..111aad9 --- /dev/null +++ b/app/Filament/Admin/Resources/Customers/Tables/CustomersTable.php @@ -0,0 +1,54 @@ +columns([ + \Filament\Tables\Columns\TextColumn::make('name') + ->searchable() + ->sortable(), + \Filament\Tables\Columns\TextColumn::make('email') + ->searchable() + ->sortable(), + \Filament\Tables\Columns\TextColumn::make('phone') + ->searchable(), + \Filament\Tables\Columns\TextColumn::make('city') + ->searchable() + ->sortable(), + \Filament\Tables\Columns\TextColumn::make('country') + ->searchable() + ->sortable(), + \Filament\Tables\Columns\TextColumn::make('status') + ->badge() + ->color(fn (string $state): string => match ($state) { + 'active' => 'success', + 'inactive' => 'danger', + 'pending' => 'warning', + }), + \Filament\Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + // + ]) + ->recordActions([ + EditAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Models/Customer.php b/app/Models/Customer.php new file mode 100644 index 0000000..bdc06b1 --- /dev/null +++ b/app/Models/Customer.php @@ -0,0 +1,27 @@ + 'datetime', + 'updated_at' => 'datetime', + ]; +} diff --git a/database/migrations/2025_09_27_162059_create_customers_table.php b/database/migrations/2025_09_27_162059_create_customers_table.php new file mode 100644 index 0000000..5919eb0 --- /dev/null +++ b/database/migrations/2025_09_27_162059_create_customers_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('name'); + $table->string('email')->unique(); + $table->string('phone')->nullable(); + $table->text('address')->nullable(); + $table->string('city')->nullable(); + $table->string('country')->nullable(); + $table->enum('status', ['active', 'inactive', 'pending'])->default('active'); + $table->text('notes')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customers'); + } +};