I need to fetch information and bring it into an array, but errors are occurring.
Below the code of the class that makes the get query
public function getByLoja(string $uuid): array
{
$query = HorarioLoja::all();
$query = $query->where('loja', function ($loja) use ($uuid) {
$loja->where('uuid', $uuid);
});
$horariosDaLoja = $query->get();
$saida = [];
foreach ($horariosDaLoja as $horario) {
$saida[] = $this->horarioLojaTransformador->paraModelo($horario);
}
return $saida;
}
Below the model code
class HorarioLoja extends Model
{
protected $dates = ['created_at', 'updated_at'];
protected $table = 'horario_lojas';
public function loja()
{
return $this->belongsTo(Loja::class, 'loja_id', 'id');
}
}
Error:
Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in /var/www/html/code/app/Persistencia/Laravel/Repositorios/HorariosLojasRepositorioLaravel.php on line 32 and at least 1 expected {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in /var/www/html/code/app/Persistencia/Laravel/Repositorios/HorariosLojasRepositorioLaravel.php on line 32 and at least 1 expected at /var/www/html/code/vendor/laravel/framework/src/Illuminate/Support/Collection.php:874)