Merge pull request #2 from truncgil/user-management-system

Add user management functionality: Implemented UserActions for editin…
This commit is contained in:
Truncgil Technology
2025-09-30 06:51:18 +03:00
committed by GitHub
14 changed files with 208 additions and 4 deletions
+1
View File
@@ -23,3 +23,4 @@ Homestead.json
Homestead.yaml
Thumbs.db
@@ -0,0 +1,52 @@
<?php
namespace App\Filament\Admin\Resources\Users\Tables;
use Filament\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class UserActions
{
public static function make(): array
{
return [
EditAction::make()
->visible(fn () => Auth::user()?->can('Update:User')),
Action::make('change_password')
->label(__('filament-users::user.resource.change_password'))
->icon('heroicon-o-key')
->color('warning')
->form([
TextInput::make('password')
->label(__('filament-users::user.resource.password'))
->password()
->required()
->confirmed(),
TextInput::make('password_confirmation')
->label(__('filament-users::user.resource.password_confirmation'))
->password()
->required(),
])
->action(function ($record, array $data) {
$record->update([
'password' => Hash::make($data['password']),
]);
Notification::make()
->title(__('filament-users::user.resource.change_password_success'))
->success()
->send();
})
->visible(fn () => Auth::user()?->can('Update:User')),
DeleteAction::make()
->visible(fn () => Auth::user()?->can('Delete:User')),
];
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class UserPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('ViewAny:User');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, User $model): bool
{
return $user->can('View:User');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('Create:User');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, User $model): bool
{
return $user->can('Update:User');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, User $model): bool
{
return $user->can('Delete:User');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, User $model): bool
{
return $user->can('Restore:User');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, User $model): bool
{
return $user->can('ForceDelete:User');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->can('DeleteAny:User');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->can('RestoreAny:User');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('ForceDeleteAny:User');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, User $model): bool
{
return $user->can('Replicate:User');
}
/**
* Determine whether the user can reorder models.
*/
public function reorder(User $user): bool
{
return $user->can('Reorder:User');
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Providers;
use App\Models\User;
use App\Policies\UserPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Spatie\Permission\Models\Role;
use App\Policies\RolePolicy;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
User::class => UserPolicy::class,
Role::class => RolePolicy::class,
];
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
$this->registerPolicies();
}
}
@@ -39,6 +39,7 @@ class AdminPanelProvider extends PanelProvider
Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Admin/Widgets'), for: 'App\Filament\Admin\Widgets')
->plugin(\TomatoPHP\FilamentUsers\FilamentUsersPlugin::make())
->plugin(FilamentShieldPlugin::make())
->widgets([
AccountWidget::class,
@@ -58,7 +59,6 @@ class AdminPanelProvider extends PanelProvider
->authMiddleware([
Authenticate::class,
])
->plugin(\TomatoPHP\FilamentUsers\FilamentUsersPlugin::make())
->login()
->assets([
\Filament\Support\Assets\Css::make('citrus', resource_path('css/citrus.css')),
+1
View File
@@ -2,5 +2,6 @@
return [
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\Filament\AdminPanelProvider::class,
];
+1 -1
View File
@@ -179,7 +179,7 @@ return [
],
],
'exclude' => [
//
// TomatoPHP Users resource'u exclude etmeyin, permission kontrolü yapması için
],
],
+1 -1
View File
@@ -141,7 +141,7 @@ return [
'table' => [
'class' => \TomatoPHP\FilamentUsers\Filament\Resources\Users\Tables\UsersTable::class,
'filters' => \TomatoPHP\FilamentUsers\Filament\Resources\Users\Tables\UserFilters::class,
'actions' => \TomatoPHP\FilamentUsers\Filament\Resources\Users\Tables\UserActions::class,
'actions' => \App\Filament\Admin\Resources\Users\Tables\UserActions::class,
'bulkActions' => \TomatoPHP\FilamentUsers\Filament\Resources\Users\Tables\UserBulkActions::class,
],
'form' => [
+3 -1
View File
@@ -3,7 +3,9 @@
height: 6rem !important;
width: auto !important;
}
.fi-topbar-start .fi-logo {
height: 2.5rem !important;
}
/* Login sayfası brand logo boyutu */
.fi-brand-logo {
height: 6rem !important;
+1
View File
@@ -10,3 +10,4 @@
'Segoe UI Symbol', 'Noto Color Emoji';
}
+1
View File
@@ -4,6 +4,7 @@
width: auto !important;
}
/* Login sayfası brand logo boyutu */
.fi-brand-logo {
height: 6rem !important;
+1
View File
@@ -1,2 +1,3 @@
import './bootstrap';
+1
View File
@@ -3,3 +3,4 @@ window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
+1
View File
@@ -12,3 +12,4 @@ export default defineConfig({
],
});