I can't figured it out how can I make following. User can see details of his order. I want to make button for a user to be able to leave a review of the product which he purchased.
When he left review for a product I want to change the button from "submit review" to "edit review". Problem is how to do this if he purchased 2 or more items? I want to be able to leave review for each item separately.
In the controller I have this function:
public function orderView($orderId)
{
$order = Order::where('order_id', $orderId)->where('user_id', Auth::user()->user_id)->first();
$reviews = Review::where('user_id', Auth::user()->user_id)->first();
return View::make('site.users.orders_view', [
'order' => $order,
'reviews' => $reviews
]);
}
So, here I select his orders and reviews for authenticated user. Where I show button on the view "submit review", "edit review" I've tried this
@if($reviews->user_id == Auth::user()->user_id)
<a class="btn btn-warning btn-xs" href="">Submit Review</a></li>
@else
<a class="btn btn-warning btn-xs" href="">Edit Review</a></li>
@endif
If user has 2 products in that order and left only for one of them review both buttons are changed to Edit Review
.
What I want to do is if user has 2 products in that order and review for 1 of the products to have one button "edit review" and one "submit review"
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yNcUID
via IFTTT
Aucun commentaire:
Enregistrer un commentaire