Download the PHP package thibaud-dauce/eloquent-inheritance-storage without Composer

On this page you can find all versions of the php package thibaud-dauce/eloquent-inheritance-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eloquent-inheritance-storage

Eloquent Inheritance Storage

Build Status

Introduction

Eloquent Inheritance Storage is extending Eloquent ORM in order to provide support for models extending other models. It allows you to store and retrieve parent and child models easily.

This package is an extension of the single table inheritance pattern. It uses views to combine data coming from several tables of a class hierarchy. By doing this we are avoiding tables with many NULL values.

Installation

PHP 5.4+ and Laravel 4.2+ are required.

To get the latest version of Eloquent Inheritance Storage, simply require "thibaud-dauce/eloquent-inheritance-storage": "0.*" in your composer.json file. You'll then need to run composer install or composer update to download it and have the autoloader updated.

Once Eloquent Inheritance Storage is installed, you need to register the service provider. Open up app/config/app.php and add the following to the providers key.

You can register the InheritanceStorage facade in the aliases key of your app/config/app.php file if you like.

Model configuration example

Presentation

Let's imagine that I'm currently developing a video game with different kind of characters. I will have some basic characters and some specialized ones:

My class hierarchy will be the following:

Models

Apply the ThibaudDauce\EloquentInheritanceStorage\ParentTrait to the Character model (the parent class).

Don't do anything to the Warrior and Wizard models (the child classes).

Database

We are going to create 3 tables and a view:

Let's create our tables. Pay attention to the different tables' name!

And finally, let's create the characters view that will contain our characters, warriors and wizards. Don't forget to the add a class_name field to your view.

Usage

Get a model

Character::all() will return a collection containing Character, Warrior and Wizard models.

Character::find($characterName) will return a Character.

Character::find($warriorName) will return a Warrior.

Warrior::find($warriorName) will return a Warrior.

Warrior::find($characterName) or Warrior::find($wizardName) will throw an error.

Save a model

Character::create(array('name' => 'Thibaud')) will store a character in the characters_storage table.

Warrior::create(array('name' => 'Thibaud', 'rage' => 10)) will add a line in the warriors table.

Extending the package

Storage name

You can use a different storage table name by defining $inheritanceStorageName in your parent model.

Example: for a view named characters and a storage table named characters-table


All versions of eloquent-inheritance-storage with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
laravel/framework Version 4.2.*
illuminate/support Version 4.2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thibaud-dauce/eloquent-inheritance-storage contains the following files

Loading the files please wait ....