@@ -40,17 +40,17 @@ protected function generateSeparateClass(): string
4040 {
4141 if (!$ this ->classExists ('models ' , $ this ->model )) {
4242 $ this ->throwFailureException (
43- ClassNotExistsException::class,
44- "Cannot create {$ this ->model }Factory cause {$ this ->model } Model does not exists. " ,
45- "Create a {$ this ->model } Model by itself or run command 'php artisan make:entity {$ this ->model } --only-model'. "
43+ exceptionClass: ClassNotExistsException::class,
44+ failureMessage: "Cannot create {$ this ->model }Factory cause {$ this ->model } Model does not exists. " ,
45+ recommendedMessage: "Create a {$ this ->model } Model by itself or run command 'php artisan make:entity {$ this ->model } --only-model'. "
4646 );
4747 }
4848
4949 if ($ this ->classExists ('factory ' , "{$ this ->model }Factory " )) {
5050 $ this ->throwFailureException (
51- ClassAlreadyExistsException::class,
52- "Cannot create {$ this ->model }Factory cause {$ this ->model }Factory already exists. " ,
53- "Remove {$ this ->model }Factory. "
51+ exceptionClass: ClassAlreadyExistsException::class,
52+ failureMessage: "Cannot create {$ this ->model }Factory cause {$ this ->model }Factory already exists. " ,
53+ recommendedMessage: "Remove {$ this ->model }Factory. "
5454 );
5555 }
5656
@@ -125,13 +125,13 @@ protected function checkExistRelatedModelsFactories(): bool
125125
126126 foreach ($ relatedModels as $ relatedModel ) {
127127 $ relatedFactoryClass = "{$ modelNamespace }\\$ relatedModel::class " ;
128- $ existModelFactory = ( strpos ( $ modelFactoryContent , $ relatedFactoryClass) !== false );
128+ $ existModelFactory = Str:: contains ( $ modelFactoryContent , $ relatedFactoryClass );
129129
130130 if (!$ existModelFactory ) {
131131 $ this ->throwFailureException (
132- ModelFactoryNotFoundedException::class,
133- "Not found {$ relatedModel } factory for {$ relatedModel } model in ' {$ this ->paths ['factory ' ]}. " ,
134- "Please declare a factory for {$ relatedModel } model on ' {$ this ->paths ['factory ' ]}' "
132+ exceptionClass: ModelFactoryNotFoundedException::class,
133+ failureMessage: "Not found {$ relatedModel } factory for {$ relatedModel } model in ' {$ this ->paths ['factory ' ]}. " ,
134+ recommendedMessage: "Please declare a factory for {$ relatedModel } model on ' {$ this ->paths ['factory ' ]}' "
135135 . "path and run your command with option '--only-tests'. "
136136 );
137137 }
@@ -173,9 +173,9 @@ protected function prepareRelatedFactories(): void
173173
174174 if (!Str::contains ($ modelFactoryContent , $ this ->getModelClass ($ relation ))) {
175175 $ this ->throwFailureException (
176- ModelFactoryNotFound::class,
177- "Model factory for model {$ relation } not found. " ,
178- "Please create it and after thar you can run this command with flag '--only-tests'. "
176+ exceptionClass: ModelFactoryNotFound::class,
177+ failureMessage: "Model factory for model {$ relation } not found. " ,
178+ recommendedMessage: "Please create it and after thar you can run this command with flag '--only-tests'. "
179179 );
180180 }
181181
@@ -224,7 +224,7 @@ protected function checkExistModelFactory(): bool
224224 $ modelNamespace = $ this ->getOrCreateNamespace ('models ' );
225225 $ factoryClass = "{$ modelNamespace }\\$ this ->model ::class " ;
226226
227- return ( strpos ( $ modelFactoryContent , $ factoryClass) !== false );
227+ return Str:: contains ( $ modelFactoryContent , $ factoryClass );
228228 }
229229
230230 protected function prepareFields (): array
@@ -233,11 +233,9 @@ protected function prepareFields(): array
233233
234234 foreach ($ this ->fields as $ type => $ fields ) {
235235 foreach ($ fields as $ field ) {
236- $ explodedType = explode ('- ' , $ type );
237-
238236 $ result [] = [
239237 'name ' => $ field ,
240- 'type ' => head ( $ explodedType )
238+ 'type ' => Str:: before ( $ type , ' - ' ),
241239 ];
242240 }
243241 }
@@ -275,9 +273,10 @@ protected function getModelClassContent($model): string
275273
276274 if (!$ this ->classExists ('models ' , $ model )) {
277275 $ this ->throwFailureException (
278- ClassNotExistsException::class,
279- "Cannot get {$ model } Model class content cause {$ model } Model does not exists. " ,
280- "Create a {$ model } Model by itself or run command 'php artisan make:entity {$ model } --only-model'. "
276+ exceptionClass: ClassNotExistsException::class,
277+ failureMessage: "Cannot get {$ model } Model class content cause {$ model } Model does not exists. " ,
278+ recommendedMessage: "Create a {$ model } Model by itself or run command "
279+ . "'php artisan make:entity {$ model } --only-model'. "
281280 );
282281 }
283282
0 commit comments