Files
ai-stylegallery/app/Http/Controllers/Api/StyleController.php

45 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Style;
use App\Models\Setting;
use Illuminate\Http\Request;
class StyleController extends Controller
{
public function index()
{
$styles = Style::with(['aiModel.apiProviders'])
->where('enabled', true)
->whereHas('aiModel', function ($query) {
$query->where('enabled', true);
$query->whereHas('apiProviders', function ($query) {
$query->where('enabled', true);
});
})
->get()
->sortBy('sort_order');
if ($styles->isEmpty()) {
return response()->json(['message' => __('api.no_styles_available')], 404);
}
return response()->json($styles);
}
public function getImageRefreshInterval()
{
$interval = Setting::where('key', 'image_refresh_interval')->first();
return response()->json(['interval' => $interval ? (int)$interval->value / 1000 : 5]);
}
public function getMaxNumberOfCopies()
{
$maxCopies = Setting::where('key', 'max_number_of_copies')->first();
return response()->json(['max_copies' => $maxCopies ? (int)$maxCopies->value : 10]); // Default to 10 if not set
}
}