How to show the value from other database in a view? i am using multi database. My Controller :
public function index()
{
$oil = DB::connection('mysql2')->table('oils')->select('oil_price')->get();
$this->oil = [
'oil_price' => $oil
];
return view('home')->with('oil', $this->oil);
}
This is my view :
{{$oil['oil_price']}}
Output is : enter image description here
I want show only 10000.
You should try this:
Your Controller
public function index()
{
$oil = DB::connection('mysql2')->table('oils')->select('oil_price')->get();
return view('home',compact('oil'));
}
Your view like :
@foreach($oil as $oildetails)
{{$oildetails->oil_price}}
@endforeach