Assign data to PHP variables
P粉256487077
2023-09-05 13:12:09
<p>I want to use the same method to get the data of two variables, but it doesn’t happen</p>
<pre class="brush:php;toolbar:false;">function display(){
$datas=Req::all();
$products = Product::all();
return view ('products.dispaly')->with('products', $products,'datas',$datas);
}</pre>
<p>Here I want to get the data from the table and assign them to two separate variables $datas and $products? What is the correct approach? </p>
You must use
view
like this:Another method that is exactly the same, just less verbose, is to use
Compact
: