PHP code example of kreetancraft / laravel-user-management
1. Go to this page and download the library: Download kreetancraft/laravel-user-management library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kreetancraft / laravel-user-management example snippets
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => Kreetancraft\UserManagement\Models\User::class,
],
],
class User extends \Kreetancraft\UserManagement\Models\User {}
'layouts' => [
'admin' => 'components.layouts.app', // view name
'auth' => 'layouts.auth', // component name
],
app(\Kreetancraft\UserManagement\Navigation::class)->add([
'label' => 'Reports',
'icon' => 'chart-bar',
'route' => 'admin.reports',
'ability' => 'view-reports', // optional
'sort' => 40,
]);
// in any service provider. No mention of this package anywhere.
$this->app->bind('acme.navigation.items', fn () => [[
'label' => __('Invoices'),
'icon' => 'document-text',
'route' => 'admin.invoices',
'ability' => 'viewAny',
'model' => Invoice::class,
'sort' => 30,
]]);
$this->app->tag('acme.navigation.items', 'admin.navigation');
// config/user-management.php
'avatar_resolver' => \Kreetancraft\Media\Support\MediaAvatarResolver::class,
'media_picker_view' => 'media::picker-field',
// config/user-management.php
'avatar_uploader' => 'media.avatar-uploader',
'super_admin' => ['role' => 'super-admin', 'enabled' => true],
'features' => [
'two_factor' => true, 'passkeys' => true,
'impersonation' => true, 'login_history' => true,
'registration' => false,
],
// Colours. Roles are runtime rows, so a colour is chosen by hashing the role
// name against this palette — stable everywhere, nothing to configure per role.
'ui' => [
'role_palette' => ['blue', 'emerald', 'violet', 'amber', 'cyan', 'pink', 'lime', 'indigo', 'teal', 'orange'],
'super_admin_color' => 'red',
'status' => ['active' => 'emerald', 'inactive' => 'zinc'],
],
'routes' => [
'prefix' => 'admin',
'middleware' => ['web', 'auth', 'verified', 'ensure.2fa.enforced'],
'names' => [
// Required only if you enforce 2FA per user: the route where they enable it.
'security_edit' => null,
],
],
'permissions' => ['protected' => []], // your permission names the UI must refuse to delete
'invitation_expiry_hours' => 48,
bash
php artisan vendor:publish --tag=user-management-config
bash
php artisan migrate
bash
php artisan user-management:super-admin
bash
php artisan user-management:sync-permissions
blade
<livewire:user-management.avatar /> {{-- the signed-in user --}}
<livewire:user-management.avatar :user="$someone" /> {{-- someone else; needs update-users --}}
bash
php artisan user-management:avatar-doctor
bash
php artisan user-management:install
bash
php artisan user-management:super-admin
bash
php artisan user-management:sync-permissions
bash
php artisan user-management:avatar-doctor