I have controller
that plays for my view
the total number of courses registered in the portal. My doubts are due to the operation of the count()
method.
For example, output
of both statements below are equivalent:
1) Instruction
$usuario = User::find(Auth::id());
$usuario->cursos->count();
2) Instruction
Curso::count('id', Auth::id());
My question is, in statement 1 I am running a select fulltable
, returning all the columns of the table and then passing to the count()
method perform the count?
And the statement 2 , does it already mount a sql
that executes count
directly in the database returning only the total?