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:
35
app/Sorting/SortSet.php
Normal file
35
app/Sorting/SortSet.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user