more seeders, drop-down for profile

This commit is contained in:
Alexander Gabriel 2026-06-28 15:36:47 +00:00
parent 3ccc525313
commit a4a36087e4
6 changed files with 66 additions and 3 deletions

View File

@ -21,7 +21,8 @@ class ConvertToComic implements ShouldQueue
{
$absolutePath = Storage::disk('public')->path($this->photoJob->image_path);
$photoprofile = Photoprofile::where('active', 1)->first();
$photoprofile = $this->photoJob->photoprofile
?? Photoprofile::where('active', 1)->first();
$photocommands = [];
foreach (explode(PHP_EOL, $photoprofile->commands) as $command) {
if (count($photocommands) > 0) $photocommands[] = ' && gmic ' . escapeshellarg($absolutePath) . ' ' . $command . ' -o ' . escapeshellarg($absolutePath);

View File

@ -4,6 +4,7 @@ namespace App\Livewire;
use App\Jobs\ConvertToComic;
use App\Models\PhotoJob;
use App\Models\Photoprofile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Livewire\Component;
@ -11,6 +12,12 @@ use Livewire\Component;
class CameraCapture extends Component
{
public string $status = '';
public ?int $photoprofileId = null;
public function mount(): void
{
$this->photoprofileId = Photoprofile::where('active', 1)->value('id');
}
public function delete(int $jobId): void
{
@ -39,6 +46,7 @@ class CameraCapture extends Component
$job = PhotoJob::create([
'image_path' => $filename,
'status' => 'processing',
'photoprofile_id' => $this->photoprofileId,
]);
ConvertToComic::dispatch($job);
@ -55,7 +63,8 @@ class CameraCapture extends Component
]);
$hasProcessing = $recentPhotos->contains('status', 'processing');
$photoprofiles = Photoprofile::where('active', 1)->pluck('name', 'id');
return view('livewire.camera-capture', compact('recentPhotos', 'hasProcessing'));
return view('livewire.camera-capture', compact('recentPhotos', 'hasProcessing', 'photoprofiles'));
}
}

View File

@ -3,8 +3,14 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Photoprofile;
class PhotoJob extends Model
{
protected $fillable = ['image_path', 'status'];
protected $fillable = ['image_path', 'status', 'photoprofile_id'];
public function photoprofile()
{
return $this->belongsTo(Photoprofile::class);
}
}

View File

@ -0,0 +1,28 @@
<?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::table('photo_jobs', function (Blueprint $table) {
$table->foreignId('photoprofile_id')->nullable()->constrained('photoprofiles')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('photo_jobs', function (Blueprint $table) {
$table->dropForeignIdFor(\App\Models\Photoprofile::class);
});
}
};

View File

@ -15,6 +15,16 @@ class PhotoprofileSeeder extends Seeder
'active' => true,
'commands' => 'simplelocalcontrast_p 16,2,0,1,1,1,1,1,1,1,1,0
cl_comic 4,1,0,0,1,15,15,1,10,20,6,2,0,0,0,0,0,0,50,50',
],
[
'name' => 'edges',
'active' => true,
'commands' => 'fx_canny 5,0.05,0.15,1',
],
[
'name' => 'tron',
'active' => true,
'commands' => 'samj_chalkitup 5,2.5,1.5,50,1,5,5,0,0,7,0.8,1.9,7,0',
]
];

View File

@ -15,6 +15,15 @@
</div>
</div>
<div class="mt-6 w-full max-w-xs">
<select wire:model="photoprofileId"
class="w-full rounded-full bg-white/10 text-white border border-white/20 px-5 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-white/40 appearance-none text-center">
@foreach ($photoprofiles as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</select>
</div>
<button id="capture-btn"
wire:loading.attr="disabled"
@disabled($hasProcessing)