public function update($id, Request $request) { $valid = \Validator::make($request->all(), ['lname' => 'required', 'code' => 'required|unique:languages,code,' . $id, 'icon' => 'required']); if ($valid->fails()) { return redirect()->back()->withErrors($valid)->withInput(); } else { $lang = Lang::find($id); $name = $request->input('lname'); $lang->lname = $name; $slug = $request->input('slug'); $lang->slug = trim($slug) == '' ? toSlug($name) : toSlug($slug); $lang->code = $request->input('code'); $lang->icon = $request->input('icon'); $lang->folder = $request->input('folder'); $lang->status = $request->input('status'); $lang->order = $request->input('order'); $default = $request->input('default'); if ($default == 1) { Lang::where('default', 1)->where('id', '!=', $id)->update(['default' => 0]); $lang->default = 1; } if ($lang->update()) { return redirect()->route('lang.index')->with('Mess', 'Thêm mới thành công!'); } else { return redirect()->back()->with('errorMess', 'Có lỗi xảy ra, Vui lòng hử lại sau!'); } } }
public function admin_ajax() { $action = Input::get('action'); if ($action == 'menu_link') { $type = Input::get('type'); $item_id = Input::get('item_id'); $link = Input::get('link'); if ($item_id == 0) { $value = $link; } else { $value = $item_id; } switch ($type) { case 'cat': $cats = Lang::where('id', get_default_lang()->id)->with('cats')->first()->cats()->where('type', 'cat')->lists('name', 'id')->toArray(); $output = Form::select('link', $cats, [$value], ['class' => 'form-control']); break; case 'page': $posts = Lang::where('id', get_default_lang()->id)->with('posts')->first()->posts()->where('post_type', 'page')->lists('post_title', 'id'); $output = Form::select('link', $posts, $value, ['class' => 'form-control']); break; case 'post': $posts = Lang::where('id', get_default_lang()->id)->with('posts')->first()->posts()->where('post_type', 'post')->lists('post_title', 'id'); $output = Form::select('link', $posts, $value, ['class' => 'form-control']); break; case 'custom': $output = Form::text('link', $value, ['class' => 'form-control', 'placeholder' => 'http://']); break; default: break; } return $output; } if ($action == 'media_upload') { echo 'media_upload'; } if ($action == 'append_modal') { // $data = [ // 'files' => Post::where('post_type', 'fileimage')->get() // ]; return redirect()->route('file.dialog'); } }
public function __construct() { $this->resortId = 2; $langDefault = Lang::where('name', '=', App::getLocale())->first(); if ($langDefault != NULL) { $this->langId = $langDefault->id; } else { $this->langId = 1; } $accommodationsFooter = Accommodation::with(['contents' => function ($query) { $query->select('accommodation_contents.accommodation_id', 'accommodation_contents.name'); $query->where('lang_id', '=', $this->langId); }])->where('resort_id', $this->resortId)->get(); $resort = Resort::active()->with(['contents' => function ($query) { $query->where('lang_id', '=', $this->langId); }])->where('id', $this->resortId)->first(); //return dd($accommodationsFooter->toArray()); View::share('resort', $resort); View::share('accommodationsFooter', $accommodationsFooter); }
public function getByName($lang_name) { return Lang::where('code', '=', $lang_name)->get(); }
public function index() { $posts = Lang::where('code', current_lang())->first()->posttype('post')->lists('post_title', 'id')->toArray(); $data = ['columns' => ['id' => 'ID', 'name' => 'Họ tên', 'email' => 'Email', 'status' => 'Trạng thái', 'created_at' => 'Thời gian'], 'items' => Subscribe::orderBy('created_at', 'desc')->paginate(20), 'posts' => $posts]; return view('backend.subscribe.index', $data); }