@@ -323,9 +323,9 @@ public function each($attribute, $rules)
323
323
*/
324
324
protected function initializeAttributeOnData ($ attribute )
325
325
{
326
- $ explicitAddress = $ this ->getExplicitAddress ($ attribute );
326
+ $ explicitPath = $ this ->getLeadingExplicitAttributePath ($ attribute );
327
327
328
- $ data = $ this ->extractData ( $ explicitAddress );
328
+ $ data = $ this ->extractDataFromPath ( $ explicitPath );
329
329
330
330
if (! Str::contains ($ attribute , '* ' ) || Str::endsWith ($ attribute , '* ' )) {
331
331
return $ data ;
@@ -895,9 +895,9 @@ protected function validateInArray($attribute, $value, $parameters)
895
895
{
896
896
$ this ->requireParameterCount (1 , $ parameters , 'in_array ' );
897
897
898
- $ explicitAddress = $ this ->getExplicitAddress ($ parameters [0 ]);
898
+ $ explicitPath = $ this ->getLeadingExplicitAttributePath ($ parameters [0 ]);
899
899
900
- $ attributeData = $ this ->extractData ( $ explicitAddress );
900
+ $ attributeData = $ this ->extractDataFromPath ( $ explicitPath );
901
901
902
902
$ otherValues = Arr::where (Arr::dot ($ attributeData ), function ($ key ) use ($ parameters ) {
903
903
return Str::is ($ parameters [0 ], $ key );
@@ -1236,9 +1236,9 @@ protected function validateDistinct($attribute, $value, $parameters)
1236
1236
{
1237
1237
$ attributeName = $ this ->getPrimaryAttribute ($ attribute );
1238
1238
1239
- $ explicitAddress = $ this ->getExplicitAddress ($ attributeName );
1239
+ $ explicitPath = $ this ->getLeadingExplicitAttributePath ($ attributeName );
1240
1240
1241
- $ attributeData = $ this ->extractData ( $ explicitAddress );
1241
+ $ attributeData = $ this ->extractDataFromPath ( $ explicitPath );
1242
1242
1243
1243
$ data = Arr::where (Arr::dot ($ attributeData ), function ($ key ) use ($ attribute , $ attributeName ) {
1244
1244
return $ key != $ attribute && Str::is ($ attributeName , $ key );
@@ -2580,21 +2580,25 @@ protected function getNumericKeys($attribute)
2580
2580
*
2581
2581
* E.g. 'foo.bar.*.baz' -> 'foo.bar'
2582
2582
*
2583
+ * Allows us to not spin through all of the flattened data for some operations.
2584
+ *
2583
2585
* @param string $attribute
2584
2586
* @return string
2585
2587
*/
2586
- protected function getExplicitAddress ($ attribute )
2588
+ protected function getLeadingExplicitAttributePath ($ attribute )
2587
2589
{
2588
2590
return rtrim (explode ('* ' , $ attribute )[0 ], '. ' );
2589
2591
}
2590
2592
2591
2593
/**
2592
- * Extract only the given attribute's values from the data.
2594
+ * Extract data based on the given dot-notated path.
2595
+ *
2596
+ * Used to extract a sub-section of the data for faster iteration.
2593
2597
*
2594
2598
* @param string $attribute
2595
2599
* @return array
2596
2600
*/
2597
- protected function extractData ($ attribute )
2601
+ protected function extractDataFromPath ($ attribute )
2598
2602
{
2599
2603
$ results = [];
2600
2604
0 commit comments