40 lines
908 B
PHP
40 lines
908 B
PHP
<?php
|
|
|
|
namespace LaraBB\Thread\UI\Web\Handlers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Exception;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use LaraBB\Thread\Actions\StoreAction;
|
|
use LaraBB\Thread\Models\Thread;
|
|
use LaraBB\Thread\UI\Web\Requests\Store;
|
|
use function GuzzleHttp\Promise\inspect;
|
|
|
|
/**
|
|
* Class StoreHandler
|
|
* @package LaraBB\Thread\UI\Web\Handlers
|
|
*/
|
|
class StoreHandler extends Controller
|
|
{
|
|
/**
|
|
* StoreHandler constructor.
|
|
* @param StoreAction $storeAction
|
|
*/
|
|
public function __construct(private readonly StoreAction $storeAction)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* @param Store $request
|
|
* @return RedirectResponse
|
|
* @throws Exception
|
|
*/
|
|
public function __invoke(Store $request): RedirectResponse
|
|
{
|
|
$thread = $this->storeAction->run($request);
|
|
|
|
return $thread instanceof Thread ? $request->success($thread) : $request->failed();
|
|
}
|
|
}
|