1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Sorting: Added content misses from last commit, started settings

This commit is contained in:
Dan Brown
2025-01-30 17:49:19 +00:00
parent b2ac3e0834
commit a34023f715
5 changed files with 122 additions and 0 deletions

35
app/Sorting/SortSet.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace BookStack\Sorting;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name
* @property string $sequence
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class SortSet extends Model
{
/**
* @return SortSetOption[]
*/
public function getOptions(): array
{
$strOptions = explode(',', $this->sequence);
$options = array_map(fn ($val) => SortSetOption::tryFrom($val), $strOptions);
return array_filter($options);
}
/**
* @param SortSetOption[] $options
*/
public function setOptions(array $options): void
{
$values = array_map(fn (SortSetOption $opt) => $opt->value, $options);
$this->sequence = implode(',', $values);
}
}