Add forSelect

This commit is contained in:
philipp lang 2021-10-31 00:55:05 +02:00
parent 51c4c32e51
commit b6819225ed
1 changed files with 8 additions and 0 deletions

View File

@ -88,4 +88,12 @@ class Page extends Model
return static::whereType($type)->get()->pluck('name', 'id')->toArray(); return static::whereType($type)->get()->pluck('name', 'id')->toArray();
} }
public static function forSelect(): array
{
return static::orderByRaw('type, name')
->selectRaw('id, CONCAT(name, " (", type, ")") AS name')
->pluck('name', 'id')
->toArray();
}
} }