From ef4d873d568d41c08113ebc709326421a8d2f0ec Mon Sep 17 00:00:00 2001 From: Larry Laski Date: Fri, 7 Sep 2018 19:21:12 -0400 Subject: [PATCH] Add initial users seeder, fix for user namespace in user model factory --- README.md | 2 +- src/Preset.php | 7 +++++++ src/stubs/seeds/DatabaseSeeder.php | 16 ++++++++++++++++ src/stubs/seeds/UsersSeeder.php | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/stubs/seeds/DatabaseSeeder.php create mode 100644 src/stubs/seeds/UsersSeeder.php diff --git a/README.md b/README.md index c034b0d..7200679 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ _Inspired by [Adam Wathan](https://github.com/adamwathan/laravel-preset) among o + Adds `assertContains`, `assertNotContains` and `assertEquals` assertion methods for Eloquent Collections + Adds `weh` method - short for `withoutExceptionHandling` directly on `TestCase` + Sets rounds for bcrypt driver to 2 instead of the default of 10 to speed up tests - +- Adds initial UsersSeeder (Add your own name and email here) ### Supports: diff --git a/src/Preset.php b/src/Preset.php index 8652d86..4a65f7d 100644 --- a/src/Preset.php +++ b/src/Preset.php @@ -217,6 +217,13 @@ protected static function setUpModelsFolder() $contents = str_replace('App\User', 'App\Models\User', $contents); $files->put($file, $contents); }); + + //Update all references to App\User within your database directory + collect(self::globRecursive(database_path('*.php')))->each(function ($file) use ($files) { + $contents = $files->get($file); + $contents = str_replace('App\User', 'App\Models\User', $contents); + $files->put($file, $contents); + }); } }); } diff --git a/src/stubs/seeds/DatabaseSeeder.php b/src/stubs/seeds/DatabaseSeeder.php new file mode 100644 index 0000000..95ccc8e --- /dev/null +++ b/src/stubs/seeds/DatabaseSeeder.php @@ -0,0 +1,16 @@ +call(UsersSeeder::class); + } +} diff --git a/src/stubs/seeds/UsersSeeder.php b/src/stubs/seeds/UsersSeeder.php new file mode 100644 index 0000000..b8f6cd0 --- /dev/null +++ b/src/stubs/seeds/UsersSeeder.php @@ -0,0 +1,19 @@ +create([ + 'name' => '{YOUR NAME}', + 'email' => '{YOUR EMAIL}', + ]); + } +}