feat(api): add AI text-to-deck generation, wallet deposit structure, and profile/notification endpoints

Fills the gaps between the admin panel screens and the backend: a full
free-text + slide-count + language -> AI-generated presentation flow with
new slide-cloning logic in TemplateFillService, a "my presentations" list
endpoint, a swappable payment-gateway structure for wallet top-ups (fake
driver for now), and avatar upload / public-profile toggle / account
deletion / password change / notification preference endpoints.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-29 01:36:17 +03:30
parent fe2090a5af
commit 46ae711a20
42 changed files with 1632 additions and 44 deletions

View File

@@ -11,6 +11,14 @@ use Illuminate\Database\Eloquent\Model;
#[Hidden(['api_key'])]
class AiProvider extends Model
{
public static function resolveActiveDefault(): ?self
{
return static::query()
->where('is_active', true)
->orderByDesc('is_default')
->first();
}
public function resolvedBaseUrl(): string
{
return $this->base_url ?: $this->driver->defaultBaseUrl();

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable([
'user_id',
'comment_on_presentation',
'form_reply',
'new_follower',
'news_announcements',
'weekly_product_updates',
'weekly_blog_digest',
])]
class NotificationPreference extends Model
{
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'comment_on_presentation' => 'boolean',
'form_reply' => 'boolean',
'new_follower' => 'boolean',
'news_announcements' => 'boolean',
'weekly_product_updates' => 'boolean',
'weekly_blog_digest' => 'boolean',
];
}
}

View File

@@ -15,6 +15,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
'file_path',
'thumbnail_path',
'is_active',
'is_ai_enabled',
'ai_repeatable_slide_number',
'created_by',
])]
class Template extends Model
@@ -58,6 +60,8 @@ class Template extends Model
{
return [
'is_active' => 'boolean',
'is_ai_enabled' => 'boolean',
'ai_repeatable_slide_number' => 'integer',
];
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Enums\TemplateGenerationSource;
use App\Enums\TemplateGenerationStatus;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
@@ -10,6 +11,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable([
'template_id',
'uuid',
'source',
'title',
'language',
'slide_count',
'source_text',
'status',
'values',
'output_path',
@@ -40,8 +46,10 @@ class TemplateGeneration extends Model
protected function casts(): array
{
return [
'source' => TemplateGenerationSource::class,
'status' => TemplateGenerationStatus::class,
'values' => 'array',
'slide_count' => 'integer',
];
}
}

View File

@@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
'type',
'shape_name',
'is_required',
'is_repeatable',
'sort_order',
'description',
])]
@@ -47,6 +48,7 @@ class TemplateKey extends Model
return [
'type' => TemplateKeyType::class,
'is_required' => 'boolean',
'is_repeatable' => 'boolean',
'sort_order' => 'integer',
];
}

View File

@@ -17,7 +17,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
#[Fillable(['name', 'username', 'email', 'mobile', 'password'])]
#[Fillable(['name', 'username', 'email', 'mobile', 'password', 'avatar_path', 'is_public'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable implements FilamentUser
{
@@ -56,6 +56,22 @@ class User extends Authenticatable implements FilamentUser
return $this->hasMany(Notification::class)->latest();
}
/**
* @return HasOne<NotificationPreference, $this>
*/
public function notificationPreference(): HasOne
{
return $this->hasOne(NotificationPreference::class);
}
/**
* @return HasMany<TemplateGeneration, $this>
*/
public function templateGenerations(): HasMany
{
return $this->hasMany(TemplateGeneration::class, 'requested_by')->latest();
}
public function hasRole(string|array $roles): bool
{
$roles = (array) $roles;
@@ -87,6 +103,7 @@ class User extends Authenticatable implements FilamentUser
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_public' => 'boolean',
];
}
}

View File

@@ -26,6 +26,14 @@ class Wallet extends Model
return $this->hasMany(WalletTransaction::class)->latest();
}
/**
* @return HasMany<WalletDeposit, $this>
*/
public function deposits(): HasMany
{
return $this->hasMany(WalletDeposit::class)->latest();
}
/**
* @return array<string, string>
*/

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use App\Enums\WalletDepositStatus;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable([
'wallet_id',
'amount',
'status',
'gateway',
'reference_id',
'meta',
])]
class WalletDeposit extends Model
{
/**
* @return BelongsTo<Wallet, $this>
*/
public function wallet(): BelongsTo
{
return $this->belongsTo(Wallet::class);
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'amount' => 'integer',
'status' => WalletDepositStatus::class,
'meta' => 'array',
];
}
}