Skip to content

Commit 7816c00

Browse files
author
Sebastian BURGIN-FIX (ext)
committed
wip
1 parent fe3e718 commit 7816c00

44 files changed

Lines changed: 1135 additions & 27 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Actions/PageAction.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use App\DTO\PageDTO;
66
use App\Models\News;
7+
use App\Models\OpenSource;
78
use App\Models\Page;
89
use App\Models\Product;
910
use App\Models\Service;
11+
use App\Models\Technology;
1012
use Illuminate\Support\Carbon;
1113
use Illuminate\Support\Collection;
1214
use Illuminate\Support\Str;
@@ -91,6 +93,36 @@ public function service(Service $service, bool $withReferences = false, ?string
9193
);
9294
}
9395

96+
public function technology(Technology $technology, bool $withReferences = false, ?string $locale = null): PageDTO
97+
{
98+
return new PageDTO(
99+
locale: $locale ?? $technology->locale->value,
100+
routeKey: 'technologies.show',
101+
routeName: Str::slug(title: $locale ?? $technology->locale->value).'.technologies.show',
102+
title: $technology->title,
103+
description: $technology->teaser,
104+
image: $technology->image,
105+
lastModificationDate: Carbon::parse($technology->updated_at ?? now()),
106+
routeParameters: ['locale' => $technology->locale, 'technology' => $technology],
107+
referencePages: $withReferences ? $this->technologyReferencePages($technology) : null,
108+
);
109+
}
110+
111+
public function openSource(OpenSource $openSource, bool $withReferences = false, ?string $locale = null): PageDTO
112+
{
113+
return new PageDTO(
114+
locale: $locale ?? $openSource->locale->value,
115+
routeKey: 'open-source.show',
116+
routeName: Str::slug(title: $locale ?? $openSource->locale->value).'.open-source.show',
117+
title: $openSource->title,
118+
description: $openSource->teaser,
119+
image: $openSource->image,
120+
lastModificationDate: Carbon::parse($openSource->updated_at ?? now()),
121+
routeParameters: ['locale' => $openSource->locale, 'openSource' => $openSource],
122+
referencePages: $withReferences ? $this->openSourceReferencePages($openSource) : null,
123+
);
124+
}
125+
94126
/**
95127
* @return Collection<int, PageDTO>
96128
*/
@@ -151,6 +183,46 @@ private function serviceReferencePages(Service $service): Collection
151183
return collect($pages);
152184
}
153185

186+
/**
187+
* @return Collection<int, PageDTO>
188+
*/
189+
private function technologyReferencePages(Technology $technology): Collection
190+
{
191+
$pages = [];
192+
193+
foreach ($technology->references as $reference) {
194+
$reference->load(['target']);
195+
196+
if (! $reference->target instanceof Technology) {
197+
continue;
198+
}
199+
200+
$pages[] = $this->technology(technology: $reference->target, withReferences: false, locale: $reference->reference_locale);
201+
}
202+
203+
return collect($pages);
204+
}
205+
206+
/**
207+
* @return Collection<int, PageDTO>
208+
*/
209+
private function openSourceReferencePages(OpenSource $openSource): Collection
210+
{
211+
$pages = [];
212+
213+
foreach ($openSource->references as $reference) {
214+
$reference->load(['target']);
215+
216+
if (! $reference->target instanceof OpenSource) {
217+
continue;
218+
}
219+
220+
$pages[] = $this->openSource(openSource: $reference->target, withReferences: false, locale: $reference->reference_locale);
221+
}
222+
223+
return collect($pages);
224+
}
225+
154226
private function findPage(): ?Page
155227
{
156228
return Page::where('locale', $this->locale)

app/Http/Controllers/OpenSource/OpenSoruceShowController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Actions\PageAction;
66
use App\Http\Controllers\Controller;
7-
use App\Models\Product;
7+
use App\Models\OpenSource;
88
use Illuminate\Support\Str;
99
use Illuminate\View\View;
1010

@@ -13,14 +13,14 @@ class OpenSoruceShowController extends Controller
1313
/**
1414
* Display the user's profile form.
1515
*/
16-
public function __invoke(string $locale, Product $product): View
16+
public function __invoke(string $locale, OpenSource $openSource): View
1717
{
1818
return view('app.open-source.show')->with([
19-
'page' => (new PageAction(locale: $locale))->product(product: $product),
20-
'name' => $product->name,
21-
'teaser' => $product->teaser,
22-
'content' => Str::of($product->content ?? '')->markdown(),
23-
'tags' => $product->tags,
19+
'page' => (new PageAction(locale: $locale))->openSource(openSource: $openSource),
20+
'name' => $openSource->title,
21+
'teaser' => $openSource->teaser,
22+
'content' => Str::of($openSource->content ?? '')->markdown(),
23+
'tags' => $openSource->tags,
2424
]);
2525
}
2626
}

app/Http/Controllers/Products/ProductsShowController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ public function __invoke(string $locale, Product $product): View
1818
return view('app.products.show')->with([
1919
'page' => (new PageAction(locale: $locale))->product(product: $product),
2020
'name' => $product->name,
21+
'headline' => $product->headline,
2122
'teaser' => $product->teaser,
2223
'content' => Str::of($product->content ?? '')->markdown(),
2324
'tags' => $product->tags,
25+
'deploymentHeading' => $product->deployment_heading,
26+
'deploymentIntro' => $product->deployment_intro,
27+
'deploymentOptions' => $product->deployment_options,
28+
'ctaHeading' => $product->cta_heading,
29+
'ctaBody' => $product->cta_body,
2430
]);
2531
}
2632
}

