1. Go to this page and download the library: Download andreshg112/datos-abiertos library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreshg112 / datos-abiertos example snippets
use Andreshg112\DatosAbiertos\Facades\Divipola;
// Listado total de municipios:
$data = Divipola::getData();
use Andreshg112\DatosAbiertos\Facades\Divipola;
// Para filtrar por código de departamento puedes hacer cualquiera de las siguientes formas:
$filterOrSoqlQuery = 'cod_depto=20'; // esta
$filterOrSoqlQuery = ['cod_depto' => '20']; // o esta
$data = Divipola::getData($filterOrSoqlQuery);
// En el archivo app/Providers/AppServiceProvider.php:
use Andreshg112\DatosAbiertos\Facades\OrganismosTransito;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
OrganismosTransito::macro('whereEstadoLimit', function($estado, $limit){
$filter = [
'$where' => "estado = '$estado'", // https://dev.socrata.com/docs/queries
'$limit' => $limit, // 1, 2, 3, etc.
];
return $this->getData($filter);
});
}
}
// Y luego, en cualquier otra parte:
$data = OrganismosTransito::whereEstadoLimit('ACTIVO', 3);
use Andreshg112\DatosAbiertos\Datasets\BaseDataset;
namespace App\Datasets;
/**
* https://www.datos.gov.co/Educaci-n/colegios/u3ch-n6ec
*/
class Colegios extends BaseDataset
{
public function getColumns()
{
return [
'a_o', // año.
'calendario',
'codigo_etc', // nombre_Rector
'codigodepartamento', 'codigoestablecimiento',
'codigomunicipio', 'correo_electronico', 'direccion', 'discapacidades', 'especialidad',
'estrato_socio_economico', 'etnias', 'grados', 'idiomas', 'internado', 'jornada',
'matricula_contratada', 'modelos', 'modelos_educativos', 'niveles', 'nombredepartamento',
'nombreestablecimiento', 'nombremunicipio', 'numero_de_sedes', 'prestador_de_servicio',
'propiedad_planta_fisica', 'resguardo', 'secretaria', 'telefono', 'tipo_establecimiento',
'zona',
];
}
protected function getDatasetIdentifier()
{
// El código del recurso, que es la última parte de la URL sin el .json
// https://www.datos.gov.co/resource/xax6-k7eu.json
return 'xax6-k7eu';
}
protected function getUniqueColumn()
{
return 'codigoestablecimiento';
}
}
use Facades\App\Datasets\Colegios;
use Facades\App\Datasets\Colegios; // Fachada en tiempo real.
$data = Colegios::where('modelos_educativos', 'EDUCACIÓN TRADICIONAL');
use Facades\App\Datasets\Colegios;
use Andreshg112\DatosAbiertos\Facades\Divipola;
use Andreshg112\DatosAbiertos\Facades\OrganismosTransito;
// nombredepartamento
Colegios::whereNombredepartamento('Cesar'); // d minúscula porque no tiene subguión.
// nom_mpio
Divipola::whereNomMpio('Valledupar'); // M mayúscula porque tiene subguión.
// categor_a
OrganismosTransito::whereCategorA('A'); // A mayúscula porque tiene un subguión antes.
use Andreshg112\DatosAbiertos\Facades\Colegios; // Esta es la implementación incluída.
$data = Colegios::find(147707000156);
// Es equivalente a:
$data = Colegios::whereCodigoestablecimiento(147707000156)[0] ?? null;
// y a:
$data = Colegios::where('codigoestablecimiento', 147707000156)[0] ?? null;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.