daltonmccleery/remote-models
Remote Models lets your Laravel app work with Eloquent models that live in another application, bridging local code and remote data. Query, sync, and manage records across services using familiar Eloquent-style syntax.
composer require daltonmccleery/remote-models. As of 1.3.0 the package supports Laravel 12, so it can be installed on current Laravel apps without --ignore-platform-reqs or Composer constraint workarounds. Confirm your app's PHP version matches the package's composer.json (Laravel 12 requires PHP 8.2+).php artisan vendor:publish --tag=remote-models-config. Put the remote API base URL, timeout, and credentials in config/remote-models.php and reference them from .env — never hard-code them in model classes.Http::get('.../users') call in a controller or service and replace it with a model class extending the package's base model, setting its endpoint to users. You immediately get a query-builder-style API (User::query()->where(...)->get()) instead of manually decoding JSON and mapping arrays.$hidden/$appends mirroring what you'd normally put on an Eloquent model. This keeps controllers free of transport concerns and makes the remote resource swappable later.save()/delete() against your API.page/per_page. Normalize the request and response keys in config or by overriding the relevant method on the model, then expose paginate() consistently so Blade/API resources don't need per-endpoint conditionals.Cache::remember() with keys derived from endpoint + query parameters. Invalidate on write operations in the system of record, or use short TTLs for volatile data.whereIn on IDs ) after the parent fetch rather than inside a loop.Http::fake() with fixtures per endpoint and Http::preventStrayRequests() in the test suite. Assert both the hydrated model attributes and the outgoing request (URL, query string, headers) — the latter catches pagination and auth regressions early.refresh() against a local store, no migrations, and no query log in the usual place. Don't assume ->save(), ->update(), or model events behave like the database-backed equivalents.data, meta, total, and last_page from your API's envelope and override if needed.config:cache traps. Resolve env values inside config/remote-models.php, not via env() calls scattered in model classes — otherwise deployed config silently diverges from local.App\Models\Remote\BaseRemoteModel) over editing vendor code, so future upgrades stay painless.How can I help you explore Laravel packages today?