/** * Handle the command. * * @param StreamSchema $schema */ public function handle(StreamSchema $schema, StreamRepositoryInterface $streams) { /* @var StreamInterface $stream */ $stream = $streams->find($this->stream->getId()); $schema->renameTable($stream, $this->stream); if ($stream->isTranslatable()) { $schema->renameTranslationsTable($stream, $this->stream); } }
/** * Set the stream attribute. * * @param StreamInterface $stream */ public function setStreamAttribute(StreamInterface $stream) { $this->attributes['stream_id'] = $stream->getId(); }
/** * Find all assignments by stream. * * @param StreamInterface $stream * @return AssignmentCollection */ public function findByStream(StreamInterface $stream) { return $this->model->where('stream_id', $stream->getId())->get(); }
/** * Fired when the table starts querying. * * @param Builder $query */ public function onQuerying(Builder $query) { $locked = $this->stream->getAssignments()->locked()->pluck('id')->all(); $assignments = $this->stream->getAssignments()->withFields($this->getOption('skip', []))->pluck('id')->all(); $query->where('stream_id', $this->stream->getId())->whereNotIn('id', array_merge($locked, $assignments)); }