Hello,
I am absolutly new to Laravel and I found this Spark project.
Sparks seams like a good choise to develop a site that has different user access to different pages and content.
Is there support to create different user roles out of the box when using Spark.
Say developing a news site with subscribers to different types of news and admins that have access to different admin roles.
I only saw one mention of this type of thing in the documentation.
Route::get('/dev', ['middleware' => 'dev', function () {
//
}]);
Using middleware and hardcoding the "dev" role.
Is there some support to do this from database relations and add new roles more like you do in Drupal?
I am a beginner so I might have missed the whole purpose of Spark.
So a Spark team is equivalent to a user role?
And you set up teams in code rather than in a database table?
Team GoldMember (Access all member resources)
Team SilverMember (Access some member resources)
Team Author (Access ability to write articles)
Team Publisher (Access ability to publish authors articles)
Team SuperUser (Access everything)
And if I want to change the names for the teams or the access for a specific team I have to change it in code on the specific page or pages?
And if I would like to add some database support to handle this I have to extend Spark to do that because Spark do not support it straight out of the box just yet?
Like laravel support database models views and controllers to handle login and registrations.
Spark is just a framework to handle the "boring" aspects of your app - billing, subscriptions, support, settings and such. You can extend it in any way you see fit, or replace any functions of it you don't feel suits your needs. If you wanted to add a "role" column to the users table via a migration, you can then access the role property like this:
Important!!!
The roles you reference are roles ON A SPECIFIC team in spark (that's why they are in the team section). They are meant to organize the team internal abilities and permission NOT the sidewide roles.
I would not use the for the use case you described. Search for ACL here on laracasts, that's a good start.
Just to be clear, most of the answers supplied so far is about the "role on a team" in Spark. Additional ACL roles can be added and applied to the users separately from Spark's roles.
One problem I have with the Spark roles implementation is that it supports just ONE role for each team member. To me, that's not a role; it's a user attribute that defines what a user is (within a team), and not what a user can do. If the team_users table did not have a unique compound index on the team_id and user_id columns, then support for multiple roles could be implemented. Not supporting multiple roles per user is a big oversight IMO when it comes to implementing applications to support real-world situations.
An ACL package such as Silber\Bouncer will support multiple roles and permissions for users that can be applied differently to each team very nicely.