Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/al-one/eloquent-super-relations
Laravel Eloquent Super Relations
https://github.com/al-one/eloquent-super-relations
eloquent-cache eloquent-relations laravel-eloquent
Last synced: 3 months ago
JSON representation
Laravel Eloquent Super Relations
- Host: GitHub
- URL: https://github.com/al-one/eloquent-super-relations
- Owner: al-one
- License: mit
- Created: 2019-12-25T10:18:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-02T03:08:16.000Z (almost 3 years ago)
- Last Synced: 2024-04-14T04:21:28.015Z (9 months ago)
- Topics: eloquent-cache, eloquent-relations, laravel-eloquent
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Eloquent Super Relations
## Installing
```
# composer.json"minimum-stability": "dev",
"prefer-stable": true,
``````sh
$ composer require al-one/eloquent-super-relations -vvv
```## Usage
```php
hasOne('App\Profile', 'uid');
}/**
* @return Model|Collection|array|null
*/
public function eagerLoadProfile($relation, $models = [], $where = [])
{
// Get cached data for relation
if(!empty($where['uid'])) {
return cache()->remember("user:profile:{$where['uid']}", 86400, function() use($where) {
return Profile::find($where['uid']);
});
}
// return null for get from database
return null;
}}
```## License
MIT