File: /var/www/vaspayment.com/app/Http/Controllers/ReviewController.php
<?php
namespace App\Http\Controllers;
use App\Models\Review;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
class ReviewController extends Controller
{
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'comment' => 'required|string|max:250',
'rating' => 'required|string|max:250',
'shop_id' => 'required|string|max:250',
]);
if ($validator->fails()) {
return redirect()->back()->with('error', $validator->errors()->first());
}
try {
$shop = new Review();
$shop->comment = $request->get('comment');
$shop->rating = $request->get('rating');
$shop->shop_id = $request->get('shop_id');
$shop->user_id = Auth::user()->id;
$shop->save();
return redirect()->back()->with('status', 'Review Shared Successfully');
} catch (\Throwable $th) {
return redirect()->back()->with('error', $th->getMessage());
}
}
/**
* Display the specified resource.
*/
public function show(Review $review)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Review $review)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Review $review)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Review $review)
{
//
}
}