2017 © Pedro Peláez
 

library foundry

A simple but powerful CRUD tool for Laravel

image

earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  • Saturday, December 6, 2014
  • by btothez
  • Repository
  • 1 Watchers
  • 1 Stars
  • 43 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

foundry

Easily perform CRUD tasks on Eloquent models, (*1)

This is a replacement for Laravel's Resource Controllers, which are very lightweight., (*2)

Installation

Add "earlybirdmvp/foundry" to your composer.json file and run composer update., (*3)

Then add these lines to your app/start/global.php file:, (*4)

View::addLocation(base_path().'/vendor/earlybirdmvp/foundry/views');
View::addNamespace('foundry', base_path().'/vendor/earlybirdmvp/foundry/views');

Getting Started

First create your Foundry model., (*5)

class Product extends Eloquent {
    use Earlybird\Foundry;
}

Then create a Controller:, (*6)

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., (*7)

Route::resource('product', 'ProductController');

That's all!, (*8)

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., (*9)

Features

  • Works well with Bootstrap classes
  • This is meant to be a CMS, not a DB admin tool. Therefore the Eloquent $hidden and $guarded arrays are respected and not visible or editable, respectively.
  • If a column name has a comment, that is shown instead (can be used to create user-friendly labels)
  • Supported data types:
bigint, char, date, decimal, enum, int, text, tinyint, varchar
  • Validation is built in. 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 checked
  • Validation errors are displayed next to the problematic input
  • Very basic belongsTo 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');
    }
}
  • These 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;
    }
}

Options

Controller

  • Specify the model with protected $model. Default is class name with "Controller" stripped off.
  • Set the number of items shown per page with protected $per_page. Default 10.
  • If you wish to detect updates, create a detectChange function. This is called before save() so that you can compare the old and new values
class OrderController extends BaseController {
    use Earlybird\FoundryController;

    public function detectChange() {
        // Email customer update that order status was changed
    }
}

Todo

  • sort and filter the index page
  • support more data types
  • improve validation for dates
  • improve support for relationships
  • delete resources
  • bulk updates and deletes
  • more flexible layout

The Versions

06/12 2014

dev-master

9999999-dev https://github.com/earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  Sources   Download

Apache-2.0

The Requires

 

laravel crud activerecord

06/12 2014

v0.3.0

0.3.0.0 https://github.com/earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  Sources   Download

Apache-2.0

The Requires

 

laravel crud activerecord

14/08 2014

v0.1.1

0.1.1.0 https://github.com/earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  Sources   Download

The Requires

 

laravel crud activerecord

14/08 2014

v0.2.0

0.2.0.0 https://github.com/earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  Sources   Download

The Requires

 

laravel crud activerecord

14/08 2014

v0.1

0.1.0.0 https://github.com/earlybirdmvp/foundry

A simple but powerful CRUD tool for Laravel

  Sources   Download

The Requires

 

laravel crud activerecord