First Commit
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\PromptGeneration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\PromptGeneration\GeneratePromptRequest;
|
||||
use App\Models\PromptGeneration;
|
||||
use App\Services\PromptGenerationService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PromptGenerationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly PromptGenerationService $promptGenerationService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Display a listing of prompt generations.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$generations = $this->promptGenerationService->index();
|
||||
|
||||
return view('prompt-generations.index', compact('generations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new prompt.
|
||||
*/
|
||||
public function generate(GeneratePromptRequest $request): RedirectResponse
|
||||
{
|
||||
$result = $this->promptGenerationService->generate($request->validated());
|
||||
|
||||
return redirect()->route('prompt-generations.index')
|
||||
->with('success', 'Prompt generated successfully.')
|
||||
->with('generation', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified prompt generation.
|
||||
*/
|
||||
public function destroy(Request $request, PromptGeneration $generation): RedirectResponse
|
||||
{
|
||||
$this->authorize('delete', $generation);
|
||||
|
||||
$this->promptGenerationService->destroy($generation);
|
||||
|
||||
return redirect()->back()->with('success', 'Prompt generation deleted successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user