/**
  * Validate and store data for new component.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see ComponentsController::getCreate() method that generates the view
  * @since [v3.0]
  * @return Redirect
  */
 public function postCreate()
 {
     // create a new model instance
     $component = new Component();
     // Update the component data
     $component->name = e(Input::get('name'));
     $component->category_id = e(Input::get('category_id'));
     $component->location_id = e(Input::get('location_id'));
     $component->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
     $component->order_number = e(Input::get('order_number'));
     $component->min_amt = e(Input::get('min_amt'));
     if (e(Input::get('purchase_date')) == '') {
         $component->purchase_date = null;
     } else {
         $component->purchase_date = e(Input::get('purchase_date'));
     }
     if (e(Input::get('purchase_cost')) == '0.00') {
         $component->purchase_cost = null;
     } else {
         $component->purchase_cost = e(Input::get('purchase_cost'));
     }
     $component->total_qty = e(Input::get('total_qty'));
     $component->user_id = Auth::user()->id;
     // Was the component created?
     if ($component->save()) {
         // Redirect to the new component  page
         return redirect()->to("admin/components")->with('success', trans('admin/components/message.create.success'));
     }
     return redirect()->back()->withInput()->withErrors($component->getErrors());
 }