You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.6 KiB
97 lines
2.6 KiB
<?php |
|
|
|
namespace App\Http\Controllers; |
|
|
|
use App\Models\UaderMapucheFamiliares; |
|
use App\Models\UaderMapuchePersona; |
|
use Illuminate\Http\Request; |
|
|
|
class ApiFamilliaresController extends Controller |
|
{ |
|
/** |
|
* Display a listing of the resource. |
|
*/ |
|
public function index() |
|
{ |
|
return json_encode(['reply' => 'hola']); |
|
} |
|
|
|
/** |
|
* Show the form for creating a new resource. |
|
*/ |
|
public function create() |
|
{ |
|
// |
|
} |
|
|
|
/** |
|
* Store a newly created resource in storage. |
|
*/ |
|
public function store(Request $request) |
|
{ |
|
$input = $request->input(); |
|
$persona = UaderMapuchePersona::BuscarPersonaPorTelefono($input['cel']); |
|
if (!empty($persona)) { |
|
$familiares = $persona->familiares; |
|
$datos = array(); |
|
foreach ($familiares as $familiar) { |
|
$datos[] = array( |
|
'dni' => $familiar->nro_docum, |
|
'apellido' => ucwords(strtolower($familiar['desc_apell'])), |
|
'nombres' => ucwords(strtolower($familiar['desc_nombre'])), |
|
'parentezco' => $familiar->codc_paren, |
|
'fnac' => $familiar->fec_nacim, |
|
'discapacidad' => $familiar->sino_incap, |
|
'a_cargo' => $familiar->sino_cargo, |
|
); |
|
} |
|
return response()->json($datos); |
|
} else { |
|
return response()->json(array(), 404); |
|
} |
|
} |
|
|
|
/** |
|
* Display the specified resource. |
|
*/ |
|
public function buscar($dni) |
|
{ |
|
$input = $request->input(); |
|
$persona = UaderMapucheFamiliares::where('nro_docum', $imput['dni']); |
|
if (!empty($persona)) { |
|
$datos[] = array( |
|
'apellido' => ucwords(strtolower($persona['desc_apell'])), |
|
'nombres' => ucwords(strtolower($persona['desc_nombre'])), |
|
'parentezco' => $persona->codc_paren, |
|
'fnac' => $persona->fec_nacim, |
|
); |
|
return response()->json($datos); |
|
} else { |
|
return response()->json(array(), 404); |
|
} |
|
} |
|
|
|
/** |
|
* Show the form for editing the specified resource. |
|
*/ |
|
public function edit(UaderMapucheFamiliares $uaderMapucheFamiliares) |
|
{ |
|
// |
|
} |
|
|
|
/** |
|
* Update the specified resource in storage. |
|
*/ |
|
public function update(Request $request, UaderMapucheFamiliares $uaderMapucheFamiliares) |
|
{ |
|
// |
|
} |
|
|
|
/** |
|
* Remove the specified resource from storage. |
|
*/ |
|
public function destroy(UaderMapucheFamiliares $uaderMapucheFamiliares) |
|
{ |
|
// |
|
} |
|
}
|
|
|