src/ExtractTags.php
protected static function modelsFor(array $targets)
    {
        $models = [];

        foreach ($targets as $target) {
            $models[] = collect((new ReflectionClass($target))->getProperties())->map(function ($property) use ($target) {
                $property->setAccessible(true);

                $value = $property->getValue($target);

                if ($value instanceof Model) {
                    return [$value];
                } elseif ($value instanceof EloquentCollection) {
                    return $value->flatten();
                }
            })->collapse()->filter()->all();
        }

        return collect(Arr::collapse($models))->unique();
    }
protected static function modelsFor(array $targets)
    {
        $models = [];

        foreach ($targets as $target) {
            $models[] = collect((new ReflectionClass($target))->getProperties())->map(function ($property) use ($target) {
                $property->setAccessible(true);

                $value = $property->getValue($target);

                if ($value instanceof Model) {
                    return [$value];
                } elseif ($value instanceof EloquentCollection) {
                    return $value->flatten();
                }
            })->collapse()->filter()->all();
        }

        return collect(Arr::collapse($models))->unique();
    }
protected static function modelsFor ( array $ targets ) { $ models = [ ] ; foreach ( $ targets as $ target ) { $ models [ ] = collect ( ( new ReflectionClass ( $ target ) ) -> getProperties ( ) ) -> map ( function ( $ property ) use ( $ target ) { $ property -> setAccessible ( true ) ; $ value = $ property -> getValue ( $ target ) ; if ( $ value instanceof Model ) { return [ $ value ] ; } elseif ( $ value instanceof EloquentCollection ) { return $ value -> flatten ( ) ; } } ) -> collapse ( ) -> filter ( ) -> all ( ) ; } return collect ( Arr :: collapse ( $ models ) ) -> unique ( ) ; }
Get the models from the given object.

@param  array  $targets
@return \Illuminate\Support\Collection
Get the models from the given object .