File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ $ factory ->define(Chrisjk123 \Blogger \Tag::class, function (Faker $ faker ) {
4
+ $ noteable = [
5
+ App \Complex::class,
6
+ ];
7
+ $ noteableType = $ faker ->randomElement ($ noteables );
8
+ $ noteable = factory ($ noteableType )->create ();
9
+
10
+ return [
11
+ 'noteable_type ' => $ noteableType ,
12
+ 'noteable_id ' => $ noteable ->id ,
13
+ . ..
14
+ ];
15
+ });
16
+
17
+ $ factory ->define (Chrisjk123 \Blogger \Category::class, function (Faker $ faker ) {
18
+ $ title = $ faker ->name ;
19
+
20
+ return [
21
+ 'title ' => $ title ,
22
+ 'slug ' => str_slug ($ title ),
23
+ 'parent_id ' => null ,
24
+ ];
25
+ });
26
+
27
+ $ factory ->define (Chrisjk123 \Blogger \Post::class, function (Faker \Generator $ faker ) {
28
+ $ title = $ faker ->name ;
29
+
30
+ return [
31
+ 'title ' => $ title ,
32
+ 'slug ' => str_slug ($ title ),
33
+ 'excerpt ' => $ faker ->name ,
34
+ 'content ' => $ faker ->paragraph ,
35
+ 'category_id ' => factory ('Chrisjk123\Blogger\Category ' )->create ()->id ,
36
+ ];
37
+ });
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /** @var \Illuminate\Database\Eloquent\Factory $factory */
4
+ use App \User ;
5
+ use Faker \Generator as Faker ;
6
+ use Illuminate \Support \Str ;
7
+
8
+ /*
9
+ |--------------------------------------------------------------------------
10
+ | Model Factories
11
+ |--------------------------------------------------------------------------
12
+ |
13
+ | This directory should contain each of the model factory definitions for
14
+ | your application. Factories provide a convenient way to generate new
15
+ | model instances for testing / seeding your application's database.
16
+ |
17
+ */
18
+
19
+ $ factory ->define (User::class, function (Faker $ faker ) {
20
+ return [
21
+ 'name ' => $ faker ->name ,
22
+ 'email ' => $ faker ->unique ()->safeEmail ,
23
+ 'email_verified_at ' => now (),
24
+ 'password ' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi ' , // password
25
+ 'remember_token ' => Str::random (10 ),
26
+ ];
27
+ });
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public function up()
15
15
{
16
16
Schema::create ('categories ' , function (Blueprint $ table ) {
17
17
$ table ->increments ('id ' );
18
- $ table ->string ('name ' );
18
+ $ table ->string ('title ' );
19
19
$ table ->string ('slug ' )->nullable ();
20
20
$ table ->index ('parent_id ' );
21
21
$ table ->timestamps ();
You can’t perform that action at this time.
0 commit comments