当前位置: 首页>>代码示例>>PHP>>正文


PHP Definition::find方法代码示例

本文整理汇总了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();
 }
开发者ID:tdt,项目名称:core,代码行数:59,代码来源:DefinitionRepository.php

示例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();
 }
开发者ID:netsensei,项目名称:core,代码行数:17,代码来源:DefinitionRepository.php

示例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');
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:16,代码来源:DatasetController.php


注:本文中的Definition::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。