/** * Return the trashable label. * * @param string $size * @return null|string */ protected function trashableLabel($size = 'sm') { if ($this->object->isTrashable()) { return '<span class="label label-danger label-' . $size . '">' . trans('streams::field.trashable.name') . '</span>'; } return null; }
/** * Return the use statement for trashable if so. * * @param StreamInterface $stream * @return string */ public function parse(StreamInterface $stream) { if (!$stream->isTrashable()) { return null; } return "use \\Illuminate\\Database\\Eloquent\\SoftDeletes;"; }
/** * Return the dates attribute. * * @param StreamInterface $stream * @return string */ public function parse(StreamInterface $stream) { $dates = []; $dates[] = "'created_at'"; $dates[] = "'updated_at'"; /* @var AssignmentInterface $assignment */ foreach ($stream->getDateAssignments() as $assignment) { $dates[] = "'{$assignment->getFieldSlug()}'"; } if ($stream->isTrashable()) { $dates[] = "'deleted_at'"; } return "[" . implode(', ', $dates) . "]"; }
/** * Create a table. * * @param StreamInterface */ public function createTable(StreamInterface $stream) { $table = $stream->getEntryTableName(); $this->schema->dropIfExists($table); $this->schema->create($table, function (Blueprint $table) use($stream) { $table->increments('id'); $table->integer('sort_order')->nullable(); $table->datetime('created_at'); $table->integer('created_by')->nullable(); $table->datetime('updated_at')->nullable(); $table->integer('updated_by')->nullable(); if ($stream->isTrashable()) { $table->datetime('deleted_at')->nullable(); } }); }