41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Mobile\ConectaSusAb\Cadastro;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Cadastro\Estabelecimento\Unidade;
|
|
use Illuminate\Http\Response;
|
|
|
|
class UnidadeController extends Controller
|
|
{
|
|
protected $modulo = 'cadastro';
|
|
protected $funcionalidade = 'unidade';
|
|
|
|
public function index()
|
|
{
|
|
|
|
$where = $this->getWhereFromQueryString([
|
|
'cnpj',
|
|
'nome_fantasia',
|
|
'cnes',
|
|
'unidade_referencia',
|
|
['not_id', '<>']
|
|
]);
|
|
|
|
$unidades = $this->get(Unidade::class)->where($where)->orderBy('nome_fantasia')->get()->map(function ($unidade) {
|
|
|
|
return [
|
|
'id' => $unidade->id,
|
|
'nome_fantasia' => $unidade->nome_fantasia,
|
|
'razao_social' => $unidade->razao_social,
|
|
'cnpj' => $unidade->cnpj,
|
|
'email' => $unidade->email,
|
|
'tipo_id' => $unidade->tipo_id,
|
|
'cnes' => $unidade->cnes
|
|
];
|
|
});
|
|
|
|
return response()->json($unidades, Response::HTTP_OK);
|
|
}
|
|
}
|