PHP code example of zenkilies / igdb-laravel

1. Go to this page and download the library: Download zenkilies/igdb-laravel 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/ */

    

zenkilies / igdb-laravel example snippets


return [
    /*
     * This is the API Token you got from https://api.igdb.com
     */
    'api_token' => env('IGDB_TOKEN', ''),

    /*
     * This package caches queries automatically (for 1 hour per default).
     * Here you can set how long each query should be cached (in seconds).
     *
     * To turn cache off set this value to 0
     */
    'cache_lifetime' => env('IGDB_CACHE_LIFETIME', 3600),

    /*
     * This is the per-page limit for your tier.
     */
    'per_page_limit' => 500,

    /*
     * This is the offset limit for your tier.
     */
    'offset_limit' => 5000,
];

use MarcReichel\IGDBLaravel\Models\Game;

$games = Game::where('first_release_date', '>=', 1546297200)->get();

use MarcReichel\IGDBLaravel\Builder as IGDB;

$igdb = new IGDB('games'); // 'games' is the endpoint

$games = $igdb->get();

$games = Game::select(['*'])->get();

$games = Game::select(['name', 'first_release_date'])->get();

$games = Game::search('Fortnite')->get();

$games = Game::where('first_release_date', '>=', 1546297200)->get();

$games = Game::where('name', 'Fortnite')->get();

$games = Game::where('name', 'Fortnite')->orWhere('name', 'Borderlands 2')->get();

$games = Game::whereBetween('first_release_date', 1546297200, 1577833199)->get();

$games = Game::whereNotBetween('first_release_date', 1546297200, 1577833199)->get();

$games = Game::whereIn('category', [0,4])->get();

$games = Game::whereNotIn('category', [0,4])->get();

$games = Game::whereNull('first_release_date')->get();

$games = Game::whereNotNull('first_release_date')->get();

$games = Game::whereDate('first_release_date', '2019-01-01')->get();

$games = Game::whereYear('first_release_date', 2019)->get();

$games = Game::where('name', 'Fortnite')
    ->orWhere(function($query) {
        $query->where('aggregated_rating', '>=', 90)
            ->where('aggregated_rating_count', '>=', 3000);
    })->get();

$games = Game::orderBy('first_release_date', 'asc')->get();

$games = Game::skip(10)->take(5)->get();

$games = Game::offset(10)->limit(5)->get();

$games = Game::cache(0)->get();

$games = Game::get();

$games = Game::all();

$game = Game::first();

$game = Game::find(1905);

$game = Game::with(['cover', 'artworks'])->get();

$game = Game::with(['cover' => ['url', 'image_id'])->get();

$game = Game::find(1905);

if ($game) {
    echo $game->name; // Will output "Fortnite"
}

$game = Game::find(1905);

if ($game) {
    echo $game->foo; // Will output nothing
}
bash
php artisan vendor:publish --provider="MarcReichel\IGDBLaravel\IGDBLaravelServiceProvider"