| Package Data | |
|---|---|
| Maintainer Username: | btothez |
| Maintainer Contact: | andrew@earlybird.co (Andrew Weber) |
| Package Create Date: | 2015-02-16 |
| Package Last Update: | 2014-12-06 |
| Language: | PHP |
| License: | Apache-2.0 |
| Last Refreshed: | 2025-11-03 15:13:38 |
| Package Statistics | |
|---|---|
| Total Downloads: | 53 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 1 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
Easily perform CRUD tasks on Eloquent models
This is a replacement for Laravel's Resource Controllers, which are very lightweight.
Add "earlybirdmvp/foundry" to your composer.json file and run composer update.
Then add these lines to your app/start/global.php file:
View::addLocation(base_path().'/vendor/earlybirdmvp/foundry/views');
View::addNamespace('foundry', base_path().'/vendor/earlybirdmvp/foundry/views');
First create your Foundry model.
class Product extends Eloquent {
use Earlybird\Foundry;
}
Then create a Controller:
class ProductController extends BaseController {
use Earlybird\FoundryController;
}
Finally add a Route resource group. See http://laravel.com/docs/controllers#resource-controllers All of the "only", "except", etc. options can be used.
Route::resource('product', 'ProductController');
That's all!
Now you simply need to go to the URL product and you will see a paginated list of all Product objects. There is a button to create a new product, and columns with unique indexes link to edit the individual resource.
$hidden and $guarded arrays are respected and not visible or editable, respectively.bigint, char, date, decimal, enum, int, text, tinyint, varchar
NOT NULL columns are considered "required", any column containing "email" inside its name must be a valid email address, and columns with unique indexes are checkedbelongsTo relationships are supported. The column must end in _id and must have the same prefix as the name of the relationship. For example, if the products table has a category_id column, and this Eloquent relationship then it will work:class Product extends Eloquent {
use Earlybird\Foundry;
public function category() {
return $this->belongsTo('Category');
}
}
belongsTo relationships are shown as select dropdowns where the value is the id and the option text is the name attribute. If the table does not have a name column, or you wish to change what is displayed, you can use $appends:class Product extends Eloquent {
use Earlybird\Foundry;
protected $appends = array(
'foundry_value',
);
public function getFoundryValueAttribute() {
return $this->sku . ': ' . $this->name;
}
}
protected $model. Default is class name with "Controller" stripped off.protected $per_page. Default 10.detectChange function. This is called before save() so that you can compare the old and new valuesclass OrderController extends BaseController {
use Earlybird\FoundryController;
public function detectChange() {
// Email customer update that order status was changed
}
}