Browse Source

Add filter in list usuarioRepo

main
lucas cardoso 2 years ago
parent
commit
8aab134d61
  1. 18
      app/Repositories/UsuarioRepository.php

18
app/Repositories/UsuarioRepository.php

@ -1,8 +1,10 @@
<?php
namespace app\Models;
namespace app\Repositories;
use app\Core\Repository;
use app\Models\UsuarioModel;
use Exception;
class UsuarioRepository extends Repository
{
@ -10,4 +12,18 @@ class UsuarioRepository extends Repository
{
$this->table = UsuarioModel::$table;
}
function list(array $params = []): array
{
$table = $this->table;
$query = "SELECT * FROM $table WHERE 1=1";
if ($params['matricula']) {
$query .= " AND matricula = :matricula ";
$dados['matricula'] = $params['matricula'];
}
if (empty($params['matricula'])) {
throw new Exception('Parâmetro matricula é obrigatório');
}
return $this->db->read($query, $params)->fetchAll();
}
}
Loading…
Cancel
Save