public static function store() { self::check_logged_in(); $params = $_POST; $attributes = array('itemtype_id' => $params['itemtype_id'], 'description' => $params['description']); $item = new Item($attributes); $errors = $item->errors(); if (count($errors) == 0) { // The part number is added when the existance of the part type is validated $itemtype = ItemType::find($params['itemtype_id']); $item->setPN($itemtype->getNextPN()); $item->save(); Redirect::to('/item/' . $item->id, array('message' => 'The new item has been added to the database')); } else { $itemtypes = ItemType::all(); View::make('item/new.html', array('errors' => $errors, 'attributes' => $attributes, 'itemtypes' => $itemtypes)); } }
public static function index() { $itemtypes = ItemType::all(); View::make('itemtype/index.html', array('itemtypes' => $itemtypes)); }