Inheritance: extends Illuminate\Database\Eloquent\Model, use trait Illuminate\Database\Eloquent\SoftDeletes
コード例 #1
0
ファイル: TagManager.php プロジェクト: devisephp/cms
 /**
  * Finds the mappings for this model type
  * This allows us to know if we have created enough
  * DvsModelField entries in the database
  *
  * @param  array $tag
  * @return array
  */
 protected function fetchMappingsForModelField($tag)
 {
     $field = $this->DvsModelField->newInstance();
     $field->model_id = $tag['key'];
     $field->model_type = $tag['type'];
     return array_keys($field->picks);
 }
コード例 #2
0
ファイル: ModelManagerTest.php プロジェクト: alpas29/cms
 public function test_it_validates_fields_on_update()
 {
     $page = ['page_version_id' => 50, 'page_id' => 42, 'language_id' => 45];
     $fields = [['id' => 1, 'model_id' => 1, 'model_type' => 'DvsTestModel', 'mapping' => 'Name', 'json_value' => '{}', 'values' => ['foo' => 'bar']]];
     $this->addSomeTestModelFields();
     try {
         $this->ModelManager->updateFields($fields, $page);
     } catch (ModelFieldValidationFailedException $e) {
         $field = \DvsModelField::find(1);
         $model = \DvsTestModel::find(1);
         assertEquals(1, $model->page_version_id);
         assertEquals('Some name here', $model->name);
         assertEquals('{}', $field->json_value);
         assertInstanceOf('Illuminate\\Support\\MessageBag', $e->getErrors());
         assertEquals('The name field is required.', $e->getErrors()->first('name'));
         return;
     }
     throw new \Exception("We should not reach this line unless the model validation exception was not thrown...");
 }