當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。