Conversation
| __DIR__.'/../config/rapidez/statamic.php' => config_path('rapidez/statamic.php'), | ||
| ], 'config'); | ||
|
|
||
| if (!class_exists('\App\Models\User::class') && $userModel = $this->prepareUserModel()) { |
There was a problem hiding this comment.
Doesn't this always place a user model in your storage directory? Even when not publishing? Maybe the publishing functionality is not exactly the way to go here, because we can also just use the User model from the module, doesn't that work too?
There was a problem hiding this comment.
Yes i agree, this was not the way to go.
Changed it so that it's loaded from the module now!
| config(['auth.providers.users.model' => User::class]); | ||
| } | ||
|
|
||
| if (!Schema::hasTable('users') && !file_exists(database_path('migrations/0001_01_01_000000_create_users_table.php'))) { |
There was a problem hiding this comment.
You don't want to have database actions within the service provider as this runs even when you didn't have this setup yet for example with composer
There was a problem hiding this comment.
Removed the hasTable check, it's not really needed for this anyways. Checking if the migration file exists is enough.
royduin
left a comment
There was a problem hiding this comment.
What about these steps? https://statamic.dev/tips/storing-users-in-a-database#in-an-existing-laravel-app, do we also need to do something with that here?
There was a problem hiding this comment.
Instead keeping a copy within this repo we could get the content from https://github.com/laravel/laravel/blob/11.x/database/migrations/0001_01_01_000000_create_users_table.php? Maybe just a file_get_contents() on the publish?
Changed this around to get a copy from the repo instead.
These steps are in the docs at this moment, only doing this automatically right now because the user model + migration is needed for the install of this addon. |
|
Conflicts |
| $userTable = file_get_contents('https://raw.githubusercontent.com/laravel/laravel/refs/heads/11.x/database/migrations/0001_01_01_000000_create_users_table.php'); | ||
|
|
||
| if (!$userTable) { | ||
| throw new Exception('Failed to download the migration file.'); |
There was a problem hiding this comment.
So if laravel moves this file, we'll get exceptions on every production site that includes this code? 😲
There was a problem hiding this comment.
No, as this will be caught and logged in the catch.
Also will only happen if there is no existing migration, which should never be on a production environment.
|
I'm not really sure about this PR, downloading from a boot method; having the user model within here as fallback. Maybe we've to talk this through later. |
Agreed |
|
Closing in favor of #111 |
The added User model is the complete User model with the Statamic changes added to it as well.