0
這是什麼魔力呢?優勢利用Laravel對通數據魔術方法來查看?
public function index()
{
$products = Product::all();
return view('products.index')->withProducts($products);
}
還有就是View::make
方式,這需要一個數組作爲第二個參數並且在with()
方式,這需要串或陣列。
with('products', $products);
或
with(array('products' => $products, 'foo' => $bar));
什麼是withModel($model)
RESP的目的。 withModels($models)
?
是否有使用這種方法比其他機會什麼好處?
還關係到以後重構現有模型的名字呢?