-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added filament package and first crud - user resource
- Loading branch information
1 parent
e037edc
commit 38351b9
Showing
9 changed files
with
2,666 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Blumilk\Website\Filament\Resources; | ||
|
||
use Blumilk\Website\Filament\Resources\UserResource\Pages; | ||
use Blumilk\Website\Models\User; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
|
||
class UserResource extends Resource | ||
{ | ||
protected static ?string $model = User::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label('Imię i nazwisko') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('email') | ||
->label('E-mail') | ||
->required() | ||
->maxLength(255) | ||
->email() | ||
->unique(ignoreRecord: true), | ||
Forms\Components\TextInput::make('password') | ||
->label('Hasło') | ||
->required() | ||
->password() | ||
->confirmed(), | ||
Forms\Components\TextInput::make('password_confirmation') | ||
->label('Potwierdź hasło') | ||
->required() | ||
->password(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make("name") | ||
->label("Imię i nazwisko"), | ||
Tables\Columns\TextColumn::make("email") | ||
->label("E-mail"), | ||
]) | ||
->filters([]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListUsers::route('/'), | ||
'create' => Pages\CreateUser::route('/create'), | ||
'edit' => Pages\EditUser::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Blumilk\Website\Filament\Resources\UserResource\Pages; | ||
|
||
use Blumilk\Website\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateUser extends CreateRecord | ||
{ | ||
protected static string $resource = UserResource::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Blumilk\Website\Filament\Resources\UserResource\Pages; | ||
|
||
use Blumilk\Website\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditUser extends EditRecord | ||
{ | ||
protected static string $resource = UserResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Blumilk\Website\Filament\Resources\UserResource\Pages; | ||
|
||
use Blumilk\Website\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListUsers extends ListRecords | ||
{ | ||
protected static string $resource = UserResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Blumilk\Website\Providers\Filament; | ||
|
||
use Filament\Http\Middleware\Authenticate; | ||
use Filament\Http\Middleware\DisableBladeIconComponents; | ||
use Filament\Http\Middleware\DispatchServingFilamentEvent; | ||
use Filament\Pages; | ||
use Filament\Panel; | ||
use Filament\PanelProvider; | ||
use Filament\Support\Colors\Color; | ||
use Filament\Widgets; | ||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; | ||
use Illuminate\Cookie\Middleware\EncryptCookies; | ||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; | ||
use Illuminate\Routing\Middleware\SubstituteBindings; | ||
use Illuminate\Session\Middleware\AuthenticateSession; | ||
use Illuminate\Session\Middleware\StartSession; | ||
use Illuminate\View\Middleware\ShareErrorsFromSession; | ||
|
||
class AdminPanelProvider extends PanelProvider | ||
{ | ||
public function panel(Panel $panel): Panel | ||
{ | ||
return $panel | ||
->default() | ||
->id('admin') | ||
->path('admin') | ||
->login() | ||
->colors([ | ||
'primary' => Color::Amber, | ||
]) | ||
->discoverResources(in: app_path('Filament/Resources'), for: 'Blumilk\\Website\\Filament\\Resources') | ||
->discoverPages(in: app_path('Filament/Pages'), for: 'Blumilk\\Website\\Filament\\Pages') | ||
->pages([ | ||
Pages\Dashboard::class, | ||
]) | ||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'Blumilk\\Website\\Filament\\Widgets') | ||
->widgets([ | ||
Widgets\AccountWidget::class, | ||
Widgets\FilamentInfoWidget::class, | ||
]) | ||
->middleware([ | ||
EncryptCookies::class, | ||
AddQueuedCookiesToResponse::class, | ||
StartSession::class, | ||
AuthenticateSession::class, | ||
ShareErrorsFromSession::class, | ||
VerifyCsrfToken::class, | ||
SubstituteBindings::class, | ||
DisableBladeIconComponents::class, | ||
DispatchServingFilamentEvent::class, | ||
]) | ||
->authMiddleware([ | ||
Authenticate::class, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Blumilk\Website\Providers\AppServiceProvider; | ||
|
||
return [ | ||
AppServiceProvider::class, | ||
Blumilk\Website\Providers\Filament\AdminPanelProvider::class, | ||
Blumilk\Website\Providers\AppServiceProvider::class, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.