Models

Usage

To generate Eloquent models, simply use the model command :

bob model [args] <model_name> [relationships ...]
Note : You can use the shortcut bob m instead of bob model to save characters.

Relationships can be defined in the format relationship_type:object_name for example :

bob model users has_many:task
Note : Always use the singular when generating relationships, if plurals are defined in the laravel strings.php file, they will be converted automatically.

Here is a list of acceptable relationships, and their shortcuts :

  • has_many or hm
  • has_one or ho
  • belongs_to or bt
  • has_and_belongs_to_many or hbm

Arguments

--timestamps Add automatic timestamping to your model. Remember to create the updated_at and created_at fields to your database.

Example

bob model user has_many:task belongs_to:profile --timestamps

produces :

<?php

class User extends Eloquent {

	public static $timestamps = true;

	public function task()
	{
		return $this->has_many('Task');
	}

	public function profile()
	{
		return $this->belongs_to('Profile');
	}

}