All Projects → netdragoon → zipcode

netdragoon / zipcode

Licence: MIT license
ZipCode Cep do Brazil

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to zipcode

laracash
PHP Laravel Money Package 💰
Stars: ✭ 52 (+20.93%)
Mutual labels:  facade
FA2sp
C&C Red Alert 2: Yuri's Revenge Map Editor : Final Alert 2 extension
Stars: ✭ 28 (-34.88%)
Mutual labels:  injection
ViaCEP
The ViaCEP API/webservice .NET client
Stars: ✭ 21 (-51.16%)
Mutual labels:  cep
wingkalabs
Wingkalabs (Linux) Wingkalabs es una máquina Virtual Linux intencionalmente vulnerable. Esta máquina virtual se puede utilizar para realizar entrenamientos de seguridad, probar herramientas de seguridad y practicar técnicas comunes de pruebas de penetración.
Stars: ✭ 16 (-62.79%)
Mutual labels:  injection
AnnotationInject
Compile-time Swift dependency injection annotations
Stars: ✭ 40 (-6.98%)
Mutual labels:  injection
helm-inject
Inject additional configurations during Helm upgrade
Stars: ✭ 17 (-60.47%)
Mutual labels:  injection
typeioc
Dependency injection container for typescript / javascript
Stars: ✭ 32 (-25.58%)
Mutual labels:  injection
bety
Web-interface to the Biofuel Ecophysiological Traits and Yields Database (used by PEcAn and TERRA REF)
Stars: ✭ 14 (-67.44%)
Mutual labels:  trait
laravel-cachable-attributes
Allows to cache attribute accessor values in an easy way.
Stars: ✭ 24 (-44.19%)
Mutual labels:  trait
ProcessInjector.NET
Learning Process Injection and Hollowing techniques
Stars: ✭ 23 (-46.51%)
Mutual labels:  injection
letsencrypt-fast
The fastest way to test/generate/renew Let's Encrypt SSL certificates!!! Requires root access and a live webserver to run the script at.
Stars: ✭ 25 (-41.86%)
Mutual labels:  renewal
Android-Task-Injection
Task Hijacking in Android (somebody call it also StrandHogg vulnerability)
Stars: ✭ 52 (+20.93%)
Mutual labels:  injection
PySiddhi
Python wrapper for Siddhi engine
Stars: ✭ 22 (-48.84%)
Mutual labels:  cep
Skrull
Skrull is a malware DRM, that prevents Automatic Sample Submission by AV/EDR and Signature Scanning from Kernel. It generates launchers that can run malware on the victim using the Process Ghosting technique. Also, launchers are totally anti-copy and naturally broken when got submitted.
Stars: ✭ 413 (+860.47%)
Mutual labels:  injection
Reflex
Minimal dependency injection framework for Unity
Stars: ✭ 263 (+511.63%)
Mutual labels:  injection
witchcraft
Opionated PHP magic methods as traits for PHP 5.4+
Stars: ✭ 23 (-46.51%)
Mutual labels:  trait
esper-demo-nuclear
Simple demo of some features of the Esper Complex Event Processing (CEP) engine.
Stars: ✭ 83 (+93.02%)
Mutual labels:  cep
SilentETHMiner
A Silent (Hidden) Ethereum (ETH & ETC) Miner Builder
Stars: ✭ 219 (+409.3%)
Mutual labels:  injection
pwptemp
pwptemp
Stars: ✭ 54 (+25.58%)
Mutual labels:  injection
laravel-make-extender
Generate and autoload custom Helpers, Builder Scope, Service class, Trait, Custom Casts, Collections Macros, View Composers
Stars: ✭ 30 (-30.23%)
Mutual labels:  trait

Canducci Zipcode

Laravel pacote do Web Service VIACEP web service - http://viacep.com.br


Downloads License Version PHP Composer

See Demo

Utilizando composer: Composer

composer require canducci/zipcode

Adicione as classes no final do array de providers no arquivo config/app.php:

'providers' => [
    // ...,
    Canducci\ZipCode\Providers\ZipCodeServiceProvider::class,
    Canducci\ZipCode\Providers\ZipCodeAddressServiceProvider::class,
],

e adicione os seus apelidos no array aliases:

