GithubHelp home page GithubHelp logo

kineticamobile / lumki Goto Github PK

View Code? Open in Web Editor NEW
75.0 4.0 26.0 1018 KB

Laravel 8 Users Management. Add-on to Jetstream, using spatie/laravel-permissions & lab404/laravel-impersonate

License: Other

PHP 65.79% Blade 34.21%

lumki's Introduction

Lumki

Laravel Users Management to Laravel 8 Jetstream (Using Spatie/LaravelPermissions & Lab404/LaravelImpersonate).

Functionalities

Impersonation / Leave:

Gif showing impersonation

Add Role To User:

Gif showing hot to add Role to User

Roles - Create and associate Permissions:

Gif adding new Roles and adding permissions to Role

Permissions - Index and create new:

Gif creating new permissions

Functionality Working Test
User - Index
User - Edit Roles
Role - Index
Role - Edit Permissions
Role - Create
Permission - Index
Permission - Create
Blade @lumki
Command to Setup

✓/⨯

Installation

Via Composer

$ composer require kineticamobile/lumki

Setup over Laravel 8 Jetstream at least one User registered to associate permissions

$ php artisan lumki:setup

Explained setup

Publish spatie/laravel-permissions

$ php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"

Publish lab404/laravel-permissions

$ php artisan vendor:publish --tag=impersonate

Add permissions traits to Models/User

Lumki::insertLineAfter(
    app_path("Models/User.php"),
    "use Laravel\Jetstream\HasProfilePhoto;",
    "use Spatie\Permission\Traits\HasRoles;"
);
Lumki::insertLineAfter(
    app_path("Models/User.php"),
    "use HasProfilePhoto;",
    "use HasRoles;"
);

Add impersonate traits to Models/User

Lumki::insertLineAfter(
    app_path("Models/User.php"),
    "use Spatie\Permission\Traits\HasRoles;",
    "use Lab404\Impersonate\Models\Impersonate;"
);
Lumki::insertLineAfter(
    app_path("Models/User.php"),
    "use HasRoles;",
    "use Impersonate;"
);

Run migrations

$ php artisan migrate

Add Impersonate Routes

Lumki::insertLineBefore(
        base_path("routes/web.php"),
        "Route::get('/', function () {",
        "Route::impersonate();\n"
);

Add Lumki menu items in User's menu

Lumki::insertLineBefore(
        resource_path('views/navigation-dropdown.blade.php'),
        "@if (Laravel\Jetstream\Jetstream::hasApiFeatures())",
        "\n@lumki\n"
);

Add roles/permissions

$r1 = Role::firstOrCreate(["name" => "Superadmin"]);
$r2 = Role::firstOrCreate(["name" => "Admin"]);
$r3 = Role::firstOrCreate(["name" => "User"]);

$p1 = Permission::firstOrCreate(['name' => 'manage users']);

$r1->givePermissionTo('manage users');

$user = User::first();
$user->assignRole($r1);
$user->assignRole($r2);
$user->assignRole($r3);

Usage

Customizable prefix for your routes

To change the prefix lumki in your routes you must publish the configuration

$ php artisan vendor:publish --tag=lumki.config 

Now, you can edit the file config/lumki.php and change the prefix from 'lumki' to whatever you want, empty string allowed, if this field is null 'lumki' is set as default value.

Error 'GuardDoesNotMatch'

If you are struggling with the error of GuardDoesNotMatch could be that you have modified the provider in your config/auth.php file

In order to solve this problem you can specify the guard name of the model.

Eg: If you are using User Model but with an ldap connection using LdapRecord you can resolve this problem adding the code above in your User Model

class User extends Authenticatable
{
    // ...

    public function guardName(){
        return "web";
    }
}

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.

lumki's People

Contributors

branigan avatar dmaciasr avatar laravel-shift avatar lsmith77 avatar raultm avatar shbov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lumki's Issues

How can you delete roles and permissions?

Can you please explain how can you delete the roles and permissions? I don't see any options through the documentation.
If you made a typo and want to rename the role/permissions how can you rectify that?

team roles?

Is there any way this package can be bound to user roles (JetstreamServiceProvider) in the jetstream teams roles?
I dont see a reason to use user roles when using teams where users have roles assigned within the team?

Add the permission access field to the config

Hi, it seems to me that we need to add the ability to change the access permission to the package. Something like this:

config/lumki.php

<?php

$permissionAccess = 'users.edit.*';

return [
    "prefix" => 'lumki',
    "permissionAccess" => $permissionAccess,
    "middleware" => ['web', 'auth:sanctum', 'can:'.$permissionAccess],
    'custom_fields' => [
        // [
        //     'type' => 'text',
        //     'name' => 'username',
        //     'label' => 'Username',
        //     'placeholder' => 'Username',
        // ],
    ]
];```

Cant install on Laravel 10

I am having this errors while trying to install in Laravel 10:

  • Root composer.json requires kineticamobile/lumki ^0.1.11 -> satisfiable by kineticamobile/lumki[v0.1.11].
  • kineticamobile/lumki v0.1.11 requires illuminate/support ~5|~6|~7|~8|~9 -> found illuminate/support[v5.0.0, ..., v5.8.36, v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.0] but these were not loaded, likely because it conflicts with another require.

Problems with Laravel 9

Hi, how we can integrate lumki into a Laravel 9 project?

Problem 1
- illuminate/support[v5.6.0, ..., 5.8.x-dev] require php ^7.1.3 -> your php version (8.0.13) does not satisfy that requirement.
- illuminate/support[v6.0.0, ..., v6.19.1] require php ^7.2 -> your php version (8.0.13) does not satisfy that requirement.
- illuminate/support[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.0.13) does not satisfy that requirement.
- illuminate/support[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.0.13) does not satisfy that requirement.
- Root composer.json requires kineticamobile/lumki ^0.1.10 -> satisfiable by kineticamobile/lumki[v0.1.10].
- Conclusion: don't install laravel/framework v9.0.0-beta.2 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.0-beta.3 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.0-beta.4 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.0-beta.5 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.0 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.1 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.2 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.1.0 (conflict analysis result)
- Conclusion: don't install laravel/framework v9.0.0-beta.1 (conflict analysis result)
- kineticamobile/lumki v0.1.10 requires illuminate/support ~5|~6|~7|~8 -> satisfiable by illuminate/support[v5.0.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev,
v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev].
- Only one of these can be installed: illuminate/support[v5.0.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev, v9.0.0-
beta.1, ..., 9.x-dev], laravel/framework[v9.0.0-beta.1, ..., 9.x-dev]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
- Root composer.json requires laravel/framework ^9.0 -> satisfiable by laravel/framework[v9.0.0-beta.1, ..., 9.x-dev].

You can also try re-running composer require with an explicit version constraint, e.g. "composer require kineticamobile/lumki:*" to figure out if any version
is installable, or "composer require kineticamobile/lumki:^2.1" if you know which you need.

Route [lumki.user.roles.edit] not defined Error

Hi,
I navigate to /lumki/users
I get

ErrorException
Route [lumki.user.roles.edit] not defined. (View: /var/www/html/vendor/kineticamobile/lumki/resources/views/users/index.blade.php)

Any clue?

New navigation menu file on Jetstream

On the new Jetstream version the navigation menu filename has changed to 'navigation-menu.blade.php'

Lumki::insertLineBefore(
        resource_path('views/navigation-dropdown.blade.php'),
        "@if (Laravel\Jetstream\Jetstream::hasApiFeatures())",
        "\n@lumki\n"
);

search

would you be interested in adding search capabilities?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.