Add AI photo import via Ollama Vision
Users can upload a photo of a nail polish bottle; a background queue job sends it to Ollama (llama3.2-vision at 192.168.30.172:11434), extracts name, number and manufacturer, then creates the nail polish and adds it to the user's collection automatically. - ProcessNailPolishImage job (180s timeout, 2 tries) - NailPolishImport model + migration (status tracking) - AiSetting model + migration (Ollama URL + model, admin-configurable) - NailPolishImportController: upload, status page (auto-refresh every 5s) - Admin\AiSettingController: configure Ollama connection - Views: drag-drop upload form, live status page, import history - Navbar: "Foto importieren" link for all users - Admin dropdown: "KI-Einstellungen" - neonail-worker.conf: Supervisor config for the queue worker Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7a24e554b0
commit
f715bc4552
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AiSetting extends Model
|
||||
{
|
||||
protected $table = 'ai_settings';
|
||||
|
||||
protected $fillable = ['ollama_url', 'ollama_model'];
|
||||
|
||||
public static function get(): self
|
||||
{
|
||||
return static::firstOrCreate([], [
|
||||
'ollama_url' => 'http://192.168.30.172:11434',
|
||||
'ollama_model' => 'llama3.2-vision',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NailPolishImport extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'image_path',
|
||||
'status',
|
||||
'result',
|
||||
'nail_polish_id',
|
||||
'error_message',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'result' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function nailPolish()
|
||||
{
|
||||
return $this->belongsTo(NailPolish::class);
|
||||
}
|
||||
|
||||
public function isPending(): bool
|
||||
{
|
||||
return in_array($this->status, ['pending', 'processing']);
|
||||
}
|
||||
|
||||
public function statusLabel(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
'pending' => 'Warten',
|
||||
'processing' => 'Verarbeitung',
|
||||
'done' => 'Fertig',
|
||||
'failed' => 'Fehler',
|
||||
default => $this->status,
|
||||
};
|
||||
}
|
||||
|
||||
public function statusColor(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
'pending' => 'warning',
|
||||
'processing' => 'info',
|
||||
'done' => 'success',
|
||||
'failed' => 'danger',
|
||||
default => 'secondary',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,11 @@ class User extends Authenticatable
|
||||
return $this->belongsToMany(NailPolish::class, 'user_nail_polishes', 'user_id', 'nail_polish_id');
|
||||
}
|
||||
|
||||
public function nailPolishImports()
|
||||
{
|
||||
return $this->hasMany(\App\Models\NailPolishImport::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob der User ein Admin ist
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user