2017 © Pedro Peláez
 

library model

image

boyhagemann/model

  • Monday, March 31, 2014
  • by boyhagemann
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Model

With this package you can:, (*1)

  • Generate an Eloquent model as a file and export it to the database.
  • Use a fluent interface to write the model specs
  • Define cross relationships between models

Install

Use [Composer] (http://getcomposer.org) to install the package into your application, (*2)

require {
    "boyhagemann/model": "dev-master"
}

Then add the following line in app/config/app.php:, (*3)

...
"Boyhagemann\Model\ModelServiceProvider"
...

Example usage


// Get a fresh ModelBuilder instance $mb = App::make('ModelBuilder'); // Set the name of the model class $mb->name('Article'); // Set the database table $mb->table('news'); // Change the folder where to store this model $mb->folder('/app/models'); // Add columns to the table, each with their own fluent interface // depending on their type of column. $mb->string('title')->required(); $mb->text('description')->length(50); $mb->integer('number_of_views'); // Add relationships, each with their own fluent interface // depending on their type of relationship. $mb->hasOne('Category');

Auto-generating and updating models

This package checks if the model exists yet in the IoC container. If it doesn't, then the Eloquent model file is written to disk and the database table is created. During development it may be handy to keep updating your database the moment you changed your configuration., (*4)

$mb->autoGenerate();

The Versions

31/03 2014

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Boy Hagemann