[英]Is it possible to return a view (using blade) with two variables in laravel?
我必須使用一個表格來執行這些頁面之一,該表格將根據菜餚類型或菜餚類型等搜索餐點及其食譜......這是我的 function 以返回視圖,但我顯示的行中有錯誤下面用粗體表示:
public static function SearchPage()
{
$DishType = DishType::getAllDishType();
$CuisineType = CuisineType::getAllCuisineType()
return view("vueRecipeSearch", [
'DishType' => DishType::getAllDishType(),
CuisineType::getAllCuisineType()
]);
}
這是我想使用變量的視圖的一部分:
<label for="DishType">Dish type :</label>
<select id="DishType" name ="DishType">
@foreach($DishType as $Dish)
<option value="Dessert">{{$Dish->dish}}</option>
@endforeach
</select>
我想對美食類型做同樣的事情,但不能因為我不知道如何返回多個變量..
return view("vueRecipeSearch", [
'DishType' => DishType::getAllDishType(),
'CuisineType' => CuisineType::getAllCuisineType()
]);
然后,您可以使用數組鍵訪問刀片文件: DishType
和CuisineType
。
顯然可以將兩個變量從 controller 發送到刀片。
$dishType' = DishType::getAllDishType();
$cuisineType = CuisineType::getAllCuisineType();
return \view("vueRecipeSearch", compact('dishType', 'cuisineType'));
在刀片文件上,您必須通過$dishType
和$cuisineType
訪問這兩個變量。
返回視圖 ('vueRecipeSearch',compact('dishType', 'cuisineType')); 無需添加正斜杠或反斜杠。 簡單的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.