Skip to content

Commit bf29a5c

Browse files
authored
Merge pull request #28 from codebar-ag/main
main/production
2 parents cf75975 + 70e5797 commit bf29a5c

38 files changed

Lines changed: 603 additions & 310 deletions

app/Actions/ViewDataAction.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public function contacts(string $locale): object
8282
->get();
8383

8484
return (object) collect([
85-
ContactSectionEnum::EMPLOYEE_SERVICES,
86-
ContactSectionEnum::EMPLOYEE_PRODUCTS,
87-
ContactSectionEnum::EMPLOYEE_ADMINISTRATION,
85+
ContactSectionEnum::EMPLOYEES,
8886
ContactSectionEnum::COLLABORATIONS,
8987
ContactSectionEnum::BOARD_MEMBERS,
9088
])->mapWithKeys(function (string $section) use ($publishedContacts, $locale): array {

app/Enums/ContactSectionEnum.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
enum ContactSectionEnum: string
66
{
7-
const string EMPLOYEE_SERVICES = 'employee_services';
8-
9-
const string EMPLOYEE_PRODUCTS = 'employee_products';
10-
11-
const string EMPLOYEE_ADMINISTRATION = 'employee_administration';
7+
const string EMPLOYEES = 'employees';
128

139
const string COLLABORATIONS = 'collaborations';
1410

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\News;
4+
5+
use App\Actions\PageAction;
6+
use App\Actions\ViewDataAction;
7+
use App\Http\Controllers\Controller;
8+
use Illuminate\View\View;
9+
10+
class NewsIndexController extends Controller
11+
{
12+
/**
13+
* Display the user's profile form.
14+
*/
15+
public function __invoke(): View
16+
{
17+
$locale = app()->getLocale();
18+
19+
return view('app.news.index')->with([
20+
'page' => (new PageAction(locale: null, routeName: 'news.index'))->default(),
21+
'news' => (new ViewDataAction)->news($locale),
22+
]);
23+
}
24+
}

app/Http/Controllers/Sitemap/SitemapController.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use App\Models\Service;
1212
use App\Sitemap\SitemapBuilder;
1313
use Illuminate\Http\Response;
14+
use Illuminate\Support\Collection;
1415
use Illuminate\Support\Facades\Cache;
1516

1617
class SitemapController extends Controller
@@ -44,35 +45,46 @@ public function __invoke(): Response
4445
});
4546

4647
return response(content: $content)
47-
->header('Content-Type', 'application/xml');
48+
->header('Content-Type', 'application/xml')
49+
->header('Cache-Control', 'public, max-age=3600'); // Cache for 1 hour
4850
}
4951

