Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/Actions/ViewDataAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use App\Models\Configuration;
use App\Models\Contact;
use App\Models\News;
use App\Models\OpenSource;
use App\Models\Product;
use App\Models\Service;
use App\Models\Technology;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -51,6 +53,24 @@ public function news(string $locale): Collection
});
}

public function technologies(string $locale): Collection
{
$key = Str::slug("technologies_published_{$locale}");

return Cache::rememberForever($key, function () use ($locale) {
return Technology::where('locale', $locale)->where('published', true)->orderBy('order')->get();
});
}

public function openSource(string $locale): Collection
{
$key = Str::slug("open_source_published_{$locale}");

return Cache::rememberForever($key, function () use ($locale) {
return OpenSource::where('locale', $locale)->where('published', true)->orderByDesc('downloads')->get();
});
}

public function contacts(string $locale): object
{
$key = Str::slug("contacts_published_{$locale}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OpenSoruceShowController extends Controller
*/
public function __invoke(string $locale, Product $product): View
{
return view('app.products.show')->with([
return view('app.open-source.show')->with([
'page' => (new PageAction(locale: $locale))->product(product: $product),
'name' => $product->name,
'teaser' => $product->teaser,
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/OpenSource/OpenSourceIndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public function __invoke(): View
{
$locale = app()->getLocale();

return view('app.products.index')->with([
'page' => (new PageAction(locale: null, routeName: 'products.index'))->default(),
'products' => (new ViewDataAction)->products($locale),
return view('app.open-source.index')->with([
'page' => (new PageAction(locale: null, routeName: 'open-source.index'))->default(),
'openSource' => (new ViewDataAction)->openSource($locale),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public function __invoke(): View
{
$locale = app()->getLocale();

return view('app.products.index')->with([
'page' => (new PageAction(locale: null, routeName: 'products.index'))->default(),
'products' => (new ViewDataAction)->products($locale),
return view('app.technologies.index')->with([
'page' => (new PageAction(locale: null, routeName: 'technologies.index'))->default(),
'technologies' => (new ViewDataAction)->technologies($locale),
]);
}
}
28 changes: 28 additions & 0 deletions app/Models/OpenSource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Models;

use App\Enums\LocaleEnum;
use App\Traits\HasLocalizedReferences;
use App\Traits\HasLocalizedRouteBinding;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class OpenSource extends Model
{
use HasFactory;
use HasLocalizedReferences;
use HasLocalizedRouteBinding;

protected $casts = [
'published' => 'boolean',
'locale' => LocaleEnum::class,
'tags' => 'json',
'downloads' => 'int',
];

public function getRouteKeyName(): string
{
return 'slug';
}
}
27 changes: 27 additions & 0 deletions app/Models/Technology.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Models;

use App\Enums\LocaleEnum;
use App\Traits\HasLocalizedReferences;
use App\Traits\HasLocalizedRouteBinding;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Technology extends Model
{
use HasFactory;
use HasLocalizedReferences;
use HasLocalizedRouteBinding;

protected $casts = [
'published' => 'boolean',
'locale' => LocaleEnum::class,
'tags' => 'json',
];

public function getRouteKeyName(): string
{
return 'slug';
}
}
23 changes: 23 additions & 0 deletions database/factories/OpenSourceFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OpenSource>
*/
class OpenSourceFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
23 changes: 23 additions & 0 deletions database/factories/TechnologyFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Technology>
*/
class TechnologyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('open_sources', function (Blueprint $table) {
$table->id();
$table->boolean('published')->default(false);
$table->string('locale');
$table->string('title');
$table->string('slug');
$table->string('teaser');
$table->longText('content')->nullable();
$table->string('image');
$table->json('tags')->nullable();
$table->string('link')->nullable();
$table->integer('downloads')->nullable();
$table->string('version')->nullable();
$table->timestamps();

$table->unique(['slug', 'locale']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('open_sources');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('technologies', function (Blueprint $table) {
$table->id();
$table->boolean('published')->default(false);
$table->string('locale');
$table->string('group');
$table->integer('order');
$table->string('title');
$table->string('slug');
$table->string('teaser');
$table->longText('content')->nullable();
$table->string('image');
$table->json('tags')->nullable();
$table->string('link')->nullable();
$table->timestamps();
$table->unique(['slug', 'locale']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('technologies');
}
};
101 changes: 101 additions & 0 deletions database/seeders/Codebar/NewsTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

namespace Database\Seeders\Codebar;

use App\Models\News;
use Illuminate\Database\Seeder;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;

class NewsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{

$this->seed(
publishedAt: Carbon::parse('2025-04-06'),
author: 'Sebastian Bürgin-Fix',
localizedData: [
'de_CH' => [
'title' => 'Hello World! codebar stellt sich vor.',
'slug' => 'dhello-world-codebar-stellt-sich-vor',
'teaser' => 'Computerprogramme werden vielfach in fernen Ländern entwickelt, nicht aber bei codebar. Hier gibt es «Software made in Basel». Wir haben Sebastian Fix, den Geschäftsführer dieses Start-ups, nach der Idee dahinter gefragt.',
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
'content' => file_get_contents(database_path('files/news/de_CH/20250406_docuware_712.md')),
'tags' => ['DMS/ECM', 'DocuWare'],
],
'en_CH' => [
'title' => 'DocuWare 7.12 is here',
'slug' => 'docuware-7-12-is-here',
'teaser' => 'More automation, more insights, more efficiency',
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
'content' => file_get_contents(database_path('files/news/en_CH/20250406_docuware_712.md')),
'tags' => ['DMS/ECM', 'DocuWare'],

],
]
);

$this->seed(
publishedAt: Carbon::parse('2025-04-06'),
author: 'Sebastian Bürgin-Fix',
localizedData: [
'de_CH' => [
'title' => 'DocuWare und codebar Solutions AG: Zwei Partner, eine Mission',
'slug' => 'docu-ware-cloud-partner',
'teaser' => 'Die codebar Solutions AG ist seit Februar 2023 offizieller Partner der Dokumenten-Management-Lösung (DMS) DocuWare Cloud. Dadurch haben unsere Kund*innen ab sofort ein Tool an der Hand, welches ihnen helfen wird, die Digitalisierung im eigenen Unternehmen voranzutreiben.',
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
'content' => file_get_contents(database_path('files/news/de_CH/20250406_docuware_712.md')),
'tags' => ['DMS/ECM', 'DocuWare'],
],
'en_CH' => [
'title' => 'DocuWare 7.12 is here',
'slug' => 'docuware-7-12-is-here',
'teaser' => 'More automation, more insights, more efficiency',
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
'content' => file_get_contents(database_path('files/news/en_CH/20250406_docuware_712.md')),
'tags' => ['DMS/ECM', 'DocuWare'],

],
]
);

}

private function seed(Carbon $publishedAt, string $author, array $localizedData): void
{
$entries = collect($localizedData)->map(function ($data, $locale) use ($author, $publishedAt) {
$slug = Str::slug(Arr::get($data, 'slug'), '-', $locale);

return News::updateOrCreate(
[
'locale' => $locale,
'slug' => $slug,
],
[
'author' => $author,
'published_at' => $publishedAt,
'title' => Arr::get($data, 'title'),
'teaser' => Arr::get($data, 'teaser'),
'image' => Arr::get($data, 'image'),
'tags' => Arr::get($data, 'tags', []),
'content' => Arr::get($data, 'content'),
]
);
});

$entries->each(function (News $entry) use ($entries) {
$entries->each(function (News $reference) use ($entry) {
$entry->references()->updateOrCreate([
'reference_type' => get_class($reference),
'reference_id' => $reference->id,
'reference_locale' => $reference->locale,
]);
});
});
}
}
Loading