Migration complete
This commit is contained in:
33
app/Http/Controllers/ReviewController.php
Normal file
33
app/Http/Controllers/ReviewController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\SubmissionException;
|
||||
use App\Http\Requests\StoreReviewRequest;
|
||||
use App\Models\Entry;
|
||||
use App\Services\ReviewsService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReviewController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(private ReviewsService $services){}
|
||||
|
||||
public function index(){
|
||||
|
||||
return view('reviews.index');
|
||||
}
|
||||
|
||||
|
||||
public function store(StoreReviewRequest $request, Entry $entry)
|
||||
{
|
||||
try {
|
||||
$this->services->storeReview( $request, $entry );
|
||||
return redirect()->route('entries.show', [ 'section' => $entry->type, 'entry' => $entry ])->with('success', "Your review has been published.");
|
||||
} catch ( SubmissionException $e ) {
|
||||
return back()->withInput()->withErrors(['error' => $e->getMessage()]);
|
||||
} catch ( \Exception $e ) {
|
||||
return back()->withInput()->withErrors(['error' => 'Unknown error: '.$e->getMessage()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user