/** * Extract the model instance and model keys from the given parameters. * * @param string|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection $model * @param array|null $keys * @return array */ public static function extractModelAndKeys($model, array $keys = null) { if (is_null($keys)) { if ($model instanceof Model) { return [$model, [$model->getKey()]]; } if ($model instanceof Collection) { return [$model->first(), $model->modelKeys()]; } } else { if (is_string($model)) { $model = new $model(); } return [$model, $keys]; } }
private function getCollectionIdentifierValues($resourceName, Collection $collection) { if (isset($this->configIdentifiers[$resourceName])) { $identifier = $this->configIdentifiers[$resourceName]; if (isset($identifier["value"])) { return $collection->lists($identifier["value"]); } } if (isset($this->configIdentifier["value"])) { $key = $this->configIdentifier["value"]; return $collection->lists($key); } return $collection->modelKeys(); }