1
I’m using Laravel for an API
In my comic book I have a table called tbmanifestacao
and in this table I have a column called nrmanifestacao
I would like in my controller return the biggest nrmanifestacao
I tried so:
$nr = DB::select('select MAX(nrmanifestacao) from tbmanifestacao', [1]);
But it did not work, beyond that I know it is not the correct to use SQL, but rather the Eloquent
How could I do this search?
A way to do:
DB::table('tbmanifestacao')->max('nrmanifestacao');
– MarceloBoni
You should probably own a model of
tbmanifestacao
, then you could do it using eloquent:seuModel::max('nrmanifestacao');
– MarceloBoni
@Marceloboni that second worked
– Mateus
@Marceloboni the first now tbm, but I had to put
use Illuminate\Support\Facades\DB;
– Mateus