PHPackages                             sidigi/laravel-remote-models - 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. sidigi/laravel-remote-models

ActiveLibrary

sidigi/laravel-remote-models
============================

Use remote requests in laravel eloquent models way

1.0.6(5y ago)54.3kMITPHPPHP ^7.4|^8.0CI failing

Since Aug 14Pushed 5y ago2 watchersCompare

[ Source](https://github.com/sidigi/laravel-remote-models)[ Packagist](https://packagist.org/packages/sidigi/laravel-remote-models)[ Docs](https://github.com/spatie/laravel-remote-models)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/sidigi-laravel-remote-models/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (27)Used By (0)

Use remote requests in laravel eloquent models way
==================================================

[](#use-remote-requests-in-laravel-eloquent-models-way)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d00ffd65a28813998d67f14504cb0d1fedc41d1daf54465e0431fac031c86238/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369646967692f6c61726176656c2d72656d6f74652d6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sidigi/laravel-remote-models)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d5fd06a1b4fab70f0e01b568ba23dc2907785d77dc52c831254dbd67c9a74bff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7369646967692f6c61726176656c2d72656d6f74652d6d6f64656c732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/sidigi/laravel-remote-models/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/dcb6b60cb1a76b9439456ef45d752228c95cb74952090a3db4a33b5b2441f9b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369646967692f6c61726176656c2d72656d6f74652d6d6f64656c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sidigi/laravel-remote-models)

This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sidigi/laravel-remote-models
```

Usage
-----

[](#usage)

### Config

[](#config)

```
    'defaults' => [
        'response_key'        => 'data',
        'pagination_strategy' => 'page_based',
    ],

    'providers' => [
        'aws-lambda' => [
            'class' => Sidigi\LaravelRemoteModels\Providers\AwsLambdaProvider::class,
        ],
        'http' => [
            'class' => Sidigi\LaravelRemoteModels\Providers\HttpProvider::class,
        ],
    ],

    'pagination_strategies' => [
        'page_based' => [
            'class'               => Sidigi\LaravelRemoteModels\Pagination\PaginationBaseStrategy::class,
            'response_number_key' => 'meta.pages_count',
            'defaults'            => [
                'number' => 1,
                'size'   => 100,
            ],
        ],
    ],

    'clients' => [
        'comment-client' => [
            'client' =>  App\RemoteClients\CommentClient::class,
            'base_uri' => 'https://jsonplaceholder.typicode.com',
   |        'provider' => 'http',
            'pagination_strategy' => 'page_based',
            'paths' => [
                'index_comments' => 'comments',
                'index_comments_filter_by_post' => '/comments?postId={id}',
                'todo_detail' => 'todos/{id}',
            ],
        ],
        'aws-comment-client' => [
            'client' =>  App\RemoteClients\AwsCommentClient::class,
            'base_uri' => 'https://jsonplaceholder.typicode.com',
   |        'provider' => 'aws-lambda',
            'function_name' => 'user-service-api',
            'pagination_strategy' => 'page_based',
            'paths' => [
                'index_comments' => 'comments',
                'index_comments_filter_by_post' => '/comments?postId={id}',
                'todo_detail' => 'todos/{id}',
            ],
        ],
    ],

    'models' => [
        App\RemoteModels\Comment::class => 'comment-client',
        //or
        App\RemoteModels\Comment::class => App\RemoteClients\CommentClient::class,
        //or
        App\RemoteModels\Comment::class => [
            'aws' => 'aws-comment-client',
            'http' => 'comment-client',
         ]
    ],
```

### Clients

[](#clients)

```
use Sidigi\LaravelRemoteModels\Client;

class CommentClient extends Client
{
}

$comments = Comment::getRemoteClient()->get();
$comments = Comment::getRemoteClient()->get('/comments');
$comments = Comment::getRemoteClient()->get('/comments/{id}', ['id' => 1]);
$comments = Comment::getRemoteClient()->get('/comments/{id}', ['id' => 1, 'active' => true]);
$comments = Comment::getRemoteClient()->withPath('/comments/{id}', ['id' => 1])->get();
$comments = Comment::getRemoteClient()->withQuery(['active' => true])->get();
$comments = Comment::getRemoteClient()->get(['active' => true]);
```

```
use Sidigi\LaravelRemoteModels\Client;

class CommentClient extends Client
{
    public function getPaths() : array
    {
        return [
            'index_comments' => 'comments',
            'detail_comment' => 'comment/{id}',
        ]
    }
}

$comments = CommentClient::withPath('index_comments')->get();
$comments = CommentClient::indexComments()->get();
$comments = CommentClient::withPath('detail_comment', ['id' => 1])->get();
$comments = CommentClient::detailComment(['id' => 1])->get();
$comments = CommentClient::detailComment(['id' => 1])->withQuery(['active' => true])->get();
```

```
use Sidigi\LaravelRemoteModels\Client

class CommentClient extends Client
{
}

$comments = CommentClient::withPath('/comments/{id}', ['id' => 1])
                ->withQuery(['active' => true])
                ->filter(['id' => [1, 2, 3])
                ->include('posts.user')
                ->orderBy('created_at')
                ->paginate(['size' => 1, 'number' => 2])
                ->get();
```

### Models

[](#models)

```
use Sidigi\LaravelRemoteModels\Client;

class CommentClient extends Client
{
}

class Comment extends Model
{
    use HasRemotes;

    protected $guarded = [];

    public function getRemoteClient(): string
    {
        return resolve(CommentClient::class);
    }
}

$comment = Comment::getRemoteClient()
    ->indexComments()
    ->get() //response with models
    ->mapModel(Comment::class, fn ($item) => ['id' => $item['id']])
    ->first();

//App\RemoteModels\Comment
```

Client classes are extended `Illuminate\Http\Client\PendingReuqest`. You can use all http client methods

```
$comment = Comment::getRemoteClient()
    ->indexComments()
    ->withHeaders(['X-Foo' => 'X-Baz']) //withToken, withAuth, etc.
    ->get() //response with models
    ->mapModel(Comment::class)
    ->first();
//App\RemoteModels\Comment
```

```
$builder = Comment::getRemoteClient()->indexComments();

foreach ($builder->perPage() as $response) {
    $comments = $response->mapModel(Note::class);
}
```

```
$builder = Post::getRemoteClient()->index();

foreach ($builder->perPage() as $response) {
    $comments = $response->mapModel(
        Comment::class,
        fn ($item) => ['id' => $item['id']],
        'data.*.comments'
    );
}
```

```
$builder = Post::getRemoteClient()->index();

foreach ($builder->perPage() as $response) {
    $commentIds = $response->get('data.*.comments.*.id');
}
```

Detail information about laravel http client [here](https://laravel.com/docs/8.x/http-client)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  or use the issue tracker.

Credits
-------

[](#credits)

- [Sidigi](https://github.com/sidigi)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

20

Last Release

1845d ago

Major Versions

0.0.13 → 1.0.02021-02-27

PHP version history (2 changes)0.0.1PHP ^7.4

0.0.13PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c697e16f8ed41fefc29c64f1a055e540886077b6d2e0b43daabb66f599ec9eb?d=identicon)[SidiGi](/maintainers/SidiGi)

---

Top Contributors

[![sidigi](https://avatars.githubusercontent.com/u/1765748?v=4)](https://github.com/sidigi "sidigi (64 commits)")

---

Tags

sidigilaravel-remote-models

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sidigi-laravel-remote-models/health.svg)

```
[![Health](https://phpackages.com/badges/sidigi-laravel-remote-models/health.svg)](https://phpackages.com/packages/sidigi-laravel-remote-models)
```

###  Alternatives

[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[bayareawebpro/laravel-multistep-forms

Responsable MultiStep Form Builder for Laravel.

967.9k](/packages/bayareawebpro-laravel-multistep-forms)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
