public function rateOrder($order_id)
{
//Checks if the user is logged in
$user = \Auth::user();
if ($user) {
//Finds the order to be rated and checks if it belongs to the current user
$order = Order::where('id', $order_id)->where('user_id', $user->id)->first();
// dd($order->details);
if ($order) {
$address = Address::find($order->address_id);
$seller = User::find($order->seller_id);
$business = Business::where('user_id', $order->seller_id)->first();
// $jsonOrder = json_encode($order->toArray());
// $jsonOrderAddress = json_encode($address->toArray());
// $jsonBusiness = json_encode($business->toArray());
return view('orders.rate_order', compact('order', 'seller', 'business'));
// return view('orders.rate_order', compact('order', 'seller', 'business', 'jsonOrder', 'jsonOrderAddress', 'jsonBusiness'));
} else {
return redirect('/user/orders');
}
} else {
return redirect('/');
}
}