PHPackages                             nazarii-kretovych/laravel-api-model-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nazarii-kretovych/laravel-api-model-driver

ActiveLibrary[Database &amp; ORM](/categories/database)

nazarii-kretovych/laravel-api-model-driver
==========================================

API driver for Laravel 7 Eloquent models

v1.0.3(5y ago)342813[1 PRs](https://github.com/nazarii-kretovych/laravel-api-model-driver/pulls)MITPHPPHP ^7.2

Since Aug 9Pushed 2y ago2 watchersCompare

[ Source](https://github.com/nazarii-kretovych/laravel-api-model-driver)[ Packagist](https://packagist.org/packages/nazarii-kretovych/laravel-api-model-driver)[ RSS](/packages/nazarii-kretovych-laravel-api-model-driver/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

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
--------

[](#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
------------

[](#installation)

Install the library using composer:

```
composer require nazarii-kretovych/laravel-api-model-driver
```

Configuration
-------------

[](#configuration)

Open **config/database.php** and add a new API connection:

```
