mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
orderBy
This commit is contained in:
@@ -27,6 +27,7 @@ class Episode extends Resource
|
||||
public static $search = [
|
||||
'id',
|
||||
];
|
||||
public static $orderBy = ['data->datePublished' => 'desc'];
|
||||
|
||||
public static function afterUpdate(NovaRequest $request, Model $model)
|
||||
{
|
||||
@@ -62,11 +63,6 @@ class Episode extends Resource
|
||||
}
|
||||
}
|
||||
|
||||
public function title()
|
||||
{
|
||||
return $this->data['title'];
|
||||
}
|
||||
|
||||
public static function afterCreate(NovaRequest $request, Model $model)
|
||||
{
|
||||
\App\Models\User::find(1)
|
||||
@@ -76,6 +72,20 @@ class Episode extends Resource
|
||||
->toString()));
|
||||
}
|
||||
|
||||
protected static function applyOrderings($query, array $orderings)
|
||||
{
|
||||
if (empty($orderings) && property_exists(static::class, 'orderBy')) {
|
||||
$orderings = static::$orderBy;
|
||||
}
|
||||
|
||||
return parent::applyOrderings($query, $orderings);
|
||||
}
|
||||
|
||||
public function title()
|
||||
{
|
||||
return $this->data['title'];
|
||||
}
|
||||
|
||||
public function subtitle()
|
||||
{
|
||||
return __('Created by: :name', ['name' => $this->createdBy->name]);
|
||||
|
||||
Reference in New Issue
Block a user