Skip to content

Commit dec0e5d

Browse files
author
Sebastian BURGIN-FIX (ext)
committed
wip
1 parent 02979dc commit dec0e5d

155 files changed

Lines changed: 3957 additions & 1193 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Pull Request | CI Pint
2+
3+
on: pull_request
4+
5+
jobs:
6+
pint:
7+
runs-on: ubuntu-latest
8+
name: pull-request | ci pint
9+
10+
env:
11+
PHP_VERSION: 8.5
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v7
16+
17+
- name: Setup PHP Environment
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ env.PHP_VERSION }}
21+
extensions: dom, curl, fileinfo, mysql, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
22+
23+
- name: Prepare the .env file
24+
run: cp .env.ci .env
25+
26+
- name: Cache Composer Dependencies
27+
uses: actions/cache@v6
28+
with:
29+
path: |
30+
~/.composer/cache/files
31+
~/.composer/cache/repo
32+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-composer-
35+
36+
- name: Install Composer Dependencies
37+
run: composer install --no-progress --prefer-dist --no-interaction --optimize-autoloader
38+
39+
- name: Execute code style check
40+
run: ./vendor/bin/pint --test

app/Actions/PageAction.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Actions;
44

55
use App\DTO\PageDTO;
6+
use App\Models\Network;
67
use App\Models\News;
78
use App\Models\OpenSource;
89
use App\Models\Page;
@@ -63,6 +64,21 @@ public function news(News $news, bool $withReferences = false, ?string $locale =
6364
);
6465
}
6566

67+
public function network(Network $network, ?string $locale = null): PageDTO
68+
{
69+
return new PageDTO(
70+
locale: $locale ?? $network->locale->value,
71+
routeKey: 'network.show',
72+
routeName: Str::slug(title: $locale ?? $network->locale->value).'.network.show',
73+
title: $network->name,
74+
description: $network->excerpt,
75+
image: $network->logo,
76+
lastModificationDate: Carbon::parse($network->updated_at ?? now()),
77+
routeParameters: ['slug' => $network->page_slug],
78+
referencePages: null,
79+
);
80+
}
81+
6682
public function product(Product $product, bool $withReferences = false, ?string $locale = null): PageDTO
6783
{
6884
return new PageDTO(

app/Enums/NetworkCategoryEnum.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum NetworkCategoryEnum: string
6+
{
7+
case COLLABORATION = 'collaboration';
8+
case SOFTWARE = 'software';
9+
case INFRASTRUCTURE = 'infrastructure';
10+
case SPONSORING = 'sponsoring';
11+
case CERTIFICATION = 'certification';
12+
13+
public function getLabel(): string
14+
{
15+
return match ($this) {
16+
NetworkCategoryEnum::COLLABORATION => __('Collaboration Partner'),
17+
NetworkCategoryEnum::SOFTWARE => __('Software Partner'),
18+
NetworkCategoryEnum::INFRASTRUCTURE => __('Infrastructure Partner'),
19+
NetworkCategoryEnum::SPONSORING => __('Sponsoring & Community'),
20+
NetworkCategoryEnum::CERTIFICATION => __('Certifications & Memberships'),
21+
};
22+
}
23+
}

app/Enums/NetworkStatusEnum.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
enum NetworkStatusEnum: string
6+
{
7+
case ACTIVE = 'active';
8+
case ENDED = 'ended';
9+
10+
public function getLabel(): string
11+
{
12+
return match ($this) {
13+
NetworkStatusEnum::ACTIVE => __('Active'),
14+
NetworkStatusEnum::ENDED => __('Ended'),
15+
};
16+
}
17+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Actions\PageAction;
6+
use App\Enums\NetworkCategoryEnum;
7+
use App\Http\Controllers\Controller;
8+
use App\Models\Network;
9+
use Illuminate\Support\Collection;
10+
use Illuminate\View\View;
11+
12+
class NetworkIndexController extends Controller
13+
{
14+
public function __invoke(): View
15+
{
16+
$networks = Network::query()
17+
->where('locale', app()->getLocale())
18+
->published()
19+
->active()
20+
->with('publishedUsers')
21+
->orderBy('sort')
22+
->get();
23+
24+
$groups = collect(NetworkCategoryEnum::cases())
25+
->mapWithKeys(fn (NetworkCategoryEnum $category): array => [
26+
$category->value => $networks->where('category', $category),
27+
])
28+
->filter(fn (Collection $items): bool => $items->isNotEmpty());
29+
30+
return view('app.network.index')->with([
31+
'page' => (new PageAction(locale: null, routeName: 'network.index'))->default(),
32+
'groups' => $groups,
33+
]);
34+
}
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Actions\PageAction;
6+
use App\Http\Controllers\Controller;
7+
use App\Models\NetworkUser;
8+
use Illuminate\View\View;
9+
10+
class NetworkManageShowController extends Controller
11+
{
12+
public function __invoke(NetworkUser $networkUser): View
13+
{
14+
return view('app.network.manage')->with([
15+
'page' => (new PageAction(locale: null, routeName: 'network.request.index'))->default(),
16+
'networkUser' => $networkUser,
17+
'network' => $networkUser->network(),
18+
]);
19+
}
20+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Network\NetworkManageUpdateRequest;
7+
use App\Jobs\Mail\NetworkProfileUpdatedMail;
8+
use App\Models\Network;
9+
use App\Models\NetworkUser;
10+
use Illuminate\Http\RedirectResponse;
11+
use Illuminate\Support\Facades\Mail;
12+
use Illuminate\Support\Facades\URL;
13+
use Illuminate\Support\Str;
14+
use Spatie\ResponseCache\Facades\ResponseCache;
15+
16+
class NetworkManageUpdateController extends Controller
17+
{
18+
public function __invoke(NetworkManageUpdateRequest $request, NetworkUser $networkUser): RedirectResponse
19+
{
20+
// Hard whitelist: a signed link may only ever touch the person's own
21+
// contact channels, their own visibility and the company website.
22+
$networkUser->update([
23+
'email' => $request->validated('email'),
24+
'linkedin' => $request->validated('linkedin'),
25+
'phone' => $request->validated('phone'),
26+
'published' => $request->boolean('published'),
27+
]);
28+
29+
Network::query()
30+
->where('key', $networkUser->network_key)
31+
->update(['website' => $request->validated('website')]);
32+
33+
ResponseCache::clear();
34+
35+
Mail::to(config('mail.from.address'))->send(new NetworkProfileUpdatedMail($networkUser->refresh()));
36+
37+
$url = URL::temporarySignedRoute(
38+
Str::slug(app()->getLocale()).'.network.manage.show',
39+
now()->addHours(48),
40+
['networkUser' => $networkUser],
41+
);
42+
43+
return redirect()
44+
->to($url)
45+
->with('status', __('Your profile has been updated.'));
46+
}
47+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Actions\PageAction;
6+
use App\Http\Controllers\Controller;
7+
use Illuminate\View\View;
8+
9+
class NetworkRequestIndexController extends Controller
10+
{
11+
public function __invoke(): View
12+
{
13+
return view('app.network.request')->with([
14+
'page' => (new PageAction(locale: null, routeName: 'network.request.index'))->default(),
15+
]);
16+
}
17+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Network\NetworkRequestStoreRequest;
7+
use App\Jobs\Mail\NetworkManageLinkMail;
8+
use App\Models\NetworkUser;
9+
use Illuminate\Http\RedirectResponse;
10+
use Illuminate\Support\Facades\Mail;
11+
use Illuminate\Support\Facades\URL;
12+
use Illuminate\Support\Str;
13+
14+
class NetworkRequestStoreController extends Controller
15+
{
16+
public function __invoke(NetworkRequestStoreRequest $request): RedirectResponse
17+
{
18+
$networkUser = NetworkUser::query()
19+
->where('email', $request->validated('email'))
20+
->first();
21+
22+
if ($networkUser) {
23+
$url = URL::temporarySignedRoute(
24+
Str::slug(app()->getLocale()).'.network.manage.show',
25+
now()->addHours(48),
26+
['networkUser' => $networkUser],
27+
);
28+
29+
Mail::to($networkUser->email)->send(new NetworkManageLinkMail($networkUser, $url));
30+
}
31+
32+
// Always the same response, so email addresses cannot be enumerated.
33+
return redirect()
34+
->to(localized_route('network.request.index'))
35+
->with('status', __('If the email address is registered, we have sent you a link.'));
36+
}
37+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Network;
4+
5+
use App\Actions\PageAction;
6+
use App\Http\Controllers\Controller;
7+
use App\Models\Network;
8+
use Illuminate\View\View;
9+
10+
class NetworkShowController extends Controller
11+
{
12+
public function __invoke(string $slug): View
13+
{
14+
$network = Network::query()
15+
->where('locale', app()->getLocale())
16+
->published()
17+
->where('page_slug', $slug)
18+
->first();
19+
20+
abort_unless((bool) $network, 404);
21+
abort_unless(view()->exists('app.network.pages.'.$slug), 404);
22+
23+
return view('app.network.pages.'.$slug)->with([
24+
'page' => (new PageAction(locale: null, routeName: 'network.index'))->default(),
25+
'network' => $network,
26+
'users' => $network->publishedUsers()->get(),
27+
]);
28+
}
29+
}

0 commit comments

Comments
 (0)