/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Requests\SupplierRequest $request) { // $data = $request->except(['_token']); Supplier::create($data); return redirect()->to('supplier'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(SupplierRequest $request) { $input = $request->all(); $user_id = '1'; $customer = new Supplier(); $customer->name = $input['name']; $customer->address1 = $input['address1']; $customer->address2 = $input['address2']; $customer->city = $input['city']; $customer->telephone = $input['telephone']; $customer->mobile = $input['mobile']; $customer->email = $input['email']; $customer->fax = $input['fax']; $customer->website = $input['website']; $customer->vat_no = $input['vat_no']; $customer->contact_person = $input['contact_person']; $customer->account_sys_id = $input['account_sys_id']; $customer->created_by = $user_id; $customer->save($request->all()); return redirect('/suppliers'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(SupplierRequest $request, $id) { $supplier = Supplier::find($id); $supplier->update($request->all()); return redirect()->route('admin.suppliers.index')->with('status', 'Supplier record updated!'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(SupplierRequest $request, $id) { $suppliers = Supplier::find($id); $suppliers->company_name = Input::get('company_name'); $suppliers->name = Input::get('name'); $suppliers->email = Input::get('email'); $suppliers->phone_number = Input::get('phone_number'); $suppliers->address = Input::get('address'); $suppliers->city = Input::get('city'); $suppliers->state = Input::get('state'); $suppliers->zip = Input::get('zip'); $suppliers->comments = Input::get('comments'); $suppliers->account = Input::get('account'); $suppliers->save(); // process avatar $image = $request->file('avatar'); if (!empty($image)) { $avatarName = 'sup' . $id . '.' . $request->file('avatar')->getClientOriginalExtension(); $request->file('avatar')->move(base_path() . '/public/images/suppliers/', $avatarName); $img = Image::make(base_path() . '/public/images/suppliers/' . $avatarName); $img->resize(100, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save(); $supplierAvatar = Supplier::find($id); $supplierAvatar->avatar = $avatarName; $supplierAvatar->save(); } Session::flash('message', 'You have successfully updated supplier'); return Redirect::to('suppliers'); }
public function update($id, SupplierRequest $request) { $supplier = Supplier::findOrFail($id); $supplier->suppliers_type = $request->input('suppliers_type'); $supplier->company_name = $request->input('company_name'); $supplier->company_address = $request->input('company_address'); $supplier->company_office_phone = $request->input('company_office_phone'); $supplier->company_office_fax = $request->input('company_office_fax'); $supplier->contact_person = $request->input('contact_person'); $supplier->contact_person_phone = $request->input('contact_person_phone'); $supplier->supplier_description = $request->input('supplier_description'); $supplier->status = $request->input('status'); $supplier->updated_at = time(); $supplier->updated_by = Auth::user()->id; $supplier->update(); Session()->flash('flash_message', 'Data has been Updated'); return redirect('suppliers'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(SupplierRequest $request, $id) { if (Supplier::find($id)->update($request->all())) { return redirect('/supplier')->with('succcess', 'Sukses ubah data supplier.'); } return redirect()->back()->withErrors(['failed' => 'Gagal ubah data supplier.']); }