Skip to content

Commit c2ebef6

Browse files
committed
WIP
1 parent 45f6e35 commit c2ebef6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/Providers/FormsProvider.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private function autoloadFields( $path, $classRoot )
125125
*/
126126
Hook::addFilter( 'ns.fields', function ( $identifier, $resource = null ) use ( $field, $params ) {
127127
if ( $identifier === $field::IDENTIFIER ) {
128-
$resolved = collect( $params )->each( function( $param ) use ( $resource, $field ) {
128+
$resolved = collect( $params )->map( function( $param ) use ( $resource, $field ) {
129129
$isBuiltin = $param[ 'isBuiltin' ];
130130

131131
/**
@@ -137,7 +137,10 @@ private function autoloadFields( $path, $classRoot )
137137
$model = $param[ 'type' ];
138138
$instance = $model::find( $resource );
139139

140-
if ( ! $instance instanceof $model ) {
140+
/**
141+
* if the param is not optional, we must have a valid instance.
142+
*/
143+
if ( ! $instance instanceof $model && ! $param[ 'isOptional' ] ) {
141144
throw new Exception( sprintf(
142145
__( 'Unable to resolve the dependency %s (%s) for the class %s' ),
143146
$resource,
@@ -151,7 +154,9 @@ private function autoloadFields( $path, $classRoot )
151154
return app()->make( $param[ 'type' ] );
152155
}
153156
}
154-
});
157+
158+
return false;
159+
})->filter();
155160

156161
/**
157162
* If no dependencies were resolved, we can create a new instance

tests/Traits/WithCustomerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ protected function attemptSearchCustomers()
329329
* Creating a first customer
330330
*/
331331
$email = $faker->email;
332-
$firstName = $faker->firstName;
332+
$firstName = $faker->firstName . Str::random( 5 );
333333
$lastName = $faker->lastName;
334334

335335
$response = $this->withSession( $this->app[ 'session' ]->all() )

0 commit comments

Comments
 (0)