finished the upgrade to filament 4. completely revamped the frontend with codex, now it looks great!
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
$this->createSpatieSettingsTable();
|
||||
|
||||
$this->seedDefaultSettings();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('settings', 'group')) {
|
||||
// Already migrated.
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::rename('settings', 'legacy_settings');
|
||||
|
||||
$this->createSpatieSettingsTable();
|
||||
|
||||
$legacySettings = DB::table('legacy_settings')->pluck('value', 'key')->toArray();
|
||||
|
||||
$records = $this->buildSettingsRecords($legacySettings);
|
||||
|
||||
if (! empty($records)) {
|
||||
DB::table('settings')->insert($records);
|
||||
}
|
||||
|
||||
Schema::dropIfExists('legacy_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('settings', 'key')) {
|
||||
// Already reverted.
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::rename('settings', 'spatie_settings');
|
||||
|
||||
Schema::create('settings', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$spatieSettings = DB::table('spatie_settings')
|
||||
->where('group', 'general')
|
||||
->get(['name', 'payload']);
|
||||
|
||||
$now = now();
|
||||
|
||||
$rows = $spatieSettings
|
||||
->map(function ($setting) use ($now) {
|
||||
$value = json_decode($setting->payload, true);
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = $value ? '1' : '0';
|
||||
}
|
||||
|
||||
return [
|
||||
'key' => $setting->name,
|
||||
'value' => is_array($value) ? json_encode($value) : (string) $value,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
if (! empty($rows)) {
|
||||
DB::table('settings')->insert($rows);
|
||||
}
|
||||
|
||||
Schema::dropIfExists('spatie_settings');
|
||||
}
|
||||
|
||||
protected function createSpatieSettingsTable(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('group');
|
||||
$table->string('name');
|
||||
$table->boolean('locked')->default(false);
|
||||
$table->json('payload');
|
||||
$table->timestamps();
|
||||
$table->unique(['group', 'name']);
|
||||
});
|
||||
}
|
||||
|
||||
protected function buildSettingsRecords(array $legacySettings): array
|
||||
{
|
||||
$defaults = [
|
||||
'gallery_heading' => 'Style Gallery',
|
||||
'new_image_timespan_minutes' => 60,
|
||||
'image_refresh_interval' => 30_000,
|
||||
'max_number_of_copies' => 3,
|
||||
'show_print_button' => true,
|
||||
'selected_printer' => null,
|
||||
'custom_printer_address' => null,
|
||||
'default_style_id' => null,
|
||||
];
|
||||
|
||||
$intKeys = [
|
||||
'new_image_timespan_minutes',
|
||||
'image_refresh_interval',
|
||||
'max_number_of_copies',
|
||||
'default_style_id',
|
||||
];
|
||||
|
||||
$boolKeys = ['show_print_button'];
|
||||
|
||||
$now = now();
|
||||
|
||||
return collect($defaults)
|
||||
->map(function ($default, string $key) use ($legacySettings) {
|
||||
return array_key_exists($key, $legacySettings)
|
||||
? $legacySettings[$key]
|
||||
: $default;
|
||||
})
|
||||
->map(function ($value, string $key) use ($intKeys, $boolKeys) {
|
||||
if (in_array($key, $intKeys, true)) {
|
||||
return is_null($value) || $value === '' ? null : (int) $value;
|
||||
}
|
||||
|
||||
if (in_array($key, $boolKeys, true)) {
|
||||
if (is_null($value) || $value === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return in_array((string) $value, ['1', 'true', 'on'], true);
|
||||
}
|
||||
|
||||
return $value;
|
||||
})
|
||||
->map(function ($value, string $key) use ($now) {
|
||||
return [
|
||||
'group' => 'general',
|
||||
'name' => $key,
|
||||
'payload' => json_encode($value),
|
||||
'locked' => false,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
protected function seedDefaultSettings(): void
|
||||
{
|
||||
$records = $this->buildSettingsRecords([]);
|
||||
|
||||
if (! empty($records)) {
|
||||
DB::table('settings')->insert($records);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AiModelApiProviderSeeder extends Seeder
|
||||
{
|
||||
@@ -14,13 +12,11 @@ class AiModelApiProviderSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
['ai_model_id' => 2, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 5, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 6, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 7, 'api_provider_id' => 3],
|
||||
['ai_model_id' => 8, 'api_provider_id' => 1],
|
||||
]
|
||||
['ai_model_id' => 2, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 5, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 6, 'api_provider_id' => 1],
|
||||
['ai_model_id' => 7, 'api_provider_id' => 3],
|
||||
['ai_model_id' => 8, 'api_provider_id' => 1],
|
||||
];
|
||||
|
||||
// Update existing AI models with their API provider IDs
|
||||
@@ -28,4 +24,4 @@ class AiModelApiProviderSeeder extends Seeder
|
||||
\App\Models\AiModel::where('id', $row['ai_model_id'])->update(['api_provider_id' => $row['api_provider_id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\AiModel;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AiModelSeeder extends Seeder
|
||||
{
|
||||
@@ -13,66 +12,69 @@ class AiModelSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Für SQLite: Lösche alle existierenden Modelle und füge sie frisch ein
|
||||
AiModel::truncate();
|
||||
|
||||
$data = [
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'FLUX.1 Kontext [dev]',
|
||||
'model_type' => 'flux',
|
||||
'created_at' => '2025-07-27T20:46:32',
|
||||
'updated_at' => '2025-07-28T18:07:14',
|
||||
'model_id' => 'runware:106@1',
|
||||
'api_provider_id' => 1,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'AbsoluteReality',
|
||||
'model_type' => 'sd1.5',
|
||||
'created_at' => '2025-07-27T20:46:32',
|
||||
'updated_at' => '2025-07-27T20:46:32',
|
||||
'model_id' => 'civitai:81458@256668',
|
||||
'api_provider_id' => 0,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'name' => 'DreamShaper 8',
|
||||
'model_type' => 'sd1.5',
|
||||
'created_at' => '2025-07-27T20:46:32',
|
||||
'updated_at' => '2025-07-27T20:46:32',
|
||||
'model_id' => 'civitai:4384@252914',
|
||||
'api_provider_id' => 0,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'name' => 'FLUX.1 Kontext [dev] in ComfyUI',
|
||||
'model_type' => 'flux',
|
||||
'created_at' => '2025-07-31T18:51:48',
|
||||
'updated_at' => '2025-08-06 11:26:30',
|
||||
'model_id' => 'flux1-kontext-dev',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => " ... dein langer JSON-String hier ... ",
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'name' => 'HiDream-I1-Dev',
|
||||
'model_type' => 'base',
|
||||
'created_at' => '2025-08-08 10:46:29',
|
||||
'updated_at' => '2025-08-08 10:46:29',
|
||||
'model_id' => 'runware:97@2',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
];
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'FLUX.1 Kontext [dev]',
|
||||
'model_type' => 'flux',
|
||||
'created_at' => '2025-07-27T20:46:32.000000',
|
||||
'updated_at' => '2025-07-28T18:07:14.000000',
|
||||
'model_id' => 'runware:106@1',
|
||||
'api_provider_id' => null, // Verwende null statt 0 oder ungültiger IDs
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'AbsoluteReality',
|
||||
'model_type' => 'sd1.5',
|
||||
'created_at' => '2025-07-27T20:46:32.000000',
|
||||
'updated_at' => '2025-07-27T20:46:32.000000',
|
||||
'model_id' => 'civitai:81458@256668',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'name' => 'DreamShaper 8',
|
||||
'model_type' => 'sd1.5',
|
||||
'created_at' => '2025-07-27T20:46:32.000000',
|
||||
'updated_at' => '2025-07-27T20:46:32.000000',
|
||||
'model_id' => 'civitai:4384@252914',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'name' => 'FLUX.1 Kontext [dev] in ComfyUI',
|
||||
'model_type' => 'flux',
|
||||
'created_at' => '2025-07-31T18:51:48.000000',
|
||||
'updated_at' => '2025-08-06T11:26:30.000000',
|
||||
'model_id' => 'flux1-kontext-dev',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => json_encode(['example' => 'parameter']),
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'name' => 'HiDream-I1-Dev',
|
||||
'model_type' => 'base',
|
||||
'created_at' => '2025-08-08T10:46:29.000000',
|
||||
'updated_at' => '2025-08-08T10:46:29.000000',
|
||||
'model_id' => 'runware:97@2',
|
||||
'api_provider_id' => null,
|
||||
'enabled' => 1,
|
||||
'parameters' => null,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($data as $row) {
|
||||
AiModel::updateOrCreate(['id' => $row['id']], $row);
|
||||
AiModel::create($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use App\Settings\GeneralSettings;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Setting;
|
||||
|
||||
class SettingSeeder extends Seeder
|
||||
{
|
||||
@@ -13,39 +12,18 @@ class SettingSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
'id' => 1,
|
||||
'key' => 'gallery_heading',
|
||||
'value' => 'Eure Bilder aus der Fotoboxx',
|
||||
'created_at' => '2025-07-30T14:03:55',
|
||||
'updated_at' => '2025-08-01T11:05:52',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'key' => 'new_image_timespan_minutes',
|
||||
'value' => '10000',
|
||||
'created_at' => '2025-08-01T12:46:00',
|
||||
'updated_at' => '2025-08-01T12:49:52',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'key' => 'image_refresh_interval',
|
||||
'value' => '30000',
|
||||
'created_at' => '2025-08-06 13:39:27',
|
||||
'updated_at' => '2025-08-06 13:46:22',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'key' => 'max_number_of_copies',
|
||||
'value' => '3',
|
||||
'created_at' => '2025-08-08 11:05:20',
|
||||
'updated_at' => '2025-08-08 11:05:20',
|
||||
],
|
||||
];
|
||||
/** @var \App\Settings\GeneralSettings $settings */
|
||||
$settings = app(GeneralSettings::class);
|
||||
|
||||
foreach ($data as $row) {
|
||||
Setting::updateOrCreate(['id' => $row['id']], $row);
|
||||
}
|
||||
$settings->fill([
|
||||
'gallery_heading' => 'Eure Bilder aus der Fotoboxx',
|
||||
'new_image_timespan_minutes' => 10_000,
|
||||
'image_refresh_interval' => 30_000,
|
||||
'max_number_of_copies' => 3,
|
||||
'show_print_button' => true,
|
||||
'selected_printer' => null,
|
||||
'custom_printer_address' => null,
|
||||
'default_style_id' => null,
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user