-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update database seeder depending on environment
- Loading branch information
Showing
7 changed files
with
90 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Seeder; | ||
|
||
class InitializationSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
factory(\App\Models\User::class)->create([ | ||
'name' => 'Miles Peng', | ||
'email' => '[email protected]', | ||
'password' => bcrypt('indigo') | ||
]); | ||
|
||
factory(\App\Models\Category::class)->create([ | ||
'name' => 'Uncategorized', | ||
'description' => 'Default category', | ||
'slug' => 'uncategorized' | ||
]); | ||
|
||
factory(\App\Models\Page::class)->create([ | ||
'title' => 'About', | ||
'slug' => 'about', | ||
'description' => null, | ||
'user_id' => \App\Models\User::first()->id, | ||
'content_id' => factory(\App\Models\Content::class)->create([ | ||
'body' => "## This is the about page." | ||
])->id, | ||
'view_count' => 0, | ||
'is_draft' => false, | ||
'deleted_at' => null | ||
]); | ||
|
||
factory(\App\Models\Page::class)->create([ | ||
'title' => 'Links', | ||
'slug' => 'links', | ||
'description' => null, | ||
'user_id' => \App\Models\User::first()->id, | ||
'content_id' => factory(\App\Models\Content::class)->create([ | ||
'body' => "## This is the links page." | ||
])->id, | ||
'view_count' => 0, | ||
'is_draft' => false, | ||
'deleted_at' => null | ||
]); | ||
|
||
factory(\App\Models\Setting::class)->create([ | ||
'key' => 'title', | ||
'value' => "Miles' Blog", | ||
'tag' => 'website' | ||
]); | ||
|
||
factory(\App\Models\Setting::class)->create([ | ||
'key' => 'keywords', | ||
'value' => 'miles,milespong,laravel,blog', | ||
'tag' => 'seo' | ||
]); | ||
|
||
factory(\App\Models\Setting::class)->create([ | ||
'key' => 'description', | ||
'value' => 'A blog built with laravel by Miles', | ||
'tag' => 'seo' | ||
]); | ||
|
||
factory(\App\Models\Setting::class)->create([ | ||
'key' => 'heading', | ||
'value' => 'Just Keep Learning', | ||
'tag' => 'website' | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,6 @@ class UsersTableSeeder extends Seeder | |
*/ | ||
public function run() | ||
{ | ||
factory(\App\Models\User::class)->create([ | ||
'name' => 'Miles Peng', | ||
'email' => '[email protected]', | ||
'password' => bcrypt('123123') | ||
]); | ||
|
||
factory(\App\Models\User::class, 10)->create()->each(function ($user) { | ||
$user->roles()->sync(\App\Models\Role::all()->random(rand(1, \App\Models\Role::count()))); | ||
}); | ||
|