serenysoft / nova-permissions

Laravel Nova 4 Roles & Permissions
72 stars 25 forks source link

Seeder JSON Generator #24

Closed beshoo closed 1 year ago

beshoo commented 1 year ago

I wanted to start by expressing my sincere appreciation for your plugin - it has been an indispensable tool for me and has saved me a tremendous amount of time. The policy method in particular is simply outstanding!

I have been using your plugin to develop websites locally and have come up with an idea that I believe could make it even more powerful. I have noticed that when we create policies locally, we sometimes need to add additional policies that are not available in the seeder. While we can assign permissions to the module, it can be a time-consuming process. image

I was thinking that it would be incredibly useful if your plugin had a seeder generator that would allow us to create all the necessary roles and permissions through the plugin interface. Then, when we need to move to the production server, we could simply generate a JSON file that contains all the permissions in the database. Your seeder could have an option to read this JSON file and automatically set up the roles and permissions on the production server.

I believe that this feature would make your plugin even more valuable and would be a game-changer for developers like me who are looking for a seamless and efficient way to manage roles and permissions. I hope you will consider adding this feature to your plugin.

Thank you for your time and for creating such a fantastic tool. I look forward to hearing your thoughts on this idea.

Best regards,

leandrogehlen commented 1 year ago

Thanks for your comments.

i'm not sure about it. The permission seed is very particular proccess and depends the application, and this procces can be complex.

I believe that using commands you can create your way to seed permissions on deploy.

beshoo commented 1 year ago

Thank you for your prompt response.

I understand that the permission seeding process can be complex and specific to each application. However, what I had in mind was a feature that would allow us to export the permissions data in a JSON format so that we could easily import it into the production server.

I was thinking that your plugin could provide a user-friendly interface to generate the JSON file, which would contain all the necessary roles and permissions, and then have the option to import this file into the production server so that the roles and permissions can be easily set up without having to manually add each one.

I hope this clarifies my idea and how it could be a valuable addition to your plugin. Please let me know if you have any further questions or concerns.

leandrogehlen commented 1 year ago

For this you can use csv export and The follow library

https://github.com/simonhamp/laravel-nova-csv-import

beshoo commented 1 year ago

But how to export at first places?

leandrogehlen commented 1 year ago

https://nova.laravel.com/docs/4.0/resources/#csv-export

leandrogehlen commented 1 year ago

Can I close this issue?

beshoo commented 1 year ago

Sure ... Thank you so much , you are the best

On Mon, Jun 26, 2023 at 1:17 PM Leandro Gehlen @.***> wrote:

Can I close this issue?

— Reply to this email directly, view it on GitHub https://github.com/serenysoft/nova-permissions/issues/24#issuecomment-1607156526, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDLT24KRQFMHB4PD3GXDDDXNFOTPANCNFSM6AAAAAAZTERQFM . You are receiving this because you authored the thread.Message ID: @.***>

beshoo commented 1 year ago

Dear @leandrogehlen If i want to add an action to this plugin resource, such as https://github.com/SpartnerNL/Laravel-Nova-Excel which will help me to export to Excel. how to , since there is no resource page!

beshoo commented 1 year ago

I tried to add it to the extended role page since it is a resource page!. but it's not working!


<?php

namespace App\Nova;

use Laravel\Nova\Http\Requests\NovaRequest;
use Sereny\NovaPermissions\Nova\Role as BaseRole;
use Laravel\Nova\Actions\ExportAsCsv;
class Role extends BaseRole
{
    /**
     * Indicates whether Nova should check for modifications between viewing and updating a resource.
     *
     * @var bool
     */
    public static $trafficCop = false;

    public function actions(NovaRequest $request)
    {
        return [
            ExportAsCsv::make(),
        ];
    }
}
beshoo commented 1 year ago

SOLVED


<?php

namespace App\Nova;

use Laravel\Nova\Http\Requests\NovaRequest;
use Sereny\NovaPermissions\Nova\Role as BaseRole;
use Laravel\Nova\Actions\ExportAsCsv;
class Role extends BaseRole
{
    /**
     * Indicates whether Nova should check for modifications between viewing and updating a resource.
     *
     * @var bool
     */
    public static $trafficCop = false;

    /**
     * Get the actions available for the resource.
     *
     * @param \Laravel\Nova\Http\Requests\NovaRequest $request
     * @return array
     */
    public function actions(NovaRequest $request)
    {
        return [
            ExportAsCsv::make(),
        ];
    }
}