I have SQL functions stored on my database.
However, I can not call them.
$nb = DB::select(\'SELECT nb_seances_archivees()\');
The
By default DB::select
return an array of objects, you can use collections to get the first result:
$nb = collect(DB::select('SELECT nb_seances_archivees() AS nb'))->first()->nb;
Or directly access the first object in the array:
$nb = DB::select('SELECT nb_seances_archivees() AS nb')[0]->nb;
If you want to pass parameters then you should do:
DB::select('SELECT nb_seances_archivees(?) AS nb', [$parameter]);