示例#1
0
 public function store(ComponentRequest $request)
 {
     $component = new Component();
     $component->name_en = $request->input('name_en');
     $component->name_bn = $request->input('name_bn');
     $component->icon = $request->input('icon');
     $component->description = $request->input('description');
     $component->ordering = $request->input('ordering');
     $component->created_by = Auth::user()->id;
     $component->created_at = time();
     $component->save();
     Session()->flash('flash_message', 'Component has been created!');
     return redirect('components');
 }
示例#2
0
 /**
  * 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());
 }