5052
private function builder(): void
5153
{
5254
$this->addDefaultRoutesToSitemap();
5355

56+
// Use chunked queries to prevent memory issues
5457
News::whereNotNull('published_at')
5558
->with('references')
56-
->each(function (News $news): void {
57-
$this->addLocalizedPageSet(
58-
page: (new PageAction(locale: null, routeName: null))->news(news: $news, withReferences: true),
59-
);
59+
->chunk(100, function (Collection $news): void {
60+
/** @var News $item */
61+
foreach ($news as $item) {
62+
$this->addLocalizedPageSet(
63+
page: (new PageAction(locale: null, routeName: null))->news(news: $item, withReferences: true),
64+
);
65+
}
6066
});
6167

6268
Service::where('published', true)
6369
->with('references')
64-
->each(function (Service $service): void {
65-
$this->addLocalizedPageSet(
66-
page: (new PageAction(locale: null, routeName: null))->service(service: $service, withReferences: true),
67-
);
70+
->chunk(100, function (Collection $services): void {
71+
/** @var Service $item */
72+
foreach ($services as $item) {
73+
$this->addLocalizedPageSet(
74+
page: (new PageAction(locale: null, routeName: null))->service(service: $item, withReferences: true),
75+
);
76+
}
6877
});
6978

7079
Product::where('published', true)
7180
->with('references')
72-
->each(function (Product $product): void {
73-
$this->addLocalizedPageSet(
74-
page: (new PageAction(locale: null, routeName: null))->product(product: $product, withReferences: true),
75-
);
81+
->chunk(100, function (Collection $products): void {
82+
/** @var Product $item */
83+
foreach ($products as $item) {
84+
$this->addLocalizedPageSet(
85+
page: (new PageAction(locale: null, routeName: null))->product(product: $item, withReferences: true),
86+
);
87+
}
7688
});
7789
}
7890

app/Models/Configuration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Configuration extends Model
1010
use HasFactory;
1111

1212
protected $casts = [
13+
'component_intro' => 'json',
14+
'section_news' => 'boolean',
1315
'section_services' => 'boolean',
1416
'section_products' => 'boolean',
1517
'section_technologies' => 'boolean',

config/database.php

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -42,48 +42,13 @@
4242
'mysql' => [
4343
'driver' => 'mysql',
4444
'url' => env('DB_URL'),
45-
'host' => env('DB_HOST', '127.0.0.1'),
46-
'port' => env('DB_PORT', '3306'),
47-
'database' => env('DB_DATABASE', 'laravel'),
48-
'username' => env('DB_USERNAME', 'root'),
49-
'password' => env('DB_PASSWORD', ''),
50-
'unix_socket' => env('DB_SOCKET', ''),
51-
'charset' => env('DB_CHARSET', 'utf8mb4'),
52-
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
53-
'prefix' => '',
54-
'prefix_indexes' => true,
55-
'strict' => true,
56-
'engine' => null,
57-
'options' => extension_loaded('pdo_mysql') ? array_filter([
58-
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
59-
]) : [],
60-
],
61-
62-
'logs' => [
63-
'driver' => 'mysql',
64-
'url' => env('LOGS_DATABASE_URL'),
65-
'host' => env('LOGS_DB_HOST', '127.0.0.1'),
66-
'port' => env('LOGS_DB_PORT', '3306'),
67-
'database' => env('LOGS_DB_DATABASE', 'forge'),
68-
'username' => env('LOGS_DB_USERNAME', 'forge'),
69-
'password' => env('LOGS_DB_PASSWORD', ''),
70-
'unix_socket' => env('LOGS_DB_SOCKET', ''),
71-
'charset' => 'utf8mb4',
72-
'collation' => 'utf8mb4_unicode_ci',
73-
'prefix' => '',
74-
'prefix_indexes' => true,
75-
'strict' => true,
76-
'engine' => null,
77-
'options' => extension_loaded('pdo_mysql') ? array_filter([
78-
PDO::MYSQL_ATTR_SSL_CA => env('LOGS_MYSQL_ATTR_SSL_CA'),
79-
]) : [],
80-
'ssl_mode' => env('LOGS_SSL_MODE', 'required'),
81-
],
82-
83-
'mariadb' => [
84-
'driver' => 'mariadb',
85-
'url' => env('DB_URL'),
86-
'host' => env('DB_HOST', '127.0.0.1'),
45+
'read' => [
46+
'host' => env('DB_READ_HOST', env('DB_HOST')),
47+
],
48+
'write' => [
49+
'host' => env('DB_WRITE_HOST', env('DB_HOST')),
50+
],
51+
// 'host' => env('DB_HOST'),
8752
'port' => env('DB_PORT', '3306'),
8853
'database' => env('DB_DATABASE', 'laravel'),
8954
'username' => env('DB_USERNAME', 'root'),
@@ -103,7 +68,13 @@
10368
'pgsql' => [
10469
'driver' => 'pgsql',
10570
'url' => env('DB_URL'),
106-
'host' => env('DB_HOST', '127.0.0.1'),
71+
'read' => [
72+
'host' => env('DB_READ_HOST', env('DB_HOST')),
73+
],
74+
'write' => [
75+
'host' => env('DB_WRITE_HOST', env('DB_HOST')),
76+
],
77+
// 'host' => env('DB_HOST'),
10778
'port' => env('DB_PORT', '5432'),
10879
'database' => env('DB_DATABASE', 'laravel'),
10980
'username' => env('DB_USERNAME', 'root'),
@@ -114,22 +85,6 @@
11485
'search_path' => 'public',
11586
'sslmode' => 'prefer',
11687
],
117-
118-
'sqlsrv' => [
119-
'driver' => 'sqlsrv',
120-
'url' => env('DB_URL'),
121-
'host' => env('DB_HOST', 'localhost'),
122-
'port' => env('DB_PORT', '1433'),
123-
'database' => env('DB_DATABASE', 'laravel'),
124-
'username' => env('DB_USERNAME', 'root'),
125-
'password' => env('DB_PASSWORD', ''),
126-
'charset' => env('DB_CHARSET', 'utf8'),
127-
'prefix' => '',
128-
'prefix_indexes' => true,
129-
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
130-
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
131-
],
132-
13388
],
13489

13590
/*

database/migrations/2025_06_23_225051_create_configurations_table.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public function up(): void
1515
$table->id();
1616

1717
$table->string('company')->nullable();
18+
$table->string('company_primary_color')->nullable();
1819

20+
$table->json('component_intro');
21+
22+
$table->boolean('section_news')->default(false);
1923
$table->boolean('section_services')->default(false);
2024
$table->boolean('section_products')->default(false);
2125
$table->boolean('section_technologies')->default(false);

database/seeders/Codebar/ConfigurationsTableSeeder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Database\Seeders\Codebar;
44

5+
use App\Enums\LocaleEnum;
56
use App\Models\Configuration;
67
use Illuminate\Database\Seeder;
78

@@ -15,7 +16,14 @@ public function run(): void
1516
Configuration::updateOrCreate([], [
1617

1718
'company' => 'codebar Solutions AG',
19+
'company_primary_color' => '#500472',
1820

21+
'component_intro' => [
22+
LocaleEnum::DE->value => file_get_contents(database_path('seeders/files/codebar_intro_de.md')),
23+
LocaleEnum::EN->value => file_get_contents(database_path('seeders/files/codebar_intro_en.md')),
24+
],
25+
26+
'section_news' => false,
1927
'section_services' => false,
2028
'section_products' => false,
2129
'section_technologies' => true,

database/seeders/Codebar/ContactsTableSeeder.php

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function run(): void
1616
'name' => 'Sebastian Bürgin-Fix',
1717
'published' => true,
1818
'sections' => [
19-
ContactSectionEnum::EMPLOYEE_SERVICES => [
20-
'key' => ContactSectionEnum::EMPLOYEE_SERVICES,
19+
ContactSectionEnum::EMPLOYEES => [
20+
'key' => ContactSectionEnum::EMPLOYEES,
2121
'role' => [
2222
'de_CH' => 'Software-Architekt',
2323
'en_CH' => 'Software-Engineer',
@@ -38,45 +38,93 @@ public function run(): void
3838
Contact::updateOrCreate(
3939
['id' => 2],
4040
[
41-
'name' => 'Rhys Lees',
42-
'published' => false,
41+
'name' => 'Melanie Bürgin-Fix',
42+
'published' => true,
4343
'sections' => [
44-
ContactSectionEnum::EMPLOYEE_SERVICES => [
45-
'key' => ContactSectionEnum::EMPLOYEE_SERVICES,
44+
ContactSectionEnum::EMPLOYEES => [
45+
'key' => ContactSectionEnum::EMPLOYEES,
4646
'role' => [
47-
'de_CH' => 'Entwickler',
48-
'en_CH' => 'Developer',
47+
'de_CH' => 'Administration',
48+
'en_CH' => 'Administration',
4949
],
5050
],
51+
ContactSectionEnum::BOARD_MEMBERS => [
52+
'key' => ContactSectionEnum::BOARD_MEMBERS,
53+
],
5154
],
5255
'icons' => [
53-
'email' => 'rhys.leess@codebar.ch',
54-
'linkedin' => 'https://www.linkedin.com/in/rhys-lees',
56+
'email' => 'melanie.buergin@codebar.ch',
57+
'linkedin' => 'https://www.linkedin.com/in/melanie-buergin',
5558
],
56-
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/r_lees_e_background_removal_f_png.webp',
59+
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/codebar.webp',
5760
]
5861
);
5962

6063
Contact::updateOrCreate(
61-
['id' => 7],
64+
['id' => 3],
6265
[
63-
'name' => 'Sebastian Bürgin-Fix',
66+
'name' => 'Tobias Brogle',
6467
'published' => true,
68+
'sections' => [
69+
ContactSectionEnum::EMPLOYEES => [
70+
'key' => ContactSectionEnum::EMPLOYEES,
71+
'role' => [
72+
'de_CH' => 'Applikationsentwickler',
73+
'en_CH' => 'Application Developer',
74+
],
75+
],
76+
],
77+
'icons' => [
78+
'email' => 'tobias.brogle@codebar.ch',
79+
'linkedin' => null,
80+
],
81+
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/codebar.webp',
82+
]
83+
);
84+
85+
Contact::updateOrCreate(
86+
['id' => 4],
87+
[
88+
'name' => 'Alexander Christoph Boll',
89+
'published' => false,
90+
'sections' => [
91+
ContactSectionEnum::EMPLOYEES => [
92+
'key' => ContactSectionEnum::EMPLOYEES,
93+
'role' => [
94+
'de_CH' => 'Produktentwickler',
95+
'en_CH' => 'Product Developer',
96+
],
97+
],
98+
],
99+
'icons' => [
100+
'email' => 'alexander.boll@codebar.ch',
101+
'linkedin' => 'https://www.linkedin.com/in/alexanderboll',
102+
],
103+
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/codebar.webp',
104+
]
105+
);
106+
107+
Contact::updateOrCreate(
108+
['id' => 6],
109+
[
110+
'name' => 'PST GmbH',
111+
'published' => false,
65112
'sections' => [
66113
ContactSectionEnum::COLLABORATIONS => [
67114
'key' => ContactSectionEnum::COLLABORATIONS,
68115
'role' => [
69-
'de_CH' => 'paperflakes AG',
70-
'en_CH' => 'paperflakes AG',
116+
'de_CH' => 'Finanzen',
117+
'en_CH' => 'Finance',
71118
],
72119
],
73120
],
74121
'icons' => [
75-
'email' => 'info@paperflakes.ch',
76-
'website' => 'https://www.paperflakes.ch',
122+
'email' => 'info@pstgmbh.ch',
123+
'website' => 'https://www.pstgmbh.ch',
77124
],
78-
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/paperflakes.webp',
125+
'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/codebar.webp',
79126
]
80127
);
128+
81129
}
82130
}

database/seeders/Paperflakes/ConfigurationsTableSeeder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Database\Seeders\Paperflakes;
44

5+
use App\Enums\LocaleEnum;
56
use App\Models\Configuration;
67
use Illuminate\Database\Seeder;
78

@@ -14,7 +15,14 @@ public function run(): void
1415
{
1516
Configuration::updateOrCreate([], [
1617
'company' => 'paperflakes AG',
18+
'company_primary_color' => '#69b3a1',
1719

20+
'component_intro' => [
21+
LocaleEnum::DE->value => file_get_contents(database_path('seeders/files/paperflakes_intro_de.md')),
22+
LocaleEnum::EN->value => file_get_contents(database_path('seeders/files/paperflakes_intro_en.md')),
23+
],
24+
25+
'section_news' => true,
1826
'section_services' => true,
1927
'section_products' => true,
2028
'section_technologies' => false,

0 commit comments

Comments
 (0)