2017 © Pedro Peláez
 

library magicmodel

Eloquent's extended Model with extra features.

image

paulvl/magicmodel

Eloquent's extended Model with extra features.

  • Friday, February 13, 2015
  • by paulvl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

MagicModel

This Laravel package provides extended functions for Eloquent., (*1)

Installation

Laravel 4.2

  1. Begin by installing this package through Composer. Edit your project's composer.json file to require paulvl/magicmodel., (*2)

    "require-dev": {
        "paulvl/magicmodel": "dev-master"
    }

    There is no support for Laravel 5., (*3)

  2. Next, update Composer from the Terminal:, (*4)

    composer update --dev
  3. Once this operation completes, add the service provider. Open app/config/app.php, and add a new item to the providers array., (*5)

    'PaulVL\MagicModel\MagicModelServiceProvider'
  4. And add a new item to the aliases array, on same app/config/app.php file., (*6)

    'MagicModel' => 'PaulVL\MagicModel\MagicModel'
  5. Finally in order to use MagicModel properly you have to extend your "Model" from MagicModel instead of Eloquent like this for example:, (*7)

    <?php
    . . .
    class User extends MagicModel implements UserInterface, RemindableInterface {
    . . .
    
    

Usage

MagicModel implements the following methods:, (*8)

To Verify References

MagicModel allows you to easily verify if a record is referenced by another one as a foreing key. You can use the static Model::hasReferences($id) method directly from your MagicModel's extended Model:, (*9)

example..., (*10)

<?php
    return dd(Model::hasReferences(1));
    //returns True if primary key "1" is referenced in any table as FK.
    //returns False if primary key "1" is NOT referenced in any table as FK.
?>

Or you can either use $object->isReferenced() method from an instanced object:, (*11)

example..., (*12)

<?php
    $object = Model::find(1);
    return dd($object->isReferenced());
    //returns True if the object is referenced in any table as FK.
    //returns False if the object is NOT referenced in any table as FK.
?>

The Versions

13/02 2015

dev-master

9999999-dev

Eloquent's extended Model with extra features.

  Sources   Download

MIT

The Requires

 

by Paul Vidal

13/02 2015

1.0.0

1.0.0.0

Eloquent's extended Model with extra features.

  Sources   Download

MIT

The Requires

 

by Paul Vidal