/**
  * @param array $models
  * @param array $joinings
  * @return array
  * @throws \Grandiloquent\Exception\MassEventFireException
  */
 public function saveMany(array $models, array $joinings = [])
 {
     $modelCollection = GrandCollection::make($models);
     $modelCollection->saveMany();
     /** @var GrandModel $model */
     foreach ($modelCollection as $key => $model) {
         $this->attach($model->getKey(), array_get($joinings, $key), false);
     }
     $this->touchIfTouching();
     return $modelCollection->toItemArray();
 }
Beispiel #2
0
 /**
  * @param array $models
  * @return array
  * @throws \Grandiloquent\Exception\MassEventFireException
  */
 public function saveMany($models)
 {
     $modelCollection = GrandCollection::make($models);
     return $modelCollection->saveMany()->toItemArray();
 }