'aliases' => [
    // ...,
    'ZipCode'   => Canducci\ZipCode\Facades\ZipCode::class,
    'Address'   => Canducci\ZipCode\Facades\ZipCodeAddress::class,
],

para finalizar precisa dar um:

php artisan vendor:publish

após digitar esse comando vai aparecer um menu de opções então escolha Canducci\ZipCode\Providers\ZipCodeServiceProvider para publicar o arquivo de configuração (simplecache.php) na pasta config/

Como utilizar?

Temos 4 caminhos para usufruir desse pacote:

Facade

use Canducci\ZipCode\Facades\ZipCode;

$zipCodeInfo = ZipCode::find('01414-001');

Helper

$zipCodeInfo = zipcode('01414000');

Injection

use Canducci\ZipCode\Contracts\ZipCodeContract;

public function index(ZipCodeContract $zipcode)
{
      $zipCodeInfo = $zipcode->find('01414-000');
}

Trait

use Canducci\ZipCode\ZipCodeTrait;

class WelcomeController extends Controller
{
    use ZipCodeTrait;

    public function index()
    {
        $zipCodeInfo =	$this->zipcode('01414000');
    }
}

Há diversas formas de chegar no mesmo resultado:

$zipCodeInfo = ZipCode::find('01414000'); // Facade

$zipCodeInfo = $zipcode->find('01414-000'); // Contract

$zipCodeInfo = zipcode('01414000'); // Helper

$zipCodeInfo = $this->zipcode('01414-000'); // Trait

Cache renovar

Pode forçar um item a renovar seu cache com o segundo parâmetro:

$zipCodeInfo = ZipCode::find('01414000', true); // Facade

$zipCodeInfo = $zipcode->find('01414-000', true); // Contract

$zipCodeInfo = zipcode('01414000', true); // Helper

$zipCodeInfo = $this->zipcode('01414-000', true); // Trait

Tipos de retornos

Por padrão o retorno é nulo ou a instância da classe Canducci\ZipCode\ZipCodeInfo, e com esse retorno de classe existe os tipos array, object e json texto:

if ($zipCodeInfo) // null or ZipCodeInfo
{
    $arr = $zipCodeInfo->getArray(); // Array

    $json = $zipCodeInfo->getJson(); // Json

    $obj = $zipCodeInfo->getObject(); // Object
}

Array

if ($zipCodeInfo)
{
    $arr = $zipCodeInfo->getArray();
    /*
    Array
    (
        [cep] => 01414-001
        [logradouro] => Rua Haddock Lobo
        [bairro] => Cerqueira César
        [localidade] => São Paulo
        [uf] => SP
        [ibge] => 3550308,
        [complemento] =>
        [gia] => 1004,
        [siafi] => 0
        [ddd] = 11
    )
    */
}

Json

if ($zipCodeInfo)
{
    $json = $zipCodeInfo->getJson();
    /*
    {
        "cep": "01414-001",
        "logradouro": "Rua Haddock Lobo",
        "bairro": "Cerqueira César",
        "localidade": "São Paulo",
        "uf": "SP",
        "ibge": "3550308",
        "complemento": ""
        "gia": 1004,
        "ddd": "11",
        "siafi": 0
    }
    */
}

Object

if ($zipCodeInfo)
{
    $obj = $zipCodeInfo->getObject();
    /*
    stdClass Object
    (
        [cep] => 01414-001
        [logradouro] => Rua Haddock Lobo
        [bairro] => Cerqueira César
        [localidade] => São Paulo
        [uf] => SP
        [ibge] => 3550308
        [complemento] =>
        [gia] => 1004
        [siafi] => 0
        [ddd] = 011
    )
    */
}

Faça a buscas de varios endereços informando, uf, cidade e endereço:

public function get(Request $request)
{
    $uf = $request->get('uf');
    $city = $request->get('cidade');
    $address = $request->get('endereco')
    $zipcodeaddressinfo = zipcodeaddress($uf, $city, $address);
    if ($zipcodeaddressinfo)
        return $zipcodeaddressinfo->getJson();
    return Response::json(['error' => 1]);
}

Lista de Unidade Federativa:

use Canducci\ZipCode\ZipCodeUf;

$lists = ZipCodeUf::lists();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].