Giorgione
Giorgione

Reputation: 37

LARAVEL 7.0 Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, array given

FULL-ERROR IS:

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, array given, called in C:\laravel\deliver-boo\vendor\laravel\ui\auth-backend\RegistersUsers.php on line 41

enter image description here

The idea is creating an app for deliveries, so in this case the user( which should be the restaurant in real word) register itself to the app and add all his restaurant information( like VAT etc.)

What I basically did is modifying the Laravel standard User registration form so it can get extra fields and send it to the table into the database. The Users table has also a many to many relationship with the table Categories, the idea is that the user( restaurant) can register himself and also his associated categories( vegan, vegetarian, Italian..) in the same form.

(SOME FIELDS HAS BEEN HIDEN FOR MAKING THIS SCREENSHOT MORE VISIBLE).

P.S. I know that for selecting more than one value I should use checkboxes instead of the select, it's just a temporary solution.

enter image description here

In the code, inside the RegisterController.php, I'm creating a new User at line 84, and trying to attach the category to the pivot table category_user at line 104, then return the user.

enter image description here

To implement the possibility of selecting a category I had to modify the RegistersUser.php, at line 9 I'm passing the Category model, then inside the showRegistrationForm() I'm passing all the categories at line 25 and return it to the register.blade.php view.

Now, the error generates because something with the function at line 42 goes wrong, this function should be responsible for authentication( NOT SURE).

enter image description here

Anyway every data is going correctly to the db, inside the tables and the relationship is generated inside the pivot table user_category as well, but instead of automatically login the new user Laravel generates the error.

Upvotes: -3

Views: 1422

Answers (1)

Giorgione
Giorgione

Reputation: 37

Error was at line 106, compact('new_user') was returning the array, you have to return $new_user instead and everything will work correctly.

Upvotes: 1

Related Questions