12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
100
database/seeders/CategorySeeder.php
Normal file
100
database/seeders/CategorySeeder.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
[
|
||||
'key' => 'news-wirtschaft',
|
||||
'portal' => Portal::Both,
|
||||
'translations' => [
|
||||
'de' => [
|
||||
'name' => 'Wirtschaft',
|
||||
'slug' => 'wirtschaft',
|
||||
'description' => 'Pressemitteilungen aus Wirtschaft und Unternehmen.',
|
||||
],
|
||||
'en' => [
|
||||
'name' => 'Business',
|
||||
'slug' => 'business',
|
||||
'description' => 'Press releases from business and companies.',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'key' => 'news-technologie',
|
||||
'portal' => Portal::Both,
|
||||
'translations' => [
|
||||
'de' => [
|
||||
'name' => 'Technologie',
|
||||
'slug' => 'technologie',
|
||||
'description' => 'News rund um Innovation, IT und digitale Themen.',
|
||||
],
|
||||
'en' => [
|
||||
'name' => 'Technology',
|
||||
'slug' => 'technology',
|
||||
'description' => 'News around innovation, IT, and digital topics.',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'key' => 'news-finanzen',
|
||||
'portal' => Portal::Both,
|
||||
'translations' => [
|
||||
'de' => [
|
||||
'name' => 'Finanzen',
|
||||
'slug' => 'finanzen',
|
||||
'description' => 'Pressemitteilungen zu Banken, Boerse und Finanzthemen.',
|
||||
],
|
||||
'en' => [
|
||||
'name' => 'Finance',
|
||||
'slug' => 'finance',
|
||||
'description' => 'Press releases about banks, stock markets, and finance topics.',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($categories as $categoryData) {
|
||||
$deSlug = $categoryData['translations']['de']['slug'];
|
||||
|
||||
$category = Category::query()
|
||||
->whereHas('translations', function ($query) use ($deSlug) {
|
||||
$query->where('locale', 'de')->where('slug', $deSlug);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (! $category) {
|
||||
$category = Category::query()->create([
|
||||
'portal' => $categoryData['portal']->value,
|
||||
'is_active' => true,
|
||||
]);
|
||||
} else {
|
||||
$category->update([
|
||||
'portal' => $categoryData['portal']->value,
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($categoryData['translations'] as $locale => $translation) {
|
||||
$category->translations()->updateOrCreate(
|
||||
['locale' => $locale],
|
||||
[
|
||||
'name' => $translation['name'],
|
||||
'slug' => $translation['slug'],
|
||||
'description' => $translation['description'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue