コード例 #1
0
ファイル: MorphTo.php プロジェクト: nova-framework/cms
 /**
  * Set the constraints for an eager load of the relation.
  *
  * @param  array  $models
  * @return void
  */
 public function addEagerConstraints(array $models)
 {
     $this->buildDictionary($this->models = Collection::make($models));
 }
コード例 #2
0
ファイル: Model.php プロジェクト: nova-framework/cms
 /**
  * Save the model and all of its relationships.
  *
  * @return bool
  */
 public function push()
 {
     if (!$this->save()) {
         return false;
     }
     foreach ($this->relations as $models) {
         foreach (Collection::make($models) as $model) {
             if (!$model->push()) {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: Model.php プロジェクト: nova-framework/system
 /**
  * Save the model and all of its relationships.
  *
  * @return bool
  */
 public function push()
 {
     if (!$this->save()) {
         return false;
     }
     // To sync all of the relationships to the database, we will simply spin through
     // the relationships and save each model via this "push" method, which allows
     // us to recurse into all of these nested relations for the model instance.
     foreach ($this->relations as $models) {
         foreach (Collection::make($models) as $model) {
             if (!$model->push()) {
                 return false;
             }
         }
     }
     return true;
 }