https://github.com/brokeyourbike/has-source-model-laravel
Interface for interacting with source models in Laravel
https://github.com/brokeyourbike/has-source-model-laravel
eloquent eloquent-models hacktoberfest interface laravel laravel-8 laravel-8-package php php8
Last synced: about 1 month ago
JSON representation
Interface for interacting with source models in Laravel
- Host: GitHub
- URL: https://github.com/brokeyourbike/has-source-model-laravel
- Owner: brokeyourbike
- License: mpl-2.0
- Created: 2021-10-19T14:49:17.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-20T11:39:24.000Z (over 2 years ago)
- Last Synced: 2025-10-09T02:49:48.115Z (about 2 months ago)
- Topics: eloquent, eloquent-models, hacktoberfest, interface, laravel, laravel-8, laravel-8-package, php, php8
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# has-source-model
[](https://github.com/brokeyourbike/has-source-model-laravel/releases)
[](https://packagist.org/packages/brokeyourbike/has-source-model)
[](https://codeclimate.com/github/brokeyourbike/has-source-model-laravel/maintainability)
[](https://codeclimate.com/github/brokeyourbike/has-source-model-laravel/test_coverage)
Interface for interacting with source models.
## Installation
```bash
composer require brokeyourbike/has-source-model
```
## Usage
```php
use BrokeYourBike\HasSourceModel\HasSourceModelInterface;
use BrokeYourBike\HasSourceModel\HasSourceModelTrait;
class Client implements HasSourceModelInterface
{
use HasSourceModelTrait;
public function fetchTransaction(Transaction $transaction)
{
$this->setSourceModel($transaction);
$this->performRequest("transactions/{$transaction->id}");
}
private function performRequest(string $url)
{
if ($this->getSourceModel($transaction)) {
// do something with it
}
}
}
```
## Authors
- [Ivan Stasiuk](https://github.com/brokeyourbike) | [Twitter](https://twitter.com/brokeyourbike) | [LinkedIn](https://www.linkedin.com/in/brokeyourbike) | [stasi.uk](https://stasi.uk)
## License
[Mozilla Public License v2.0](https://github.com/brokeyourbike/has-source-model-laravel/blob/main/LICENSE)