railken / eloquent-instance
Installs: 5 036
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- illuminate/database: 9.* || 10.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-27 19:45:20 UTC
README
A simple trait that enables the use of instance of Model
in your relationships. Why? Because otherwise it would be impossible to relate two models that doesn't exist in the code, but only as instances (e.g. stored in db)
Requirements
PHP 7.2 and laravel 5.8
Installation
You can install it via Composer by typing the following command:
composer require railken/eloquent-instance
Usage
Simple include Railken\EloquentInstance\HasRelationships
in your model and start using
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Railken\EloquentInstance\HasRelationships; class Author extends Model { use HasRelationships; public function books() { $book = new Book(); $book->setTable('book_custom'); return $this->hasMany($book); } }