/** * Find an assignment by stream and field. * * @param StreamInterface $stream * @param FieldInterface $field * @return null|AssignmentInterface|EloquentModel */ public function findByStreamAndField(StreamInterface $stream, FieldInterface $field) { return $this->model->where('stream_id', $stream->getId())->where('field_id', $field->getId())->first(); }
/** * Set the field attribute. * * @param FieldInterface $field */ public function setFieldAttribute(FieldInterface $field) { $this->attributes['field_id'] = $field->getId(); }
/** * Handle the command. */ public function handle() { foreach ($this->field->getTranslations() as $translation) { $translation->delete(); } }
/** * Handle the command. */ public function handle() { foreach ($this->field->getAssignments() as $assignment) { $this->dispatch(new UpdateAssignmentColumn($assignment->setRelation('field', $this->field))); } }
/** * Handle the command. * * @param AssignmentRepositoryInterface $assignments */ public function handle(AssignmentRepositoryInterface $assignments) { foreach ($this->field->getAssignments() as $assignment) { $assignments->delete($assignment); } }
/** * Parse an assignment field. * * @param FieldInterface $field * @param $string */ protected function parseField(FieldInterface $field, &$string) { $string .= "\n'field' => ["; foreach ($field->getAttributes() as $key => $value) { $value = $field->getAttribute($key); if (is_string($value)) { $value = addslashes($value); } if (is_array($value)) { $value = serialize($value); } $string .= "\n'{$key}' => '{$value}',"; } // Parse field translations. $this->parseTranslations($field, $string); $string .= "\n],"; }
/** * Fired after a field has been deleted. * * @param FieldInterface $model */ public function deleted(FieldInterface $model) { $model->flushCache(); $this->dispatch(new DeleteFieldTranslations($model)); $this->events->fire(new FieldWasDeleted($model)); }