namvoyager/simple-user-management

v1.0.1 2024-05-07 10:02 UTC

This package is auto-updated.

Last update: 2024-05-07 10:07:39 UTC


README

PHP v8.2

Laravel v11.x

Installation

Install using composer:

composer require namvoyager/simple-user-management

Publish and install initial resources

php artisan user-management:install

Customize and override vendor logic

To customize the logic of the user management feature, you can open the app/Http/Controllers/UserController file. Here the controller will use UserRepository to handle logic.

namespace App\Http\Controllers;

use VoyagerInc\SimpleUserManagement\Contracts\UserRepository;

class UserController extends Controller
{
    public function __construct(
        protected UserRepository $users,
    ) {
    }
}

To be able to inherit or override VoyagerInc\SimpleUserManagement\Repositories\UserRepository, you can define a new App\Repositories\UserRepository class and implement VoyagerInc\SimpleUserManagement\Contracts\UserRepository. Then go to app\Providers\SimpleUserManagementServiceProvider to declare, now you can replace the UserRepository class of the vendor.

First, define a new UserRepository in path app\Repositories.

namespace App\Repositories;

use VoyagerInc\SimpleUserManagement\Contracts\UserRepository as UserRepositoryContract;

class UserRepository implements UserRepositoryContract
{
    // Override all the methods of the interface here.
}

Then, go to app\Providers\SimpleUserManagementServiceProvider.php.

use VoyagerInc\SimpleUserManagement\Contracts\UserRepository as UserRepositoryContract;
use App\Repositories\UserRepository;

public function register()
{
    $this->app->singleton(UserRepositoryContract::class, UserRepository::class);
}

Custom view

User management view files are located in the path resources/views/users/. Corresponding to each screen there will be files: index.blade.php, create.blade.php, show.blade.php, edit.blade.php