public function showFt($id, $slug = null) { $hotel = $this->model->getShow($id); $data = ['hotel' => $hotel, 'hotellists' => $this->model->getLast(4), 'attrnolang' => $this->attr->noLang('room', $id, default_lang_id()), 'attrhaslang' => $this->attr->requireLang('room', $id, default_lang_id())]; return $hotel; return view('website.hotel.hotelshow', $data); }
public function updateType($id, $args) { if ($this->valid($args, $this->rules_nolang())) { $item = $this->findItem($id); $name = $args['name']; $slug = $args['slug']; $cat_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug)]; $item->langs()->sync([default_lang_id() => $cat_desc]); } else { throw new ValidationException('Vui lòng điền đầy đủ các trường!', $this->getError()); } }
function get_setting($key, $lang_id = null) { $lang_id = $lang_id == null ? default_lang_id() : $lang_id; $result = \App\Model\Setting::where('key', $key)->where('lang_id', $lang_id)->get(['value'])->first(); if (empty($result)) { return null; } else { $value = $result->value; $value = is_serialized($value) ? unserialize($value) : $value; return $value; } }
public function update($id, $args) { $langs = get_langs(); $post = $this->findItem($id); if (isset($args['image'])) { $post->image = get_path($args['image']); } if (isset($args['post_status'])) { $post->post_status = $args['post_status']; } if (!$post->update()) { throw new ExcuteException('save_error', 'Không lưu được'); } $post->cats()->detach(); if (isset($args['cats'])) { $post->cats()->attach($args['cats']); } if (isset($args['newtags'])) { $newtags = $args['newtags']; if ($newtags) { foreach ($newtags as $tag) { $newtag = new Category(); $newtag->type = 'tag'; $newtag->save(); $newtag->langs()->attach(default_lang_id(), ['name' => $tag, 'slug' => toSlug($tag)]); $post->cats()->attach($newtag->id); } } } if (isset($args['availtags'])) { $availtags = $args['availtags']; if ($availtags) { $post->cats()->attach($availtags); } } $syncs = []; foreach ($langs as $lang) { $code = $args[$lang->code]; if (isset($code['post_title'])) { $this->post_title = $code['post_title']; } if (isset($code['slug'])) { $this->slug = $code['slug']; } $slug = trim($this->slug) == '' ? toSlug($this->post_title) : toSlug($this->slug); if (isset($code['post_content'])) { $this->post_content = $code['post_content']; } if (isset($code['post_excerpt'])) { $this->post_excerpt = $code['post_excerpt']; } if (isset($code['custom'])) { $this->custom = $code['custom']; } $post_desc = ['post_title' => $this->post_title, 'slug' => $slug, 'post_content' => $this->post_content, 'post_excerpt' => $this->post_excerpt, 'custom' => $this->custom]; $syncs[$lang->id] = $post_desc; } $post->langs()->sync($syncs); }