/** * Update the specified resource in storage. * PUT /sysparams/{id} * * @param int $id * @return Response */ public function update($id) { $sysparam = Sysparam::findOrFail($id); if ($sysparam->type == 'file') { if (Input::hasFile('content')) { if (Input::file('content')->isValid()) { $destinationPath = '/img'; // upload path $extension = Input::file('content')->getClientOriginalExtension(); // getting image extension $fileName = rand(1, 1000) . '_' . $sysparam->key . '.' . $extension; // renameing image Input::file('content')->move(public_path() . $destinationPath, $fileName); // uploading file to given path $sysparam->value->content = $destinationPath . "/" . $fileName; } else { // sending back with error message. return Redirect::back()->with('errors', 'Uploaded file is not valid')->withInput(); } } } else { $sysparam->value->content = Input::get('content'); } $sysparam->push(); return Redirect::route('admin.sysparams.index')->with("message", "Data berhasil disimpan"); }