【发布时间】:2017-01-06 11:11:10
【问题描述】:
我有一个关于显示添加到购物车的特定问题。首先,我认为以前的路线总是相同的,因为你先选择菜单类别,然后再去菜,所以我无法检查。 我有两种不同的方式去购买产品。第一个是单击导航栏中的“菜单”,然后将菜肴作为画廊打开(没有添加到购物车的选项),第二个是在完成预订表格后选择产品并选择您想要的菜单进行预订.那么,如果我直接从导航栏进入,如何禁用添加到购物车选项????(因为在这两种情况下都是相同的视图) 这是我的控制器:
public function index($id)
{
$menu_categories = Menu_Categories::where('visible','yes')->where('delete','no')->orderBy('position','ASC')->get();
$selected_menu = $id;
$dishes = Dishes::where('visible','yes')->where('delete','no')->where('id_menu_category',$id)->orderBy('name','DESC')->get();
return view('dishes.dishes', ['dishes' => $dishes,'menu_categories' => $menu_categories,'selected_menu' => $selected_menu]);
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index_nav($id)
{
$menu_categories = Menu_Categories::where('visible','yes')->where('delete','no')->orderBy('position','ASC')->get();
$selected_menu = $id;
$dishes = Dishes::where('visible','yes')->where('delete','no')->where('id_menu_category',$id)->orderBy('name','DESC')->get();
session(['menu_nav' => true]);
return view('dishes.dishes', ['dishes' => $dishes,'menu_categories' => $menu_categories,'selected_menu' => $selected_menu]);
}
这是我的观点:
@foreach($dishes as $dish)
<!-- shop item -->
<div class="col-md-6 col-sm-6">
<div class="home-product text-center position-relative overflow-hidden margin-ten no-margin-top">
<a href=""><img height="300" style="height:250px;width: 100%" src="{{$dish->image}}" alt=""/></a>
<span class="product-name text-uppercase black-text" ><a style="font-weight: bold; background-color: #FFFFFF;border: 1px solid white">{{$dish->name}}</a></span>
<span class="price black-text">{{$dish->price}} €</span>
<div class="quick-buy" style="width:100px;height:100px;margin-left:150px;">
<div class="product-share">
@if(Session::has('manu_nav') && Session::get('manu_nav') == true)
@else
<a href="{{url('add_item_to_cart',$dish->id)}}" class="highlight-button-dark btn btn-small no-margin-right quick-buy-btn" title=""><i class="fa fa-shopping-cart"></i></a>
@endif
</div>
</div>
</div>
</div>
<!-- end shop item -->
@endforeach
【问题讨论】:
-
没有解开你的问题..你可以编辑或更清楚吗?
-
@FaisalMehmoodAwan 嗯,现在可以了吗?
标签: php laravel session laravel-5