-
routes/api.php
Open in GitHubuse Illuminate\Support\Facades\Route; use App\Http\Controllers\Api\AvatarController; Route::get('/initials', [AvatarController::class, 'initials'])->name('generateInitials');
-
app/Http/Controllers/Api/AvatarController.php
Open in GitHubuse App\Http\Controllers\Controller; use App\Services\AvatarGenerator; class AvatarController extends Controller { public function initials(Request $request) { $name = $request->query('name', 'John Doe'); $background_color = $request->query('bgcolor', 'random'); $text_color = $request->query('color', 'fafafa'); $shape = $request->query('shape', 'circle'); $size = $request->query('size', 260); $image = new AvatarGenerator(name: $name, background_color:$background_color, text_color:$text_color, shape:$shape, size:$size); return $image->generate(); } }