This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.
You can install the package via composer:
composer require slatyo/laravel-pokemontcgThe package will automatically register its service provider.
To publish the config file to config/pokemontcg.php run:
php artisan vendor:publish --provider="Slatyo\LaravelPokemontcg\LaravelPokemontcgServiceProvider"Default content of config/pokemontcg.php:
<?php
/*
* Default configuration to run the pokemontcg.io API
*/
return [
'url' => env('POKEMONTCG_API_URL', 'https://api.pokemontcg.io/v2'),
'secret' => env('POKEMONTCG_SECRET'),
];Slatyo\LaravelPokemontcg\Pokemontcg is the default wrapper to access everything the
Pokemontcg API has to offer.
To access the cards model you have to call:
$cards = Pokemontcg::cards();Find a specific card by its id:
$cards->find('Test-111');
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::find('Test-111');Find Pokémon's based on HP:
$from = "1";
$to = "100";
$cards->hp($from, $to);
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::hp($from, $to);
Card::whereHp($from, $to); // aliasFind Pokémon's based on their name:
$cards->name('Charizard');
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::name('Charizard');
Card::whereName('Charizard'); // aliasFind Pokémon's based on their name:
$from = "1";
$to = "151";
$cards->pokedex($from, $to);
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::pokedex($from, $to);
Card::wherePokedex($from, $to); // aliasFind Pokémon's by supertypes and types:
$cards->supertype('mega');
$cards->supertype('mega', 'water');
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::supertype('mega');
Card::supertype('mega', 'water');
Card::whereSupertype('mega'); // alias
Card::whereSupertype('mega', 'water'); // aliasSearch Pokémon's based on a query string - for more details on how the query works check out: Pokemontcg search cards.
$cards->search('name:Char*zard supertype:mega -type:fire');
// or
use \Slatyo\LaravelPokemontcg\Facades\Card;
Card::search('name:Char*zard supertype:mega -type:fire');To access the sets model you have to call:
$sets = Pokemontcg::sets();Find a specific set by its id:
$sets->find('set-name');
// or
use \Slatyo\LaravelPokemontcg\Facades\Set;
Set::find('set-name');Search Pokémon sets based on a query string - for more details on how the query works check out: Pokemontcg search sets.
$sets->search('legalities.standard:legal');
// or
use \Slatyo\LaravelPokemontcg\Facades\Set;
Set::search('legalities.standard:legal');To access the supertypes model you have to call:
$supertypes = Pokemontcg::supertypes();Return all supertypes:
$supertypes->all();
// or
use \Slatyo\LaravelPokemontcg\Facades\Supertype;
Supertype::all();To access the subtypes model you have to call:
$subtypes = Pokemontcg::subtypes();Return all subtypes:
$subtypes->all();
// or
use \Slatyo\LaravelPokemontcg\Facades\Subtype;
Subtype::all();To access the subtypes model you have to call:
$types = Pokemontcg::types();Return all types:
$types->all();
// or
use \Slatyo\LaravelPokemontcg\Facades\Type;
Type::all();To access the rarities model you have to call:
$rarities = Pokemontcg::rarities();Return all rarities:
$rarities->all();
// or
use \Slatyo\LaravelPokemontcg\Facades\Rarity;
Rarity::all();Executing the testbench:
composer testRunning PHPStan
composer stanRunning PHPStan on windows
composer stan-2gGenerate coverage reports
composer test:coverage
composer test:coverage-htmlPlease see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email daniel.henze@outlook.com instead of using the issue tracker.
- Daniel Henze
- All Contributors
- This package was generated using the Laravel Package Boilerplate.
The MIT License (MIT). Please see License File for more information.