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; }
/** * Paginator * @param int $page * @param int $limit * @param bool $all * @return mixed */ public function paginate($page = 1, $limit = 10, $all = false) { return $this->video->paginate($page, $limit, $all); }