eeappdev/laravel-external-id

Make a morph-table to keep track of external id relationships for external API

0.0.4 2023-06-29 19:08 UTC

This package is auto-updated.

Last update: 2024-05-30 00:16:10 UTC


README

Latest Version on Packagist Total Downloads

When you are working with an external API, and need to syncronize clients, products, services, categories or like, this package help you to store the external id for all the models you want.

This package provides a HasExternalId trait that, once installed on a model, allows you to do things like this:

// Store (update or create) the external id
$model->addExternalId('external_unique_id');

// Remove/unlink an external ID
$model->removeExternalId();

// Get the external ID
$model->getExternalID();

// Get all external information
$model->external()

Installation

You can install the package via composer:

composer require eeappdev/laravel-external-id

You must publish the migration with:

php artisan vendor:publish --provider="Eeappdev\ExternalId\ExternalIdServiceProvider" --tag="migrations"

Migrate the external_ids table:

php artisan migrate

Usage

Add the HasExternalId trait to a model you like to use external relationships on.

use Eeappdev\ExternalId\HasExternalId;

class Client extends Model
{
    use HasExternalId;

License

The MIT License (MIT). Please see License File for more information.