Skip to content

Commit

Permalink
Add initial users seeder, fix for user namespace in user model factory
Browse files Browse the repository at this point in the history
  • Loading branch information
llaski committed Sep 7, 2018
1 parent a642b7f commit ef4d873
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 7 additions & 0 deletions src/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
});
}
Expand Down
16 changes: 16 additions & 0 deletions src/stubs/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call(UsersSeeder::class);
}
}
19 changes: 19 additions & 0 deletions src/stubs/seeds/UsersSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Database\Seeder;

class UsersSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(\App\Models\User::class)->create([
'name' => '{YOUR NAME}',
'email' => '{YOUR EMAIL}',
]);
}
}

0 comments on commit ef4d873

Please sign in to comment.