20-02-2026

This commit is contained in:
Kevin Adametz 2026-02-20 17:55:06 +01:00
parent a8b395e20d
commit a00c42e770
252 changed files with 28785 additions and 8907 deletions

View file

@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Model;
* @property \Illuminate\Support\Carbon|null $display_date
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
*
* @mixin \Eloquent
*/
class DashboardNews extends Model
@ -55,9 +56,10 @@ class DashboardNews extends Model
return $this->{$key};
}
$trans = $this->getTrans($key, $lang);
if (!$trans || $trans == '') {
if (! $trans || $trans == '') {
return $this->{$key};
}
return $trans;
}
@ -66,29 +68,44 @@ class DashboardNews extends Model
*/
public function getTrans($key, $lang)
{
$transKey = 'trans_' . $key;
if (!empty($this->{$transKey}[$lang])) {
$transKey = 'trans_'.$key;
if (! empty($this->{$transKey}[$lang])) {
return $this->{$transKey}[$lang];
}
return "";
return '';
}
/**
* Get active news
*/
public static function getActiveNews()
public static function getActiveNews(): ?self
{
return self::where('active', true)
->orderBy('created_at', 'DESC')
->first();
}
/**
* Get all archived (non-active) news ordered by display date descending
*
* @return \Illuminate\Database\Eloquent\Collection<int, self>
*/
public static function getArchiveNews(): \Illuminate\Database\Eloquent\Collection
{
return self::where('active', false)
->orderBy('display_date', 'DESC')
->orderBy('created_at', 'DESC')
->get();
}
/**
* Get formatted display date or created_at as fallback
*/
public function getDisplayDateFormatted()
{
$date = $this->display_date ?: $this->created_at;
return $date ? $date->format('d.m.Y') : '';
}
@ -97,11 +114,11 @@ class DashboardNews extends Model
*/
public function getFileLinks($lang = null)
{
if (!$lang) {
if (! $lang) {
$lang = \App::getLocale();
}
if (!$this->file_links || !isset($this->file_links[$lang])) {
if (! $this->file_links || ! isset($this->file_links[$lang])) {
return [];
}
@ -115,6 +132,7 @@ class DashboardNews extends Model
];
}
}
return null;
})->filter()->values();
}