Пример #1
0
 /**
  * Handle the command.
  *
  * @param TypeRepositoryInterface $types
  * @param PostRepositoryInterface $posts
  */
 public function handle(TypeRepositoryInterface $types, PostRepositoryInterface $posts)
 {
     /* @var TypeInterface $type */
     $type = $types->find($this->type->getId());
     /* @var PostInterface $post */
     foreach ($type->getPosts() as $post) {
         $posts->save($post->setAttribute('entry_type', $this->type->getEntryModelName()));
     }
 }
Пример #2
0
 /**
  * Handle the command.
  *
  * @param StreamRepositoryInterface $streams
  * @param TypeRepositoryInterface   $types
  * @param Repository                $config
  */
 public function handle(StreamRepositoryInterface $streams, TypeRepositoryInterface $types, Repository $config)
 {
     /* @var TypeInterface $type */
     $type = $types->find($this->type->getId());
     /* @var StreamInterface $stream */
     $stream = $type->getEntryStream();
     $stream->fill([$config->get('app.fallback_locale') => ['name' => $this->type->getName(), 'description' => $this->type->getDescription()], 'slug' => $this->type->getSlug() . '_posts']);
     $streams->save($stream);
 }
Пример #3
0
 /**
  * Find many posts by type.
  *
  * @param TypeInterface $type
  * @param null          $limit
  * @return PostCollection
  */
 public function findManyByType(TypeInterface $type, $limit = null)
 {
     return $this->model->live()->where('type_id', $type->getId())->paginate($limit);
 }