Download the PHP package zenkilies/igdb-laravel without Composer
On this page you can find all versions of the php package zenkilies/igdb-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenkilies/igdb-laravel
More information about zenkilies/igdb-laravel
Files in zenkilies/igdb-laravel
Package igdb-laravel
Short Description A Laravel Wrapper for the IGDB API v3
License MIT
Informations about the package igdb-laravel
IGDB Laravel Wrapper
This is a Laravel-Wrapper for version 3 of the IGDB API (Apicalypse).
Basic installation
You can install this package via composer using:
The package will automatically register its service provider.
To publish the config file to config/igdb.php
run:
This is the default content of the config file:
Usage
If you're familiar with the Eloquent System and the Query Builder of Laravel you will love this package as it uses a similar approach.
Models
Each endpoint of the API is mapped to its own model.
To get a list of games you simply call something like this:
Here's a list of all available Models:
- Achievement
- AchievementIcon
- AgeRating
- AgeRatingContentDescription
- AlternativeName
- Artwork
- Character
- CharacterMugShot
- Collection
- Company
- CompanyLogo
- CompanyWebsite
- Cover
- ExternalGame
- Feed
- Franchise
- Game
- GameEngine
- GameEngineLogo
- GameMode
- GameVersion
- GameVersionFeature
- GameVersionFeatureValue
- GameVideo
- Genre
- InvolvedCompany
- Keyword
- MultiplayerMode
- Page
- PageBackground
- PageLogo
- PageWebsite
- Platform
- PlatformLogo
- PlatformVersion
- PlatformVersionCompany
- PlatformVersionReleaseDate
- PlatformWebsite
- PlayerPerspective
- ProductFamily
- Pulse
- PulseGroup
- PulseSource
- PulseUrl
- ReleaseDate
- Screenshot
- Search
- Theme
- TimeToBeat
- Title
- Website
Query Builder
You can use one of the defined models listed above. The search results will be mapped into the used model automatically then. This method is used in the examples below.
Otherwise you can use the Query Builder itself like this:
Select
Select which fields should be in the response. If you want to have all available
fields in the response you can also skip this method as the query builder will
select *
by default. (Attention: This is the opposite behaviour from the
Apicalypse API)
Search
Where-Clauses
Simple Where Clauses
For convenience, if you want to verify that a column is equal to a given value,
you may pass the value directly as the second argument to the where
method:
Or Statements
You may chain where constraints together as well as add or
clauses to the query.
The orWhere
method accepts the same arguments as the where
method:
Additional Where Clauses
whereBetween
The whereBetween
method verifies that a fields's value is between two values:
whereNotBetween
The whereNotBetween
method verifies that a field's value lies outside of two
values:
whereIn
The whereIn
method verifies that a given field's value is contained within the
given array:
whereNotIn
The whereNotIn
method verifies that the given field's value is not
contained in the given array:
whereInAll / whereNotInAll / whereInExact / whereNotInExact
Alternatively you could use one of these methods to match against all or exactly the given array.
whereNull
The whereNull
method verifies that the value of the given field is NULL
:
whereNotNull
The whereNotNull
method verifies that the field's value is not NULL
:
whereDate
The whereDate
method may be used to compare a field's value against a date:
whereYear
The whereYear
method may be used to compare a fields's value against a specific
year:
whereHas / whereHasNot
These methods have the same syntax as whereNull
and whereNotNull
and literally
do the exact same thing.
Parameter Grouping
Ordering, Limit, & Offset
orderBy
The orderBy
method allows you to sort the result of the query by a given field.
The first argument to the orderBy
method should be the field you wish to sort
by, while the second argument controls the direction of the sort and may be either
asc
or desc
:
skip / take
To limit the number of results returned from the query, or to skip a given
number of results in the query, you may use the skip
and take
methods (Both
methods are limited to your current tier, so make sure you configure them
correctly in the config file):
Alternatively, you may use the limit
and offset
methods:
Cache
You can overwrite the default cache time for one specific query. So you can for example turn off caching for a query:
Get
To finally get results for the query, simply call get
:
All
If you just want to get "all" results (limited to the per_page_limit of your tier)
just call the all
-Method directly on your model:
First
If you only want one result call the first
-method after your query:
Find
If you know the Identifier of the model you can simply call the find
-method
with the identifier as a parameter:
FindOrFail
find
returns null
if no result were found. If you want to throw an Exception
instead use findOrFail
. This will throw an
MarcReichel\IGDBLaravel\Exceptions\ModelNotFoundException
if no result were
found.
Relationships (Extends)
To extend your result use the with
-method:
By default, every field (*
) of the relationship is selected.
If you want to define the fields of the relationship yourself you have to define
the relationship as the array-key and the fields as an array:
Reading properties
Model-based approach
If you used the Model-based approach you can simply get a property:
If you want to access a property which does not exist null
is returned:
Query-Builder-based approach
If you used the Query Builder itself you must check if a property exists yourself.
TODO List
- Refactor code (beautify code)
- Write unit tests
Contribution
Pull requests are welcome :)
All versions of igdb-laravel with dependencies
laravel/framework Version 5.8.*|^6.0|^7.0
guzzlehttp/guzzle Version ~6.0
ext-json Version *