public function postEditacolor($id) { $material_color = MaterialColor::find($id); $color = Color::where('id', $material_color->color_id)->firstorfail(); $color->nombre = Input::get('nombre_color'); $color->save(); $material = MaterialColor::where('id', $material_color->id)->firstorfail(); $material_color->material_id = Input::get('material_id'); $material->save(); return Redirect::action('InventarioRecubControlador@getColores'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($palette_id, $color_id) { try { $color = Color::where('palette_id', $palette_id)->findOrFail($color_id); $color->fill(Input::all()); $color->validate(); $color->save(); return $this->respondOK(['data' => $this->transformer->transform($color)]); } catch (ModelNotFoundException $e) { return $this->respondNotFound(); } catch (ValidationException $e) { return $this->respondNotAcceptable($e->getMessage()); } catch (Exception $e) { return $this->respondBadRequest($e->getMessage()); } }
public function saveTemplate($truth_name, $tpl_name = '', $temptype = 0) { if ($tpl_name != '') { $tpl_exists = Template::where('name', $tpl_name)->first(); if ($tpl_exists) { $unpack_resuslt = $this->unpack($truth_name, $tpl_name, true, $temptype); } else { $tpl_exists = false; $unpack_resuslt = $this->unpack($truth_name, $tpl_name, true, $temptype); } } else { $tpl_exists = false; $unpack_resuslt = $this->unpack($truth_name, $tpl_name, false, $temptype); } if ($unpack_resuslt) { $tpl_info = $unpack_resuslt['config']; if ($tpl_exists) { $template = Template::find($tpl_exists->id); } else { $template = new Template(); $template->name = $unpack_resuslt['tpl_dir']; $template->tpl_num = $unpack_resuslt['tpl_num']; } $template->tpl_name = $tpl_info['template']['tpl_name']; $template->classify = $tpl_info['template']['classify']; $template->demo = $tpl_info['template']['demo']; $template->type = $tpl_info['template']['type']; $template->description = $tpl_info['template']['description']; $template->list1showtypetotal = $tpl_info['template']['list1showtypetotal']; $template->list2showtypetotal = $tpl_info['template']['list2showtypetotal']; $template->list3showtypetotal = $tpl_info['template']['list3showtypetotal']; $template->list4showtypetotal = $tpl_info['template']['list4showtypetotal']; $template->updated_at = date("Y-m-d H:i:s", time()); $insert_rst = $template->save(); if ($insert_rst) { $insert_id = $template->id; $color_arr = $tpl_info['tpl_color']; $tpl_color = array(); $i = 0; TemplateToColor::where('template_id', $insert_id)->delete(); if (count($color_arr) > 0) { foreach ($color_arr as $color) { $tpl_color[$i]['template_id'] = $insert_id; $tpl_color[$i]['color_code'] = Config::get('color.' . $color); $tpl_color[$i]['color_id'] = Color::where('color_en', $color)->pluck('id'); $i++; } TemplateToColor::insert($tpl_color); } } $result = ['err' => 1000, 'msg' => '上传模板成功']; } else { $result = ['err' => 1003, 'msg' => '解压文件失败']; } return $result; }