first commit
This commit is contained in:
commit
405df0a122
3083 changed files with 69203 additions and 0 deletions
72
app/Console/Commands/GenerateDomainFavicons.php
Normal file
72
app/Console/Commands/GenerateDomainFavicons.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class GenerateDomainFavicons extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'domains:generate-favicons';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generiere Favicons für alle konfigurierten Domains';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$domains = config('domains');
|
||||
$faviconDir = public_path('img/favicons');
|
||||
|
||||
// Erstelle das Favicon-Verzeichnis, wenn es nicht existiert
|
||||
if (!File::exists($faviconDir)) {
|
||||
File::makeDirectory($faviconDir, 0755, true);
|
||||
$this->info("Verzeichnis {$faviconDir} erstellt.");
|
||||
}
|
||||
|
||||
// Erstelle eine Liste der Themes, für die wir Favicons erstellen müssen
|
||||
$themes = [];
|
||||
|
||||
foreach ($domains as $domain => $config) {
|
||||
if (is_array($config) && isset($config['theme'])) {
|
||||
$themes[$config['theme']] = [
|
||||
'domain' => $domain,
|
||||
'name' => $config['name'] ?? 'Website',
|
||||
'color' => $config['color_scheme']['primary'] ?? '#000000',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Erstelle die Favicons
|
||||
foreach ($themes as $theme => $data) {
|
||||
$faviconPath = "{$faviconDir}/{$theme}-favicon.ico";
|
||||
|
||||
// Wenn die Datei bereits existiert, frage, ob sie überschrieben werden soll
|
||||
if (File::exists($faviconPath) && !$this->confirm("Favicon für '{$theme}' existiert bereits. Überschreiben?")) {
|
||||
$this->info("Favicon für '{$theme}' übersprungen.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Hier könntest du mit einer externen Bibliothek einen Favicon erstellen
|
||||
// Da dies aber komplex sein kann, erstellen wir erstmal nur Platzhalter-Dateien
|
||||
File::put($faviconPath, '');
|
||||
|
||||
$this->info("Platzhalter-Favicon für '{$theme}' erstellt: {$faviconPath}");
|
||||
$this->comment("Ersetze diese Datei mit einem echten Favicon für {$data['domain']} ({$data['name']})");
|
||||
}
|
||||
|
||||
$this->info('Favicons wurden erfolgreich erstellt!');
|
||||
$this->line('Denke daran, die Platzhalter-Dateien mit echten Favicons zu ersetzen.');
|
||||
}
|
||||
}
|
||||
138
app/Console/Commands/MigratePresseData.php
Normal file
138
app/Console/Commands/MigratePresseData.php
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
// Import der Models für die NEUE Struktur
|
||||
use App\Models\User as NewUser;
|
||||
use App\Models\Article as NewArticle;
|
||||
use App\Models\Brand;
|
||||
|
||||
// Import der Models für die ALTE Struktur
|
||||
use App\Models\Legacy\Presseecho\User as LegacyUser;
|
||||
use App\Models\Legacy\Presseecho\Article as LegacyArticle;
|
||||
|
||||
class MigratePresseechoData extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'migrate:presseecho';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migrates all data from the old presseecho.de database to the new central database';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting migration for presseecho.de...');
|
||||
|
||||
// Holen der Brand-ID für Presseecho aus der neuen DB
|
||||
$brand = Brand::where('domain', 'presseecho.de')->first();
|
||||
if (!$brand) {
|
||||
$this->error('Brand "presseecho.de" not found in the new database. Please seed brands first.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Deaktivieren von Foreign Key Checks für reibungsloses Einfügen
|
||||
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=0;');
|
||||
|
||||
// Starten der einzelnen Migrationsschritte
|
||||
$this->migrateUsers();
|
||||
$this->migrateArticles($brand->id);
|
||||
// $this->migrateCategories($brand->id); // Weitere Schritte hier hinzufügen
|
||||
|
||||
// Reaktivieren der Foreign Key Checks
|
||||
DB::connection('mysql')->statement('SET FOREIGN_KEY_CHECKS=1;');
|
||||
|
||||
$this->info('Migration for presseecho.de completed successfully!');
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function migrateUsers()
|
||||
{
|
||||
$this->line('Migrating users...');
|
||||
$progressBar = $this->output->createProgressBar(LegacyUser::count());
|
||||
$progressBar->start();
|
||||
|
||||
// Chunking verwenden, um den Speicher bei vielen Nutzern zu schonen
|
||||
LegacyUser::chunk(200, function ($legacyUsers) use ($progressBar) {
|
||||
foreach ($legacyUsers as $legacyUser) {
|
||||
// Prüfen, ob der Nutzer (anhand der E-Mail) bereits in der neuen DB existiert
|
||||
$existingUser = NewUser::where('email', $legacyUser->email)->first();
|
||||
|
||||
if (!$existingUser) {
|
||||
// Nutzer existiert noch nicht -> neu anlegen
|
||||
NewUser::create([
|
||||
'name' => $legacyUser->name,
|
||||
'email' => $legacyUser->email,
|
||||
'password' => $legacyUser->password, // Annahme: Passwörter sind bereits gehasht. Wenn nicht: Hash::make(Str::random(16)) und Passwort-Reset erzwingen
|
||||
'email_verified_at' => $legacyUser->created_at, // oder ein anderer Zeitstempel
|
||||
'created_at' => $legacyUser->created_at,
|
||||
'updated_at' => $legacyUser->updated_at,
|
||||
// ... weitere Felder mappen
|
||||
]);
|
||||
}
|
||||
$progressBar->advance();
|
||||
}
|
||||
});
|
||||
|
||||
$progressBar->finish();
|
||||
$this->newLine(2);
|
||||
}
|
||||
|
||||
private function migrateArticles(int $brandId)
|
||||
{
|
||||
$this->line('Migrating articles...');
|
||||
$progressBar = $this->output->createProgressBar(LegacyArticle::count());
|
||||
$progressBar->start();
|
||||
|
||||
LegacyArticle::chunk(200, function ($legacyArticles) use ($brandId, $progressBar) {
|
||||
foreach ($legacyArticles as $legacyArticle) {
|
||||
// Den zugehörigen Nutzer in der NEUEN Datenbank finden
|
||||
$author = NewUser::where('email', $legacyArticle->author_email)->first(); // Annahme: Artikel hat eine Autoren-E-Mail
|
||||
|
||||
if (!$author) {
|
||||
$this->warn("Skipping article ID {$legacyArticle->id}, author with email {$legacyArticle->author_email} not found.");
|
||||
continue; // Artikel überspringen, wenn kein Autor gefunden wurde
|
||||
}
|
||||
|
||||
// Neuen Artikel in der zentralen DB erstellen
|
||||
$newArticle = NewArticle::create([
|
||||
'user_id' => $author->id,
|
||||
'title' => $legacyArticle->title,
|
||||
'slug' => $legacyArticle->slug, // oder neu generieren: Str::slug($legacyArticle->title)
|
||||
'content' => $legacyArticle->body, // Spaltennamen anpassen
|
||||
'created_at' => $legacyArticle->created_at,
|
||||
'updated_at' => $legacyArticle->updated_at,
|
||||
// ... weitere Felder mappen
|
||||
]);
|
||||
|
||||
// Den Artikel mit der Plattform "Presseecho" verknüpfen
|
||||
// Dies fügt den Eintrag in die Pivot-Tabelle `article_platform` ein
|
||||
$newArticle->platforms()->attach($brandId, [
|
||||
'status' => 'published', // oder den alten Status übernehmen
|
||||
'published_at' => $legacyArticle->published_date,
|
||||
// eventuell weitere Pivot-Daten
|
||||
]);
|
||||
|
||||
$progressBar->advance();
|
||||
}
|
||||
});
|
||||
|
||||
$progressBar->finish();
|
||||
$this->newLine(2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue