feat(AI): add ai manager admin and create powerpoint with ai

This commit is contained in:
2026-07-22 08:06:48 +03:30
parent ae974c2afa
commit 4a3c109bf3
23 changed files with 743 additions and 23 deletions

31
app/Models/AiProvider.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use App\Enums\AiProviderDriver;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Model;
#[Fillable(['name', 'driver', 'model', 'base_url', 'api_key', 'is_active', 'is_default'])]
#[Hidden(['api_key'])]
class AiProvider extends Model
{
public function resolvedBaseUrl(): string
{
return $this->base_url ?: $this->driver->defaultBaseUrl();
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'driver' => AiProviderDriver::class,
'api_key' => 'encrypted',
'is_active' => 'boolean',
'is_default' => 'boolean',
];
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use App\Enums\TemplateKeyType;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -27,6 +28,17 @@ class TemplateKey extends Model
return $this->belongsTo(Template::class);
}
/**
* Strip any literal curly braces the admin may have copied from the pptx placeholder
* (e.g. "{Main Title}" -> "Main Title"), since braces are added automatically at match time.
*/
protected function key(): Attribute
{
return Attribute::make(
set: fn (string $value) => trim($value, "{} \t\n\r\0\x0B"),
);
}
/**
* @return array<string, string>
*/