This commit is contained in:
Benjamin Takats
2023-01-18 16:50:46 +01:00
parent 3c87b47778
commit ef92cc647d

View File

@@ -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]);