Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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