Skip to content

Commit 147f786

Browse files
committed
[Wip] Feat pannel admin
1 parent a9b98b5 commit 147f786

40 files changed

+1330
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
namespace App\Filament\Resources;
4+
5+
use App\Filament\Resources\PermissionResource\Pages;
6+
use App\Filament\Resources\PermissionResource\RelationManagers;
7+
use App\Models\Permission;
8+
use Filament\Forms;
9+
use Filament\Forms\Form;
10+
use Filament\Resources\Resource;
11+
use Filament\Tables;
12+
use Filament\Tables\Table;
13+
use Illuminate\Database\Eloquent\Builder;
14+
use Illuminate\Database\Eloquent\SoftDeletingScope;
15+
16+
class PermissionResource extends Resource
17+
{
18+
protected static ?string $model = Permission::class;
19+
20+
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
21+
22+
public static function form(Form $form): Form
23+
{
24+
return $form
25+
->schema([
26+
Forms\Components\TextInput::make('name')
27+
->required(),
28+
Forms\Components\TextInput::make('guard_name')
29+
->required(),
30+
]);
31+
}
32+
33+
public static function table(Table $table): Table
34+
{
35+
return $table
36+
->columns([
37+
Tables\Columns\TextColumn::make('name')
38+
->searchable(),
39+
Tables\Columns\TextColumn::make('guard_name')
40+
->searchable(),
41+
Tables\Columns\TextColumn::make('created_at')
42+
->dateTime()
43+
->sortable()
44+
->toggleable(isToggledHiddenByDefault: true),
45+
Tables\Columns\TextColumn::make('updated_at')
46+
->dateTime()
47+
->sortable()
48+
->toggleable(isToggledHiddenByDefault: true),
49+
])
50+
->filters([
51+
//
52+
])
53+
->actions([
54+
Tables\Actions\EditAction::make(),
55+
])
56+
->bulkActions([
57+
Tables\Actions\BulkActionGroup::make([
58+
Tables\Actions\DeleteBulkAction::make(),
59+
]),
60+
]);
61+
}
62+
63+
public static function getRelations(): array
64+
{
65+
return [
66+
//
67+
];
68+
}
69+
70+
public static function getPages(): array
71+
{
72+
return [
73+
'index' => Pages\ListPermissions::route('/'),
74+
'create' => Pages\CreatePermission::route('/create'),
75+
'edit' => Pages\EditPermission::route('/{record}/edit'),
76+
];
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\PermissionResource\Pages;
4+
5+
use App\Filament\Resources\PermissionResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\CreateRecord;
8+
9+
class CreatePermission extends CreateRecord
10+
{
11+
protected static string $resource = PermissionResource::class;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\PermissionResource\Pages;
4+
5+
use App\Filament\Resources\PermissionResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\EditRecord;
8+
9+
class EditPermission extends EditRecord
10+
{
11+
protected static string $resource = PermissionResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\DeleteAction::make(),
17+
];
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\PermissionResource\Pages;
4+
5+
use App\Filament\Resources\PermissionResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\ListRecords;
8+
9+
class ListPermissions extends ListRecords
10+
{
11+
protected static string $resource = PermissionResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\CreateAction::make(),
17+
];
18+
}
19+
}
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace App\Filament\Resources;
4+
5+
use App\Filament\Resources\RoleResource\Pages;
6+
use App\Filament\Resources\RoleResource\RelationManagers;
7+
use App\Models\Role;
8+
use Filament\Forms;
9+
use Filament\Forms\Form;
10+
use Filament\Resources\Resource;
11+
use Filament\Tables;
12+
use Filament\Tables\Table;
13+
use Illuminate\Database\Eloquent\Builder;
14+
use Illuminate\Database\Eloquent\SoftDeletingScope;
15+
16+
class RoleResource extends Resource
17+
{
18+
protected static ?string $model = Role::class;
19+
20+
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
21+
22+
public static function form(Form $form): Form
23+
{
24+
return $form
25+
->schema([
26+
Forms\Components\TextInput::make('name')
27+
->required(),
28+
Forms\Components\TextInput::make('guard_name')
29+
->default(config('auth.defaults.guard'))
30+
->required(),
31+
]);
32+
}
33+
34+
public static function table(Table $table): Table
35+
{
36+
return $table
37+
->columns([
38+
Tables\Columns\TextColumn::make('name')
39+
->searchable(),
40+
Tables\Columns\TextColumn::make('guard_name')
41+
->searchable(),
42+
Tables\Columns\TextColumn::make('created_at')
43+
->dateTime()
44+
->sortable()
45+
->toggleable(isToggledHiddenByDefault: true),
46+
Tables\Columns\TextColumn::make('updated_at')
47+
->dateTime()
48+
->sortable()
49+
->toggleable(isToggledHiddenByDefault: true),
50+
])
51+
->filters([
52+
//
53+
])
54+
->actions([
55+
Tables\Actions\EditAction::make(),
56+
])
57+
->bulkActions([
58+
Tables\Actions\BulkActionGroup::make([
59+
Tables\Actions\DeleteBulkAction::make(),
60+
]),
61+
]);
62+
}
63+
64+
public static function getRelations(): array
65+
{
66+
return [
67+
//
68+
];
69+
}
70+
71+
public static function getPages(): array
72+
{
73+
return [
74+
'index' => Pages\ListRoles::route('/'),
75+
'create' => Pages\CreateRole::route('/create'),
76+
'edit' => Pages\EditRole::route('/{record}/edit'),
77+
];
78+
}
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\RoleResource\Pages;
4+
5+
use App\Filament\Resources\RoleResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\CreateRecord;
8+
9+
class CreateRole extends CreateRecord
10+
{
11+
protected static string $resource = RoleResource::class;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\RoleResource\Pages;
4+
5+
use App\Filament\Resources\RoleResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\EditRecord;
8+
9+
class EditRole extends EditRecord
10+
{
11+
protected static string $resource = RoleResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\DeleteAction::make(),
17+
];
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\RoleResource\Pages;
4+
5+
use App\Filament\Resources\RoleResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\ListRecords;
8+
9+
class ListRoles extends ListRecords
10+
{
11+
protected static string $resource = RoleResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\CreateAction::make(),
17+
];
18+
}
19+
}
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
namespace App\Filament\Resources;
4+
5+
use App\Filament\Resources\UserResource\Pages;
6+
use App\Filament\Resources\UserResource\Pages\CreateUser;
7+
use App\Filament\Resources\UserResource\RelationManagers;
8+
use App\Models\User;
9+
use Filament\Forms;
10+
use Filament\Forms\Components\Select;
11+
use Filament\Forms\Form;
12+
use Filament\Pages\Page;
13+
use Filament\Resources\Resource;
14+
use Filament\Tables;
15+
use Filament\Tables\Table;
16+
use Illuminate\Database\Eloquent\Builder;
17+
use Illuminate\Database\Eloquent\SoftDeletingScope;
18+
use Illuminate\Support\Facades\Hash;
19+
20+
class UserResource extends Resource
21+
{
22+
protected static ?string $model = User::class;
23+
24+
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
25+
26+
public static function form(Form $form): Form
27+
{
28+
return $form
29+
->schema([
30+
Forms\Components\TextInput::make('name')
31+
->required(),
32+
Forms\Components\TextInput::make('email')
33+
->email()
34+
->required(),
35+
Forms\Components\DateTimePicker::make('email_verified_at'),
36+
Forms\Components\TextInput::make('password')
37+
->password()
38+
->dehydrateStateUsing(fn ($state) => Hash::make($state))
39+
->dehydrated(fn (?string $state) => filled($state))
40+
->required(fn (Page $livewire) => ($livewire instanceof CreateUser))
41+
->minLength(6),
42+
Select::make('roles')
43+
->relationship('roles','name')
44+
->multiple()
45+
->preload()
46+
]);
47+
}
48+
49+
public static function table(Table $table): Table
50+
{
51+
return $table
52+
->columns([
53+
Tables\Columns\TextColumn::make('name')
54+
->searchable(),
55+
Tables\Columns\TextColumn::make('email')
56+
->searchable(),
57+
Tables\Columns\TextColumn::make('email_verified_at')
58+
->dateTime()
59+
->sortable(),
60+
Tables\Columns\TextColumn::make('created_at')
61+
->dateTime()
62+
->sortable()
63+
->toggleable(isToggledHiddenByDefault: true),
64+
Tables\Columns\TextColumn::make('updated_at')
65+
->dateTime()
66+
->sortable()
67+
->toggleable(isToggledHiddenByDefault: true),
68+
])
69+
->filters([
70+
//
71+
])
72+
->actions([
73+
Tables\Actions\EditAction::make(),
74+
])
75+
->bulkActions([
76+
Tables\Actions\BulkActionGroup::make([
77+
Tables\Actions\DeleteBulkAction::make(),
78+
]),
79+
]);
80+
}
81+
82+
public static function getRelations(): array
83+
{
84+
return [
85+
//
86+
];
87+
}
88+
89+
public static function getPages(): array
90+
{
91+
return [
92+
'index' => Pages\ListUsers::route('/'),
93+
'create' => Pages\CreateUser::route('/create'),
94+
'edit' => Pages\EditUser::route('/{record}/edit'),
95+
];
96+
}
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\UserResource\Pages;
4+
5+
use App\Filament\Resources\UserResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\CreateRecord;
8+
9+
class CreateUser extends CreateRecord
10+
{
11+
protected static string $resource = UserResource::class;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\UserResource\Pages;
4+
5+
use App\Filament\Resources\UserResource;
6+
use Filament\Actions;
7+
use Filament\Resources\Pages\EditRecord;
8+
9+
class EditUser extends EditRecord
10+
{
11+
protected static string $resource = UserResource::class;
12+
13+
protected function getHeaderActions(): array
14+
{
15+
return [
16+
Actions\DeleteAction::make(),
17+
];
18+
}
19+
}

0 commit comments

Comments
 (0)