New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

railken/eloquent-instance

5,241 1
Install
composer require railken/eloquent-instance
Latest Version:v2.0.0
PHP:>=8.1
Laravel:9 · 10
License:MIT
Last Updated:Mar 27, 2024
Links: GitHub  ·  Packagist
Maintainer: railken

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

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

651,963,193 9,701
laravel/framework

The Laravel Framework.

610,364,751 34,988
laravel/tinker

Powerful REPL for the Laravel framework.

518,004,183 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

435,097,283 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

407,699,310 4,663

Version History

Version Released PHP Laravel License
v2.0.0 >=8.1 9.* || 10.* MIT
v1.0.2 >=7.1 MIT
v1.0.1 >=7.1 MIT
v1.0.0 >=7.1 MIT