laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.95k stars 809 forks source link

Cannot find id of non object #238

Closed rhaider-dev closed 4 years ago

rhaider-dev commented 4 years ago

Description:

Produces error when I login to dahsboard.

Steps To Reproduce:

  1. Create a user using api.
  2. Login with new created user
  3. Showing error of id

When I modify user database and give a value in 'current_team_id', the error resolves. Capture

howlowck commented 4 years ago

I ran into the same issue.

Here are my repro steps:

  1. Cloned the latest Laravel
  2. composer require laravel/jetstream
  3. Installed Jetstream by running artisan jetstream:install inertia --teams
  4. Registered a user
  5. uncommented Features::teams(), in config/jetstream.php

The issue is for some reason the install script didn't copy the correct stub over to app/Actions/Fortify/CreateNewUser.php. It should have copied the CreateNewUserWithTeams stub overwriting the previous stub, but didn't.

Anyway, TL/DR, you can do the following to fix the issue:

  1. Delete the existing user (optional)
  2. Copy the content of the CreateNewUserWithTeams stub into your app/Actions/Fortify/CreateNewUser.php
  3. create a new user
  4. log in with the new user

Hope this helps.

It's weird that it does seems like some of the operations like Line 399 in the InstallCommand didn't work, since I had to uncomment the line out myself, but other copy operations did work (besides Line 422.

I'm running PHP 7.4

driesvints commented 4 years ago

Create a user using api.

@rhaider-dev please explain how you did this.

@howlowck you need to use the Laravel installer to properly run the install procedure, not just clone the skeleton.

driesvints commented 4 years ago

@rhaider-dev I'm thinking you only created a user record and not a personal team for a user. Each user needs a personal team record that's linked to the user.

driesvints commented 4 years ago

Also see: https://jetstream.laravel.com/1.x/features/teams.html

By default, every registered user will belong to a "Personal" team.