How can I get the value of a variable that comes from a query to the database? I want to know what value that query brings me and for that I need to print it in console.
How can I get the value of a variable that comes from a query to the database? I want to know what value that query brings me and for that I need to print it in console.
This is a basic example:
In your controller it would go like this:
$data = DB::table('data')->where('id','3')->first();
return View::make('hello',['data'=>$data->info]);
Where:
table('data')table('data')
Is the name of the table.
where('id','3')
Extract the data where
id=3
'hello'
It is the name of the view where you want to show the data.
['data'=>$data->info]
Show the info in the table.
Now in the view you put this:
{{ $data }}
This variable will show the data of ['data'=>$data->info]
.
In console I do not know exactly how to print directly, but it goes like this:
Log::info("mensaje: " . $variable);
For more info click here