app/Http/Controllers/Technologies/TechnologiesShowController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Actions\PageAction;
66
use App\Http\Controllers\Controller;
7-
use App\Models\Product;
7+
use App\Models\Technology;
88
use Illuminate\Support\Str;
99
use Illuminate\View\View;
1010

@@ -13,14 +13,14 @@ class TechnologiesShowController extends Controller
1313
/**
1414
* Display the user's profile form.
1515
*/
16-
public function __invoke(string $locale, Product $product): View
16+
public function __invoke(string $locale, Technology $technology): View
1717
{
18-
return view('app.products.show')->with([
19-
'page' => (new PageAction(locale: $locale))->product(product: $product),
20-
'name' => $product->name,
21-
'teaser' => $product->teaser,
22-
'content' => Str::of($product->content ?? '')->markdown(),
23-
'tags' => $product->tags,
18+
return view('app.technologies.show')->with([
19+
'page' => (new PageAction(locale: $locale))->technology(technology: $technology),
20+
'name' => $technology->title,
21+
'teaser' => $technology->teaser,
22+
'content' => Str::of($technology->content ?? '')->markdown(),
23+
'tags' => $technology->tags,
2424
]);
2525
}
2626
}

app/Models/Product.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Product extends Model
2222
'published' => 'boolean',
2323
'locale' => LocaleEnum::class,
2424
'tags' => 'json',
25+
'deployment_options' => 'json',
2526
];
2627

2728
public function getRouteKeyName(): string

app/Providers/AppServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
use App\Checks\JobsCheck;
99
use App\Models\Configuration;
1010
use App\Models\News;
11+
use App\Models\OpenSource;
1112
use App\Models\Product;
1213
use App\Models\Service;
14+
use App\Models\Technology;
1315
use Illuminate\Database\Eloquent\Model;
1416
use Illuminate\Support\Facades\View;
1517
use Illuminate\Support\ServiceProvider;
@@ -57,6 +59,8 @@ private function multilanguage(): void
5759
News::registerLocalizedBinding('news');
5860
Service::registerLocalizedBinding('service');
5961
Product::registerLocalizedBinding('product');
62+
Technology::registerLocalizedBinding('technology');
63+
OpenSource::registerLocalizedBinding('openSource');
6064
}
6165

6266
private function getConfiguration(): ?Configuration

database/factories/ConfigurationFactory.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Database\Factories;
44

5+
use App\Enums\LocaleEnum;
56
use App\Models\Configuration;
67
use Illuminate\Database\Eloquent\Factories\Factory;
78

@@ -18,7 +19,19 @@ class ConfigurationFactory extends Factory
1819
public function definition(): array
1920
{
2021
return [
21-
//
22+
'company' => fake()->company(),
23+
'company_primary_color' => fake()->hexColor(),
24+
'component_intro' => [
25+
LocaleEnum::DE->value => fake()->paragraph(),
26+
LocaleEnum::EN->value => fake()->paragraph(),
27+
],
28+
'section_news' => false,
29+
'section_services' => false,
30+
'section_products' => false,
31+
'section_technologies' => false,
32+
'section_open_source' => false,
33+
'key' => fake()->unique()->slug(),
34+
'links' => [],
2235
];
2336
}
2437
}

database/factories/ContactFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ class ContactFactory extends Factory
1818
public function definition(): array
1919
{
2020
return [
21-
//
21+
'published' => true,
22+
'name' => fake()->name(),
23+
'sections' => [],
24+
'image' => fake()->imageUrl(),
25+
'icons' => [],
2226
];
2327
}
2428
}

database/factories/NewsFactory.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Database\Factories;
44

5+
use App\Enums\LocaleEnum;
56
use App\Models\News;
67
use Illuminate\Database\Eloquent\Factories\Factory;
78

@@ -17,8 +18,18 @@ class NewsFactory extends Factory
1718
*/
1819
public function definition(): array
1920
{
21+
$title = fake()->unique()->sentence();
22+
2023
return [
21-
//
24+
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
25+
'title' => $title,
26+
'slug' => str($title)->slug(),
27+
'teaser' => fake()->sentence(),
28+
'content' => fake()->paragraphs(3, true),
29+
'image' => fake()->imageUrl(),
30+
'published_at' => fake()->dateTime(),
31+
'author' => fake()->name(),
32+
'tags' => fake()->words(2),
2233
];
2334
}
2435
}

database/factories/OpenSourceFactory.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Database\Factories;
44

5+
use App\Enums\LocaleEnum;
56
use App\Models\OpenSource;
67
use Illuminate\Database\Eloquent\Factories\Factory;
78

@@ -17,8 +18,20 @@ class OpenSourceFactory extends Factory
1718
*/
1819
public function definition(): array
1920
{
21+
$title = fake()->unique()->words(3, true);
22+
2023
return [
21-
//
24+
'published' => true,
25+
'locale' => fake()->randomElement(LocaleEnum::cases())->value,
26+
'title' => $title,
27+
'slug' => str($title)->slug(),
28+
'teaser' => fake()->sentence(),
29+
'content' => fake()->paragraphs(3, true),
30+
'image' => fake()->imageUrl(),
31+
'tags' => fake()->words(2),
32+
'link' => fake()->url(),
33+
'downloads' => fake()->numberBetween(0, 1000),
34+
'version' => 'v'.fake()->numerify('#.#.#'),
2235
];
2336
}
2437
}

0 commit comments

Comments
 (0)