laravel / jetstream

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

Missing personal team on fresh install #1460

Closed miclaus closed 3 months ago

miclaus commented 3 months ago

Jetstream Version

5.0.0

Jetstream Stack

Inertia

Laravel Version

11.0.8

PHP Version

8.2.0

Database Driver & Version

No response

Description

When installing Jetstream (Inertia) with teams support, the example user created in DatabaseSeeder.php isn't created with a personal team which leads to a blank dashboard and the following error being logged to console for app.js when logging in with the test user test@example.com:

Error: Ziggy error: 'team' parameter is required for route 'teams.show'.

The following in DatabaseSeeder.php:

User::factory()->create([
    'name' => 'Test User',
    'email' => 'test@example.com',
]);

Should be:

User::factory()->withPersonalTeam()->create([
    'name' => 'Test User',
    'email' => 'test@example.com',
]);

Related issue: #1341

I'm open to do a PR.

Steps To Reproduce

  1. composer create-project laravel/laravel:^11.0 example-app
  2. composer require laravel/jetstream
  3. php artisan jetstream:install inertia --teams --ssr --dark (--ssr and --dark might not be the issue here)
  4. npm install
  5. npm run build
  6. php artisan migrate
  7. Serve application and log in with test user test@example.com:password

The dashboard is blank and error is logged in console.

driesvints commented 3 months ago

Hi there. This isn't a Jetstream issue. You need to add ->withPersonalTeam() manually.

miclaus commented 3 months ago

@driesvints Thanks!

What do you mean with "this isn't a Jetstream issue"? Jetstream introduces the Teams functionality, no? UserFactory::withPersonalTeam() is provided with Jetstream.

Currently anybody installing Jetstream (with teams support) on top of a fresh Laravel installation will inadvertently encounter this issue, leading to having to understand the error, google it, search GitHub issues, etc., basically individually having to figure out that ->withPersonalTeam() has to manually be added to the database seeder.

Since Jetstream should only be installed on new Laravel applications only, this issue could very easily be remedied by copying an already working DatabaseSeeder.php, which would include ->withPersonalTeam().

driesvints commented 3 months ago

@miclaus if you could send in a PR that adds it to the seeder without too many workarounds we could maybe consider it 👍