IlCallo / laravel-permission

Associate users with roles and permissions, extension of
https://github.com/spatie/laravel-permission
MIT License
3 stars 1 forks source link

Do you plan to update this with latest spatie branch ? #2

Closed meanmachin3 closed 5 years ago

IlCallo commented 5 years ago

Hi, no I'm not planning to. I still hope they'll consider adding this feature to their official package but they repeatedly said they are not interested (even in PRs). This is a "divergent" branch which also have a different version numeration (I did not even changed the package name, you have to reference this repo directly to use this).

If you want to try to take this back in sync with the original package, feel free to PR, but I'm not planning to do it :)

meanmachin3 commented 5 years ago

I am new to php and laravel.

Do you mind sharing steps to add this package to current project ? I've tried adding repositories and referenced your package. Downgrade spatie package to 2.2.0 and did a composer update. It still refers to old package. Am I missing something ?

IlCallo commented 5 years ago

Because this package is not published on packagist register, you must register a private repo endpoint in your composer.json file.

You can find how to do it in composer documentation. I don't know if you also need to generate a GitHub token to add a custom repo, probably yes.

meanmachin3 commented 5 years ago

@IlCallo Thanks for all your response and help.

Yes, you were right, I had generate Github token and added this repo.

Whenever I try to publish a migration, I am unable to do so.

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

I tried running the above command, I cannot see any migration published. Should I add a migration file manually ?

Manually adding migration helped.

Class Spatie\Permission\Middlewares\RoleMiddleware does not exist

However, I get the following error.

Sorry for all trouble.

Many thanks for help !

IlCallo commented 5 years ago

No problem! Even if it seems strange that the migration command doesn't work

meanmachin3 commented 5 years ago

Hi @IlCallo

Sorry for bothering yet again, while trying to pass restrictable entity, I've noticed that it doesn't creates entry for that resource. Looks like I am missing something.

Do I need to implement Restrictable in to my resource like

class Project extends Model implements Restrictable

or do I need to add a trait ?

I've tried both ways and was successful in getting restrictable resource's id and table name, however whenever I try to give it permission, restrictable columns in model_has_permissions is empty.

Thanks for help in advance !

IlCallo commented 5 years ago

Hi, check out this for usage (you should implement Restrictable interface and you could use the already provided RestrictableTrait if it fits your needs).

To specify a restrictable model, you should pass it as second argument (eg. $user->assignRole('writer', $department))