本文整理汇总了PHP中Definition::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::find方法的具体用法?PHP Definition::find怎么用?PHP Definition::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Definition
的用法示例。
在下文中一共展示了Definition::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($identifier, array $input)
{
$attributions = @$input['attribution'];
// Process input (e.g. set default values to empty properties)
$input = $this->processInput($input);
$definition = $this->getByIdentifier($identifier);
$source = $this->getDefinitionSource($definition['source_id'], $definition['source_type']);
$type = ucfirst(strtolower($source['type']));
if (empty($definition)) {
\App::abort(404, "The resource with identifier '{$identifier}' could not be found.");
}
$source_repository = $this->getSourceRepository($type);
$this->validateType($input);
$source_repository->update($source['id'], $input);
$definition_model = \Definition::find($definition['id']);
$definition_model->update(array_only($input, array_keys($this->getCreateParameters())));
if (!empty($input['title'])) {
$definition_model->title = $input['title'];
}
if (!empty($input['description'])) {
$definition_model->description = $input['description'];
}
// Update the facets for the definition
$this->updateFacets($definition_model);
//$definition_object = $this->getEloquentDefinition($identifier);
// Add the rest of the properties
$create_parameters = $this->getCreateParameters();
unset($create_parameters['geometry']);
unset($create_parameters['label']);
$definition_model->update(array_only($input, array_keys($create_parameters)));
// Delete the locations and create again if geo meta-data is provided (= update)
if (!empty($definition_model->location->id)) {
$location = $definition_model->location;
$location->geometry->delete();
$location->label->delete();
$location->delete();
$definition_model->save();
}
$location = $this->createLocation($input);
// Check for location meta-data
if (!empty($location)) {
$definition_model->location()->save($location);
}
if (!empty($definition_model->attributions)) {
foreach ($definition_model->attributions as $attribution) {
$attribution->delete();
}
}
// Add attributions if there are any
if (!empty($attributions)) {
$attribution_models = [];
foreach ($attributions as $attribution) {
$attribution_models[] = $this->createAttribution($attribution);
}
$definition_model->attributions()->saveMany($attribution_models);
}
$definition_model->save();
return $definition_model->toArray();
}
示例2: update
public function update($identifier, array $input)
{
// Process input (e.g. set default values to empty properties)
$input = $this->processInput($input);
$definition = $this->getByIdentifier($identifier);
$source = $this->getDefinitionSource($definition['source_id'], $definition['source_type']);
$type = ucfirst(strtolower($source['type']));
if (empty($definition)) {
\App::abort(404, "The resource with identifier '{$identifier}' could not be found.");
}
$source_repository = $this->getSourceRepository($type);
$this->validateType($input);
$source_repository->update($source['id'], $input);
$definition_object = \Definition::find($definition['id']);
$definition_object->update(array_only($input, array_keys($this->getCreateParameters())));
return $definition_object->toArray();
}
示例3: getDelete
/**
* Admin.dataset.delete
*/
public function getDelete($id)
{
// Set permission
Auth::requirePermissions('admin.dataset.delete');
if (is_numeric($id)) {
$definition = \Definition::find($id);
if ($definition) {
// Delete it (with cascade)
$definition->delete();
}
}
return \Redirect::to('api/admin/datasets');
}