Initial commit: Runware-powered content generator foundation

Laravel app with a cost-tracked Runware.ai integration (image, video,
text generation), a hard monthly EUR budget cap with live USD/EUR FX
conversion, and a locally-maintained model/pricing table since
Runware's model-search API doesn't expose pricing.
This commit is contained in:
2026-09-23 15:59:05 +03:00
commit 79320950e7
78 changed files with 14452 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Generation extends Model
{
protected $fillable = [
'batch_id',
'type',
'model',
'prompt',
'params',
'status',
'runware_task_uuid',
'cost_usd',
'cost_eur',
'cost_is_estimated',
'output_path',
'output_text',
'error',
];
protected function casts(): array
{
return [
'params' => 'array',
'cost_usd' => 'decimal:6',
'cost_eur' => 'decimal:6',
'cost_is_estimated' => 'boolean',
];
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class RunwareModel extends Model
{
protected $fillable = [
'modality',
'air_id',
'label',
'unit',
'price_usd',
'is_default',
'active',
];
protected function casts(): array
{
return [
'price_usd' => 'decimal:6',
'is_default' => 'boolean',
'active' => 'boolean',
];
}
public static function defaultFor(string $modality): ?self
{
return static::query()
->where('modality', $modality)
->where('is_default', true)
->where('active', true)
->first();
}
/**
* The cheapest active model always wins the default flag, since Runware's
* own model-search API doesn't expose pricing — this locally-entered
* table is the only place "cheapest" can be computed from.
*/
public static function recomputeDefault(string $modality): void
{
static::query()->where('modality', $modality)->update(['is_default' => false]);
$cheapest = static::query()
->where('modality', $modality)
->where('active', true)
->orderBy('price_usd')
->orderBy('id')
->first();
$cheapest?->update(['is_default' => true]);
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}