What does this magic do?
public function index()
{
$products = Product::all();
return view('products.index')->withProducts($products);
}
There is the View::make
way, which takes an array as a second parameter and there is the with()
way, which takes string or an array.
with('products', $products);
or
with(array('products' => $products, 'foo' => $bar));
What is the purpose of withModel($model)
resp. withModels($models)
?
Are there any benefits using this approach over the other opportunities?
Also related to refactoring existing model names later on?