protected function getIndexesDelta(array $indexesA, array $indexesB)
    {
        $currentIndexes = Collect($indexesA);
        $currentIndexNames = $currentIndexes->pluck('name');

        $requestedIndexes = Collect($indexesB);
        $requestedIndexNames = $requestedIndexes->pluck('name');

        $updatedIndexes = $currentIndexes->whereIn('name', $requestedIndexNames)->all();

        $addedIndexes = $requestedIndexes->reject(function ($requestedIndex) use ($currentIndexNames) {
            return !is_null($requestedIndex->name) && in_array($requestedIndex->name, $currentIndexNames);
        })->all();

        $deletedIndexes = $currentIndexes->reject(function ($currentIndex) use ($requestedIndexNames) {
            return in_array($currentIndex->name, $requestedIndexNames);
        })->all();

        $indexChanges = [];

        foreach ($updatedIndexes as $key => $updatedIndex) {
            $indexChanges[] = IndexMigrationChange::compare($updatedIndex, $requestedIndexes[$key]);
        }

        foreach ($addedIndexes as $addedIndex) {
            $indexChanges[] = IndexMigrationChange::getAdded($addedIndex);
        }

        foreach ($deletedIndexes as $deletedIndex) {
            $indexChanges[] = IndexMigrationChange::getDeleted($deletedIndex);
        }

        return $indexChanges;
    }
protected function getIndexesDelta(array $indexesA, array $indexesB)
    {
        $currentIndexes = Collect($indexesA);
        $currentIndexNames = $currentIndexes->pluck('name');

        $requestedIndexes = Collect($indexesB);
        $requestedIndexNames = $requestedIndexes->pluck('name');

        $updatedIndexes = $currentIndexes->whereIn('name', $requestedIndexNames)->all();

        $addedIndexes = $requestedIndexes->reject(function ($requestedIndex) use ($currentIndexNames) {
            return !is_null($requestedIndex->name) && in_array($requestedIndex->name, $currentIndexNames);
        })->all();

        $deletedIndexes = $currentIndexes->reject(function ($currentIndex) use ($requestedIndexNames) {
            return in_array($currentIndex->name, $requestedIndexNames);
        })->all();

        $indexChanges = [];

        foreach ($updatedIndexes as $key => $updatedIndex) {
            $indexChanges[] = IndexMigrationChange::compare($updatedIndex, $requestedIndexes[$key]);
        }

        foreach ($addedIndexes as $addedIndex) {
            $indexChanges[] = IndexMigrationChange::getAdded($addedIndex);
        }

        foreach ($deletedIndexes as $deletedIndex) {
            $indexChanges[] = IndexMigrationChange::getDeleted($deletedIndex);
        }

        return $indexChanges;
    }
protected function getIndexesDelta ( array $ indexesA , array $ indexesB ) { $ currentIndexes = Collect ( $ indexesA ) ; $ currentIndexNames = $ currentIndexes -> pluck ( 'name' ) ; $ requestedIndexes = Collect ( $ indexesB ) ; $ requestedIndexNames = $ requestedIndexes -> pluck ( 'name' ) ; $ updatedIndexes = $ currentIndexes -> whereIn ( 'name' , $ requestedIndexNames ) -> all ( ) ; $ addedIndexes = $ requestedIndexes -> reject ( function ( $ requestedIndex ) use ( $ currentIndexNames ) { return ! is_null ( $ requestedIndex -> name ) && in_array ( $ requestedIndex -> name , $ currentIndexNames ) ; } ) -> all ( ) ; $ deletedIndexes = $ currentIndexes -> reject ( function ( $ currentIndex ) use ( $ requestedIndexNames ) { return in_array ( $ currentIndex -> name , $ requestedIndexNames ) ; } ) -> all ( ) ; $ indexChanges = [ ] ; foreach ( $ updatedIndexes as $ key => $ updatedIndex ) { $ indexChanges [ ] = IndexMigrationChange :: compare ( $ updatedIndex , $ requestedIndexes [ $ key ] ) ; } foreach ( $ addedIndexes as $ addedIndex ) { $ indexChanges [ ] = IndexMigrationChange :: getAdded ( $ addedIndex ) ; } foreach ( $ deletedIndexes as $ deletedIndex ) { $ indexChanges [ ] = IndexMigrationChange :: getDeleted ( $ deletedIndex ) ; } return $ indexChanges ; }
Get the field difference between two given Index arrays

@param array $indexesA
@param array $indexesB

@return array
Get the field difference between two given Index arrays