need some help about Laravel user auth. my knowledge about Laravel is very little, my experiences were deploying web app based on raw/pure PHP (never have experience with the framework).
The idea is to let an operator input the first and only one user to the system through the Laravel standard registration process, and this user will automatically become Super-User.
The super-user function is to manage normal-user registration (inside super-user session), by creating user & password and define the role of the normal-users.
I define the user's table like this, I add 'user_role' column to distinguished roles between users.
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->char('user_role')->nullable();
$table->rememberToken();
$table->timestamps();
});
'user_role' value for super-user must be 0, while another normal-users role should be numbers between 1-9.
content/views of each section of the webpage will be displayed depends on the 'user_role' value.
need help how to :
- display
user-registration page/url
if none users defined in the user's table. - I need check 'user_role' every time I need to display a section of the page. how to achieve it?
From your table structure i assume you manage roles within users table. Now when you want to allow a specific role user for some part, just check the role of the user.
In blade template you can check in the following way.
To show registration form if there is no user in the table. In your blade you can select data from users table and then check if users table is empty.