Exemple #1
0
 public function info(array $attributes)
 {
     $this->model = is_null($this->model) ? $this->repository->getModel()->find($attributes['video_id']) : $this->model;
     if (null !== $this->model) {
         $info = $this->infoRepository->getModel()->where('video_id', $this->model->getId())->first();
         // Create a new item
         $info = $info ? $info : $this->infoRepository->getModel()->newInstance();
         $info->fill(array_merge($attributes, array('video_id' => $this->model->getId())));
         if (!$info->save()) {
             throw new Exception("Could not create a video info");
         }
     }
     return $this->model;
 }