Neuigkeiten und Termine (vorgezogen)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m8s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m5s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m6s
CI / Build-Artefakte aktuell (pull_request) Failing after 43s
- Neuigkeiten mit Kategorien, Titelbild (WebP-Varianten), Lesezeit, geplanter Veröffentlichung und Hervorhebung; Text wird beim Speichern bereinigt - Termine mit Ort, Online-Link, ganztägigen Terminen und .ics-Export - Startseite nach Intranet-Vorbild: Slider, Neuigkeiten, Termine, Aktuelles aus den Bereichen; mobil in sinnvoller Reihenfolge - Admin: Beiträge, Kategorien und Termine - Bildverarbeitung für Shared Hosting: nur eine Vollbild-Kopie im Speicher, Speicherlimit bei Bedarf auf 256 MB angehoben (wie WordPress) - Demo-Inhalte für die Entwicklung Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f813a0fff3
commit
a36752e09a
103 changed files with 2810 additions and 124 deletions
27
database/factories/EventFactory.php
Normal file
27
database/factories/EventFactory.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Event>
|
||||
*/
|
||||
class EventFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
$start = now()->addDays(fake()->numberBetween(1, 30))->setTime(10, 0);
|
||||
|
||||
return [
|
||||
'title' => fake()->sentence(4),
|
||||
'description' => '<p>'.fake()->paragraph().'</p>',
|
||||
'location' => fake()->city(),
|
||||
'starts_at' => $start,
|
||||
'ends_at' => $start->copy()->addHours(2),
|
||||
'all_day' => false,
|
||||
'is_published' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
24
database/factories/NewsCategoryFactory.php
Normal file
24
database/factories/NewsCategoryFactory.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\NewsCategory;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<NewsCategory>
|
||||
*/
|
||||
class NewsCategoryFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->words(2, true);
|
||||
|
||||
return [
|
||||
'name' => Str::title($name),
|
||||
'slug' => Str::slug($name),
|
||||
'sort' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/NewsPostFactory.php
Normal file
32
database/factories/NewsPostFactory.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\NewsPost;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<NewsPost>
|
||||
*/
|
||||
class NewsPostFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'title' => fake()->sentence(6),
|
||||
'teaser' => fake()->sentence(15),
|
||||
'body' => '<p>'.fake()->paragraph(5).'</p>',
|
||||
'published_at' => now()->subDay(),
|
||||
];
|
||||
}
|
||||
|
||||
public function draft(): static
|
||||
{
|
||||
return $this->state(fn () => ['published_at' => null]);
|
||||
}
|
||||
|
||||
public function scheduled(): static
|
||||
{
|
||||
return $this->state(fn () => ['published_at' => now()->addDay()]);
|
||||
}
|
||||
}
|
||||
47
database/migrations/2026_09_26_000001_create_news_tables.php
Normal file
47
database/migrations/2026_09_26_000001_create_news_tables.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('news_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('description', 500)->nullable();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('news_posts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->nullable()->constrained('news_categories')->nullOnDelete();
|
||||
$table->foreignId('author_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('teaser')->nullable();
|
||||
$table->longText('body')->nullable();
|
||||
// Beim Speichern gerendert und bereinigt – die Ausgabe kostet keine Rechenzeit.
|
||||
$table->longText('body_html')->nullable();
|
||||
$table->unsignedSmallInteger('reading_minutes')->default(1);
|
||||
$table->string('cover_path')->nullable();
|
||||
$table->boolean('is_featured')->default(false);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('published_at');
|
||||
$table->index(['category_id', 'published_at']);
|
||||
$table->index(['is_featured', 'published_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('news_posts');
|
||||
Schema::dropIfExists('news_categories');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('author_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('title');
|
||||
$table->longText('description')->nullable();
|
||||
$table->longText('description_html')->nullable();
|
||||
$table->string('location')->nullable();
|
||||
$table->string('online_url', 500)->nullable();
|
||||
$table->timestamp('starts_at');
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
$table->boolean('all_day')->default(false);
|
||||
$table->string('image_path')->nullable();
|
||||
$table->boolean('is_published')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['is_published', 'starts_at']);
|
||||
$table->index(['is_published', 'ends_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
};
|
||||
|
|
@ -37,5 +37,7 @@ class DatabaseSeeder extends Seeder
|
|||
['label' => 'Ideenbox', 'url' => 'https://example.com/ideen', 'icon' => 'lightbulb', 'new_tab' => true],
|
||||
['label' => 'Personen', 'url' => '/personen', 'icon' => 'users', 'new_tab' => false],
|
||||
]);
|
||||
|
||||
$this->call(DemoContentSeeder::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
145
database/seeders/DemoContentSeeder.php
Normal file
145
database/seeders/DemoContentSeeder.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\NewsCategory;
|
||||
use App\Models\NewsPost;
|
||||
use App\Models\User;
|
||||
use App\Support\Branding;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Demo-Inhalte für Entwicklung und Vorführung. Bilder kommen – wenn Netz da ist –
|
||||
* von picsum.photos (frei nutzbare Unsplash-Fotos), sonst als ruhige Farbflächen.
|
||||
*/
|
||||
class DemoContentSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$authors = User::query()->inRandomOrder()->limit(5)->get();
|
||||
|
||||
$categories = collect([
|
||||
'Unternehmen', 'Arbeit & Bildung', 'Menschen', 'Nachhaltigkeit', 'Freizeit & Kultur', 'Verwaltung',
|
||||
])->mapWithKeys(fn (string $name, int $i) => [$name => NewsCategory::query()->create([
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name, language: 'de'),
|
||||
'sort' => $i,
|
||||
])]);
|
||||
|
||||
$posts = [
|
||||
['Unternehmen', 'Gemeinsam Zukunft gestalten: Strategie 2030 gestartet', 'Mit der neuen Unternehmensstrategie richten wir uns auf Teilhabe, Qualität und nachhaltige Entwicklung aus.', true, 'strategie'],
|
||||
['Menschen', 'Herzlich willkommen im Team! Unsere neuen Kolleginnen und Kollegen', 'Im Mai haben zwölf neue Mitarbeitende bei uns angefangen – wir stellen sie vor.', true, 'team'],
|
||||
['Arbeit & Bildung', 'CNC-Schulung erfolgreich abgeschlossen', 'Herzlichen Glückwunsch an alle Teilnehmenden der dreimonatigen Weiterbildung.', true, 'werkstatt'],
|
||||
['Unternehmen', 'Rückblick: Mitarbeitendenversammlung 2025', 'Die wichtigsten Themen, Zahlen und Fragen aus der Versammlung im Überblick.', false, 'versammlung'],
|
||||
['Nachhaltigkeit', 'Photovoltaik auf dem Dach der Werkstatt in Betrieb', 'Seit dieser Woche erzeugen wir einen großen Teil unseres Stroms selbst.', false, 'solar'],
|
||||
['Verwaltung', 'Digitalisierung: Neue Software für die Dienstplanung', 'Ab Juni planen alle Bereiche ihre Dienste in einer gemeinsamen Anwendung.', false, 'buero'],
|
||||
['Freizeit & Kultur', 'Inklusives Fußballturnier – ein voller Erfolg!', 'Fairer Sport, tolle Stimmung und viele strahlende Gesichter beim Sommerturnier.', false, 'fussball'],
|
||||
['Arbeit & Bildung', 'Neue Maßnahmen im Arbeitsbereich Holz gestartet', 'Drei neue Angebote erweitern die berufliche Bildung ab dem Herbst.', false, 'holz'],
|
||||
['Nachhaltigkeit', 'Blühwiese statt Rasen: Artenvielfalt am Standort', 'Auf 800 Quadratmetern summt und blüht es jetzt – ein Projekt der Gartengruppe.', false, 'wiese'],
|
||||
['Menschen', '25 Jahre dabei: Ein Gespräch mit Maria Hoffmann', 'Wie sich die Arbeit verändert hat und was gleich geblieben ist.', false, 'portrait'],
|
||||
['Verwaltung', 'Informationen zur Entgeltabrechnung Mai', 'Was sich durch die neue Tarifrunde auf Ihrer Abrechnung ändert.', false, null],
|
||||
['Freizeit & Kultur', 'Betriebsfest 2025: Jetzt anmelden', 'Musik, Essen und Programm für die ganze Familie – wir freuen uns auf Sie.', false, 'fest'],
|
||||
];
|
||||
|
||||
foreach ($posts as $i => [$category, $title, $teaser, $featured, $image]) {
|
||||
NewsPost::query()->create([
|
||||
'category_id' => $categories[$category]->id,
|
||||
'author_id' => $authors->random()->id,
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'body' => $this->body($teaser),
|
||||
'is_featured' => $featured,
|
||||
'cover_path' => $image ? $this->image("news/demo-{$image}.jpg", $image) : null,
|
||||
'published_at' => now()->subHours(3 + $i * 19),
|
||||
]);
|
||||
}
|
||||
|
||||
NewsPost::query()->create([
|
||||
'category_id' => $categories['Unternehmen']->id,
|
||||
'title' => 'Entwurf: Ausblick auf das zweite Halbjahr',
|
||||
'teaser' => 'Dieser Beitrag ist noch nicht veröffentlicht.',
|
||||
'body' => '<p>Entwurf.</p>',
|
||||
]);
|
||||
|
||||
$events = [
|
||||
['Betriebsfest 2025', 'Außenbereich Hauptstandort', 12, 14, 18, false, 'fest'],
|
||||
['Fortbildung: Unterstützte Kommunikation', 'Bildungswerk, Seminarraum 2', 5, 9, 16, false, null],
|
||||
['Teamschulung Führungskräfte', 'Seminarraum 1, Verwaltung', 9, 10, 15, false, null],
|
||||
['Inklusionstag', 'Marktplatz', 20, 0, 0, true, 'inklusion'],
|
||||
['Sprechstunde der Mitarbeitervertretung', 'MAV-Büro, Raum 1.12', 2, 13, 15, false, null],
|
||||
['Erste-Hilfe-Auffrischung', 'Schulungsraum Werkstatt', 16, 8, 12, false, null],
|
||||
];
|
||||
|
||||
foreach ($events as [$title, $location, $inDays, $from, $to, $allDay, $image]) {
|
||||
$day = now()->addDays($inDays)->startOfDay();
|
||||
|
||||
Event::query()->create([
|
||||
'author_id' => $authors->random()->id,
|
||||
'title' => $title,
|
||||
'description' => '<p>Weitere Informationen folgen. Bei Fragen wenden Sie sich bitte an die Organisatorinnen und Organisatoren.</p>',
|
||||
'location' => $location,
|
||||
'starts_at' => $allDay ? $day : $day->copy()->setHour($from),
|
||||
'ends_at' => $allDay ? null : $day->copy()->setHour($to),
|
||||
'all_day' => $allDay,
|
||||
'image_path' => $image ? $this->image("events/demo-{$image}.jpg", $image) : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function body(string $teaser): string
|
||||
{
|
||||
return "<p>{$teaser}</p>"
|
||||
.'<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum.</p>'
|
||||
.'<h2>Was sich ändert</h2>'
|
||||
.'<ul><li>Klare Ansprechpersonen in jedem Bereich</li><li>Mehr Informationen direkt im Portal</li><li>Regelmäßige Rückblicke und Ausblicke</li></ul>'
|
||||
.'<p>Maecenas sed diam eget risus varius blandit sit amet non magna. Vestibulum id ligula porta felis euismod semper. Aenean lacinia bibendum nulla sed consectetur.</p>'
|
||||
.'<blockquote><p>„Gemeinsam erreichen wir mehr – das zeigt dieses Projekt.“</p></blockquote>'
|
||||
.'<p>Nullam quis risus eget urna mollis ornare vel eu leo. Fragen beantwortet gern das Redaktionsteam.</p>';
|
||||
}
|
||||
|
||||
private function image(string $path, string $seed): string
|
||||
{
|
||||
$disk = Storage::disk('uploads');
|
||||
|
||||
if ($disk->exists($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::timeout(10)->get("https://picsum.photos/seed/inhaus-{$seed}/1600/900");
|
||||
|
||||
if ($response->successful() && str_starts_with((string) $response->header('Content-Type'), 'image/')) {
|
||||
$disk->put($path, $response->body());
|
||||
|
||||
return $path;
|
||||
}
|
||||
} catch (Throwable) {
|
||||
// Kein Netz – Farbfläche als Ersatz.
|
||||
}
|
||||
|
||||
$disk->put($path, $this->placeholder($seed));
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
private function placeholder(string $seed): string
|
||||
{
|
||||
$palette = app(Branding::class)->palette();
|
||||
$shades = [$palette[700], $palette[800], $palette[900], $palette[600]];
|
||||
[$r, $g, $b] = sscanf($shades[crc32($seed) % count($shades)], '#%02x%02x%02x');
|
||||
|
||||
$image = imagecreatetruecolor(1600, 900);
|
||||
imagefill($image, 0, 0, imagecolorallocate($image, $r, $g, $b));
|
||||
imagefilledellipse($image, 1300, 200, 1100, 1100, imagecolorallocatealpha($image, 255, 255, 255, 115));
|
||||
|
||||
ob_start();
|
||||
imagejpeg($image, null, 85);
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue