src/Helpers.php
public static function extractModelAndKeys($model, array $keys = null)
    {
        if (! is_null($keys)) {
            if (is_string($model)) {
                $model = new $model;
            }

            return [$model, $keys];
        }

        if ($model instanceof Model) {
            return [$model, [$model->getKey()]];
        }

        if ($model instanceof Collection) {
            $keys = $model->map(function ($model) {
                return $model->getKey();
            });

            return [$model->first(), $keys];
        }
    }
public static function extractModelAndKeys($model, array $keys = null)
    {
        if (! is_null($keys)) {
            if (is_string($model)) {
                $model = new $model;
            }

            return [$model, $keys];
        }

        if ($model instanceof Model) {
            return [$model, [$model->getKey()]];
        }

        if ($model instanceof Collection) {
            $keys = $model->map(function ($model) {
                return $model->getKey();
            });

            return [$model->first(), $keys];
        }
    }
public static function extractModelAndKeys ( $ model , array $ keys = null ) { if ( ! is_null ( $ keys ) ) { if ( is_string ( $ model ) ) { $ model = new $ model ; } return [ $ model , $ keys ] ; } if ( $ model instanceof Model ) { return [ $ model , [ $ model -> getKey ( ) ] ] ; } if ( $ model instanceof Collection ) { $ keys = $ model -> map ( function ( $ model ) { return $ model -> getKey ( ) ; } ) ; return [ $ model -> first ( ) , $ keys ] ; } }
Extract the model instance and model keys from the given parameters.

@param  \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|string  $model
@param  array|null  $keys
@return array
Extract the model instance and model keys from the given parameters .