creating Multiple Authentication Laravel 5.5 - laravel-5

I plan to develop a system that has three two types (admin, users). I want to have each user types information stored in a separate table for easy access and to reduce the number of blank fields (if they were all in one table).
i need all users login in the same login form not separated form for each one of them

Related

Laravel multi-auth different table for admin and user but one login page

Is it possible to have two different tables for users and admin but one login page? I already used middleware and Spatie permission, but I need them to separate because some info doesn't match if they are together in one table.
For example:
Admin needs name, employee number. At the same time, users need a name, address, student number, etc.
I need suggestions on how to do that to study it.

Automated tests with Laravel

I am new to PHP laravel framework.
My application is very basic:
User first log-in with login and password (html form)
The user can add items in a mysql table. This are numeric values. There are 2 controllers: One to see all rows and another to add/edit row
Another Controller computes statistics (sum, average, etc.) on the numeric values stored in the table.
What i want do to is to test this application.
I want to write a test that:
Creates an empty database
Creates a user
Log-in this user on my application
Creates entries in my table throw my application (not directly in mysql)
Check in the listing page if each entry has been created properly
And i want to check if the statistics are good (check good values displayed on the webpage.
I have read about Testing section on Laravel's website documentation.
Here are my questions:
I do not se how i can automated database initialization
I do not see how i can check if a span or div contains a specific value (i only can test http response code and if webpage contains a given string).
I have worked with phpunit.
Thanks a lot

Should I have different tables for different user types

I'm creating an app in blade, where I need two different user types. (Landlord and tenant).
I'm currently using the laravel auth, and I have a dropdown menu which lets a user select there type upon registration. I need the users to interact with eachother.
Should I have seperate models for the landlord, and the tenant.
Why use a different table? Just use a userType column and you're good! If you do go with two table structure, you will have to manage two different structure and need all your logics done twice...

Laravel authorization via email, password and additional field

Out of the box Laravel authorizes users by matching email (default - can be overridden) and password.
Is it possible to authorize user using 3 fields, e.g:
email
password
group
... where 'group' is some additional field from 'users' database.
In other words, user can belong to group:1 and can login to group:1 resources only, but not to group:2 using his group:1 credentials.
If user belongs to group:1 and group:2, then he needs different credentials to login to either group.
Additionally, user can use same email for both groups. In such case it is group number that would act as additional identifier. And of course passwords would be different.
I am thinking setting a database multiple column index on fields 'id' and 'group' would be a good start, but I fail to grasp (yet), what would be required to make Laravel authorization process sensitive to 3 fields, instead of 2.
I would appreciate some pointers.
This sounds like you're trying to achieve a form of tenancy on data belonging to certain groups only. Have a look at this package:
https://github.com/HipsterJazzbo/Landlord
In essence, you would add a group_id field to the tables where you wish to restrict access and then using middleware, apply an additional where('group_id', Auth::user()->group_id) clause to any database queries. This works very well for retrieving subsets of data belonging to specific users by their role, for example.

Custom login in laravel with single table

As i searched a lot to create the custom multi auth in laravel on single table for different different user (i.e Customer,Shopkeeper,Admin,Delivery Executives). and this is done on single table i.e. user_table which contain a column name user_type which will hold that what type of user is that, as i need to do like this because existing system was developed in PHP and having same schema but i want to upgrade to laravel so i stuck up in the very first step.
But i searched then found to create multiple tables like admin,customer and etc but for this i have to alter my current database which i dont need.
So, any one help me out how to do it exactly.

Resources