Comments (3)
Wow, this is great stuff. I like the PRs and will merge as soon as we resolve the issues that I commented upon.
from comments.
You could opt out of package discovery for this package and then write your own service provider by copying the package service provider, changing the gate checks and then registering that service provider in your config/app.php
.
I think that that should work.
P.S. This is the first thing that came to my mind. Maybe there is a simpler way of just overriding the gate check.
from comments.
I think a similar solution as well, but maybe using a Policy class and then define in config which one to use, will allow to override without duplicate code of ServiceProvider.
I make a pull request, if you want to check into.
-
I add new CommentPolicy.php
-
I updated ServiceProvider.php how is defined the permission, using:
// Define permission defined in config
$permissions = config('comments.permissions', [
'create-comment' => 'Laravelista\Comments\CommentPolicy@create',
'delete-comment' => 'Laravelista\Comments\CommentPolicy@delete',
'edit-comment' => 'Laravelista\Comments\CommentPolicy@update',
'reply-to-comment' => 'Laravelista\Comments\CommentPolicy@reply',
]);
foreach($permissions as $permission => $policy) {
Gate::define($permission, $policy);
}
- In config I added below which can be override by application:
'permissions' => [
'create-comment' => 'Laravelista\Comments\CommentPolicy@create',
'delete-comment' => 'Laravelista\Comments\CommentPolicy@delete',
'edit-comment' => 'Laravelista\Comments\CommentPolicy@update',
'reply-to-comment' => 'Laravelista\Comments\CommentPolicy@reply',
]
- I also added new permission for create-comment, which per default is true. So in controller
store
method I add$this->authorize('create-comment', Comment::class);
The rest is untouched so it should not break anything else.
from comments.
Related Issues (20)
- Call to a member function count() on null
- Argument Two passed HOT 9
- Call count on Null HOT 3
- On server not Working.. HOT 2
- Changes not detected in Blade File HOT 4
- Error installing for Laravel 7 HOT 1
- Latest Release Tag? HOT 1
- Argument 2 passed to Laravelista\Comments\CommentPolicy::reply() must be an instance of Laravelista\Comments\Comment HOT 1
- The edit/replay button not working
- Laravel 9.x Compatibility HOT 1
- ajax support HOT 1
- Reply for Guest Users HOT 1
- Spatie permission issues after upgrading to Laravel 9 HOT 2
- unable to install in laravel 9 HOT 7
- Loading all comments? HOT 1
- Call to a member function count() on null HOT 3
- Attempt to read property "comments" on string
- Section added after the comment block is not working -
- markdown styling is not working
- Laravel 9 doesn't support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from comments.