29 lines
613 B
PHP
29 lines
613 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
class NewsRepository
|
|
{
|
|
/**
|
|
* @return array<int, array<string, mixed>>
|
|
*/
|
|
public static function all(): array
|
|
{
|
|
$translations = trans('news_articles_page');
|
|
|
|
return collect($translations)
|
|
->map(fn ($article, $slug) => array_merge(['slug' => $slug], $article))
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>|null
|
|
*/
|
|
public static function findBySlug(string $slug): ?array
|
|
{
|
|
return collect(self::all())->firstWhere('slug', $slug);
|
|
}
|
|
}
|