Download the PHP package nazarii-kretovych/laravel-api-model-driver without Composer
On this page you can find all versions of the php package nazarii-kretovych/laravel-api-model-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nazarii-kretovych/laravel-api-model-driver
More information about nazarii-kretovych/laravel-api-model-driver
Files in nazarii-kretovych/laravel-api-model-driver
Package laravel-api-model-driver
Short Description API driver for Laravel 7 Eloquent models
License MIT
Informations about the package laravel-api-model-driver
Laravel API Model Driver
The library allows to create and assign an API connection to Laravel 7 Eloquent models and use Laravel query builder to build a query string and get data as if you get data from a database connection. It also allows to use Eloquent relationships.
Once developers define the configuration of a new API connection and make the related model classes use that connection, they don't need to think about API calls, authentication, etc. They just work with those models as if they are regular models that have a MySQL connection. However, the library only supports retrieving data from an API service.
There is also a possibility to configure automatic time zone conversion in case the API service provides the clients with time values in a different time zone so that the developers don't need to think about it while they are writing code.
Features
- Support the following query builder functions: where, whereIn, whereBetween, orderBy and limit;
- Support Eloquent relationships;
- Automatic pluralization of the name of a query parameter that has an array;
- Automatic time zone conversion for time JSON properties and time query parameters;
- Possibility to define multiple API connections with their own configuration and authentication;
- Automatic splitting query strings whose length is too long (see the max_url_length parameter);
- The library makes API calls using the php-curl extension so that the subsequent requests reuse the connection that was established during the first request without wasting time on establishing new connections.
Installation
Install the library using composer:
Configuration
Open config/database.php and add a new API connection:
Create a new model class and set its connection: