22
33namespace Moox \Draft \Database \Factories ;
44
5- use Moox \Draft \Models \Draft ;
65use Illuminate \Database \Eloquent \Factories \Factory ;
6+ use Moox \Draft \Models \Draft ;
77
88class DraftFactory extends Factory
99{
@@ -14,11 +14,11 @@ public function definition(): array
1414 return [
1515 // Base model attributes (non-translated)
1616 'is_active ' => $ this ->faker ->boolean (80 ),
17-
17+
1818 'image ' => [
1919 'url ' => $ this ->faker ->imageUrl (800 , 600 , 'business ' ),
2020 'alt ' => $ this ->faker ->sentence (4 ),
21- 'caption ' => $ this ->faker ->optional ()->sentence ()
21+ 'caption ' => $ this ->faker ->optional ()->sentence (),
2222 ],
2323 'type ' => $ this ->faker ->randomElement (['article ' , 'page ' , 'post ' , 'news ' , 'tutorial ' ]),
2424 'color ' => $ this ->faker ->hexColor (),
@@ -28,8 +28,8 @@ public function definition(): array
2828 'theme ' => $ this ->faker ->randomElement (['light ' , 'dark ' , 'auto ' ]),
2929 'layout ' => $ this ->faker ->randomElement (['grid ' , 'list ' , 'masonry ' ]),
3030 'show_author ' => $ this ->faker ->boolean (),
31- 'allow_comments ' => $ this ->faker ->boolean (70 )
32- ]
31+ 'allow_comments ' => $ this ->faker ->boolean (70 ),
32+ ],
3333 ];
3434 }
3535
@@ -50,7 +50,7 @@ public function configure()
5050 private function setTranslatedAttributes (Draft $ draft ): void
5151 {
5252 $ locales = $ this ->getLocales ();
53-
53+
5454 foreach ($ locales as $ locale ) {
5555 $ draft ->translateOrNew ($ locale )->fill ([
5656 'title ' => $ this ->getLocalizedTitle ($ locale ),
@@ -60,7 +60,7 @@ private function setTranslatedAttributes(Draft $draft): void
6060 'content ' => $ this ->getLocalizedContent ($ locale ),
6161 'author_id ' => $ this ->faker ->numberBetween (1 , 10 ),
6262 'author_type ' => 'Moox \\User \\Models \\User ' ,
63- 'translation_status ' => $ this ->faker ->randomElement (['draft ' , 'waiting ' , 'private ' , 'scheduled ' , 'published ' , 'not_translated ' , 'deleted ' ])
63+ 'translation_status ' => $ this ->faker ->randomElement (['draft ' , 'waiting ' , 'private ' , 'scheduled ' , 'published ' , 'not_translated ' , 'deleted ' ]),
6464
6565 ]);
6666 }
@@ -72,11 +72,11 @@ private function setTranslatedAttributes(Draft $draft): void
7272 private function getLocales (): array
7373 {
7474 $ locales = ['en ' ]; // Always create English
75-
76- $ locales [] = 'de ' ;
77- $ locales [] = 'fr ' ;
78- $ locales [] = 'es ' ;
79-
75+
76+ $ locales [] = 'de ' ;
77+ $ locales [] = 'fr ' ;
78+ $ locales [] = 'es ' ;
79+
8080 return $ locales ;
8181 }
8282
@@ -87,9 +87,9 @@ private function getLocalizedTitle(string $locale): string
8787 {
8888 $ titles = [
8989 'en ' => $ this ->faker ->sentence (rand (3 , 8 )),
90- 'de ' => $ this ->faker ->sentence (rand (3 , 8 )) . ' (Deutsch) ' ,
91- 'fr ' => $ this ->faker ->sentence (rand (3 , 8 )) . ' (Français) ' ,
92- 'es ' => $ this ->faker ->sentence (rand (3 , 8 )) . ' (Español) ' ,
90+ 'de ' => $ this ->faker ->sentence (rand (3 , 8 )). ' (Deutsch) ' ,
91+ 'fr ' => $ this ->faker ->sentence (rand (3 , 8 )). ' (Français) ' ,
92+ 'es ' => $ this ->faker ->sentence (rand (3 , 8 )). ' (Español) ' ,
9393 ];
9494
9595 return $ titles [$ locale ] ?? $ titles ['en ' ];
@@ -101,7 +101,8 @@ private function getLocalizedTitle(string $locale): string
101101 private function getLocalizedSlug (string $ locale ): string
102102 {
103103 $ baseSlug = $ this ->faker ->slug (3 );
104- return $ baseSlug . '- ' . $ locale ;
104+
105+ return $ baseSlug .'- ' .$ locale ;
105106 }
106107
107108 /**
@@ -111,9 +112,9 @@ private function getLocalizedDescription(string $locale): string
111112 {
112113 $ descriptions = [
113114 'en ' => $ this ->faker ->paragraph (2 ),
114- 'de ' => $ this ->faker ->paragraph (2 ) . ' (Deutsche Beschreibung) ' ,
115- 'fr ' => $ this ->faker ->paragraph (2 ) . ' (Description française) ' ,
116- 'es ' => $ this ->faker ->paragraph (2 ) . ' (Descripción española) ' ,
115+ 'de ' => $ this ->faker ->paragraph (2 ). ' (Deutsche Beschreibung) ' ,
116+ 'fr ' => $ this ->faker ->paragraph (2 ). ' (Description française) ' ,
117+ 'es ' => $ this ->faker ->paragraph (2 ). ' (Descripción española) ' ,
117118 ];
118119
119120 return $ descriptions [$ locale ] ?? $ descriptions ['en ' ];
@@ -125,14 +126,14 @@ private function getLocalizedDescription(string $locale): string
125126 private function getLocalizedContent (string $ locale ): string
126127 {
127128 $ content = $ this ->faker ->paragraphs (rand (3 , 8 ), true );
128-
129+
129130 $ localizedSuffix = [
130131 'de ' => ' (Deutscher Inhalt) ' ,
131132 'fr ' => ' (Contenu français) ' ,
132133 'es ' => ' (Contenido español) ' ,
133134 ];
134135
135- return $ content . ($ localizedSuffix [$ locale ] ?? '' );
136+ return $ content. ($ localizedSuffix [$ locale ] ?? '' );
136137 }
137138
138139 /**
@@ -179,7 +180,7 @@ public function withLocales(array $locales): static
179180 return $ this ->afterMaking (function (Draft $ draft ) use ($ locales ) {
180181 // Clear existing translations
181182 $ draft ->deleteTranslations ();
182-
183+
183184 // Create only specified locales
184185 foreach ($ locales as $ locale ) {
185186 $ draft ->translateOrNew ($ locale )->fill ([
@@ -190,7 +191,7 @@ public function withLocales(array $locales): static
190191 'content ' => $ this ->getLocalizedContent ($ locale ),
191192 'author_id ' => $ this ->faker ->numberBetween (1 , 10 ),
192193 'author_type ' => 'Moox \\User \\Models \\User ' ,
193- 'translation_status ' => $ this ->faker ->randomElement (['draft ' , 'waiting ' , 'private ' , 'scheduled ' , 'published ' , 'not_translated ' , 'deleted ' ])
194+ 'translation_status ' => $ this ->faker ->randomElement (['draft ' , 'waiting ' , 'private ' , 'scheduled ' , 'published ' , 'not_translated ' , 'deleted ' ]),
194195 ]);
195196 }
196197 });
@@ -219,4 +220,4 @@ public function multilingual(): static
219220 {
220221 return $ this ->withLocales (['en ' , 'de ' , 'fr ' , 'es ' ]);
221222 }
222- }
223+ }
0 commit comments