Skip to content

A simple trait that enables the use of instance of Model in your relationships

License

Notifications You must be signed in to change notification settings

railken/eloquent-instance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eloquent Instance

Actions Status

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);
    }
}

About

A simple trait that enables the use of instance of Model in your relationships

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages