<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thibaud-dauce / eloquent-inheritance-storage example snippets
use ThibaudDauce\EloquentInheritanceStorage\ParentTrait;
class Character extends Eloquent {
use ParentTrait;
protected $table = 'characters';
protected $primaryKey = 'name';
}
class Warrior extends Character {
protected $table = 'warriors';
}
class Wizard extends Character {
protected $table = 'wizards';
}
DB::statement("
CREATE VIEW `characters` AS
SELECT
`characters_storage`.`id` AS `id` ,
'Character' AS `class_name` ,
`characters_storage`.`name` AS `name` ,
NULL AS `rage` ,
NULL AS `magic` ,
FROM `characters_storage`
UNION
SELECT
`warriors`.`id` AS `id` ,
'Warrior' AS `class_name` ,
`warriors`.`name` AS `name` ,
`warriors`.`rage` AS `rage` ,
NULL AS `magic` ,
FROM `warriors`
UNION
SELECT
`wizards`.`id` AS `id` ,
'Wizard' AS `class_name` ,
`wizards`.`name` AS `name` ,
`wizards`.`magic` AS `magic` ,
NULL AS `rage` ,
FROM `wizards` ;
");
use ThibaudDauce\EloquentInheritanceStorage\ParentTrait;
class Character extends Eloquent {
use ParentTrait;
protected $table = 'characters';
protected $inheritanceStorageName = 'characters-table';
protected $primaryKey = 'name';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.