Laravel Eloquet AND-OR-AND Undefined variable

Asked

Viewed 45 times

0

I have a function in the Repository to list only the employees not dismissed on a certain date

use Parametergroup, but the condition does not find the $date parameter of the function, giving the error: "Undefined variable: date"

public function listarFuncionariosAtivos($data) 
{
    $funcionarios = Funcionario::where('demitido', '0')
                              ->orWhere(function($query) {
                                  $query->whereNotNull('data_demissao')
                                        ->where('data_demissao', '>=', $data);
                              })
                        ->orderBy('nome')
                        ->get(['id','nome','salario','data_admissao','data_demissao']); 

    return $funcionarios;

inserir a descrição da imagem aqui }

1 answer

2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.