Giter Site home page Giter Site logo

scaffold's Introduction

Scaffold Laravel Bundle

Easily create scaffolds to manage your database.

Installation

Install using the Artisan CLI:

php artisan bundle:install scaffold
php artisan bundle:publish

Then, place the bundle's name in your application/bundles.php file:

<?php

return array(

	'scaffold',
);

Don't forget that each time you generate a scaffold, you will need to add the Controller in your routes. Or, simply use this:

<?php

Route::controller(Controller::detect());

A Few Examples

Creating a full Blog... in seconds!

Say you want to make a blog that contains posts that are posted by users. You could manually code all of that, or you could just run:

$ php artisan scaffold::make blog.comment content:text belongs_to:blog.post,user timestamps
$ php artisan migrate

$ php artisan scaffold::make blog.post title:string content:text belongs_to:user has_many:blog.comment timestamps
$ php artisan migrate

$ php artisan scaffold::make user username:string password:string has_many:blog.post,blog.comment
$ php artisan migrate

Now isn't that a bit faster?

Dissecting the Blog Example

This is the basic structure to generate a new scaffold:

php artisan scaffold::make <name> <attributes> <relationships> <timestamps>

name: The scaffold's name (always singular). Notice that the scaffold can be nested by adding a prefix and a period.

attributes: The scaffold's attributess, separated by a space. The different supported attribute types are: string, integer, float, boolean, date, timestamp, text, and blob. The general syntax for an attribute is:

name:type

title:string

Additionally, you can make a attribute nullable:

name:type:nullable

title:string:nullable

Or, you can set a character limit for an attribute:

name:type:length

title:string:255

You can even set a character limit and make an attribute nullable:

name:type:length:nullable

title:string:255:nullable

relationships: The relationships between this scaffold and other scaffolds, separated by a space. The different supported relationships are: has_one, has_one_or_many, belongs_to, has_many, and has_many_and_belongs_to. The general syntax for a relationship is:

relationship:scaffold

has_many:post

Note that the scaffold is always in its singular form. Additionally, several similar relationships may be defined at the same time using a comma (but no spaces):

relationship:scaffold1,scaffold2

has_many:post,comment

It is important to note that the different scaffolds listed within a similar relationship should be ordered by importance. For example, a post is more important than a comment. Additionally, if the scaffold is nested it should be prefixed like so:

has_many:blog.post,blog.comment

timestamps: If included, this will make the scaffold automatically timestamp when rows are created or updated. If timestamps is omitted, the scaffold will not do this.

scaffold's People

Contributors

loic-sharma avatar asirco avatar akhy avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.