Merge pull request #2 from truncgil/user-management-system
Add user management functionality: Implemented UserActions for editin…
This commit is contained in:
@@ -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')),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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')),
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\Filament\AdminPanelProvider::class,
|
||||
];
|
||||
|
||||
@@ -179,7 +179,7 @@ return [
|
||||
],
|
||||
],
|
||||
'exclude' => [
|
||||
//
|
||||
// TomatoPHP Users resource'u exclude etmeyin, permission kontrolü yapması için
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
|
||||
/* Login sayfası brand logo boyutu */
|
||||
.fi-brand-logo {
|
||||
height: 6rem !important;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
import './bootstrap';
|
||||
|
||||
|
||||
|
||||
Vendored
+1
@@ -3,3 +3,4 @@ window.axios = axios;
|
||||
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
||||
|
||||
|
||||
@@ -12,3 +12,4 @@ export default defineConfig({
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user