https://github.com/ayzerobug/laravel-external-references
Easy link Laravel Models with external references for seamless integration and enhanced functionality.
https://github.com/ayzerobug/laravel-external-references
external ids laravel reference
Last synced: 5 months ago
JSON representation
Easy link Laravel Models with external references for seamless integration and enhanced functionality.
- Host: GitHub
- URL: https://github.com/ayzerobug/laravel-external-references
- Owner: ayzerobug
- License: mit
- Created: 2024-05-15T02:41:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-30T09:06:14.000Z (10 months ago)
- Last Synced: 2025-09-30T22:49:20.677Z (9 months ago)
- Topics: external, ids, laravel, reference
- Language: PHP
- Homepage: https://packagist.org/packages/ayzerobug/laravel-external-references
- Size: 49.8 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README

# Manage External References in Laravel
[](https://packagist.org/packages/ayzerobug/laravel-external-references)
[](https://github.com/ayzerobug/laravel-external-references/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/ayzerobug/laravel-external-references/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/ayzerobug/laravel-external-references)
This package facilitates the seamless integration of your Laravel Models with external systems or services by managing external references or identifiers. It streamlines the process of associating your application's data with external datasets, such as payment processor IDs or user accounts. This enhancement enables the smooth integration of your application with diverse services and systems, thereby augmenting its capabilities and adaptability.
## Installation
You can install the package via composer:
```bash
composer require ayzerobug/laravel-external-references
```
You can publish and run the migrations with:
```bash
php artisan vendor:publish --tag="external-references-migrations"
php artisan migrate
```
You can publish the config file with:
```bash
php artisan vendor:publish --tag="external-references-config"
```
## Usage
Include the HasExternalReferences trait in your model:
```php
namespace App\Models;
use Ayzerobug\LaravelExternalReferences\Traits\HasExternalReferences;
class Payment extends Model
{
use HasExternalReferences;
...
}
```
Set Payment External Reference:
```php
use App\Models\Payment;
$payment = Payment::find($id);
$idOnPaystack = "random-id";
$payment->setExternalReference($idOnPaystack, 'paystack');
```
Get the external Reference
```php
use App\Models\Payment;
$payment = Payment::find($id);
$idOnPaystack = $payment->getExternalReference('paystack');
```
Get Payment with the external Reference
```php
use App\Models\Payment;
$idOnPaystack = "random-id";
$payment = Payment::findByExternalReference($idOnPaystack, 'paystack');
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Ayomide Micheal](https://github.com/ayzerobug)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.