public function show($id) { $category = Cache::want('category_' . $id, 0, function () use($id) { return Category::findOrFail($id); }); $articles = Article::with('tags')->where('cid', '=', $category->id)->orderBy('id', 'desc')->paginate(15); $values = array('title' => $category->name . '_', 'category' => $category, 'articles' => $articles); return View::make('category.show', $values); }
/** * Update the specified category in storage. * * @param int $id * @return Response */ public function update($id) { $category = Category::findOrFail($id); $validator = Validator::make($data = Input::all(), Category::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $category->update($data); return Redirect::route('categories.index'); }
/** * Delete Category, related Albums & Images * * @param int $categoryId * * @return \Illuminate\View\View | \Illuminate\Http\RedirectResponse */ public function delete($categoryId) { $category = Category::findOrFail($categoryId); if (Request::isMethod('GET')) { return View::make('category.delete', compact('category')); } elseif (Request::isMethod('POST')) { $category->delete(); return Redirect::to('/categories')->with('success', 'Category deleted'); } }
public function tree(Request $request) { $parent_id = $request->input('parent_id', 0); $query = $this->resources; if ($parent_id) { $parent = Category::findOrFail($parent_id); $query->where('parents', 'LIKE', "{$parent->parents}/{$parent_id}/%"); } $categories = $query->get(); return make_tree($categories); }
/** * Delete Album & related Images * * @param int $categoryId * @param int $albumId * * @return \Illuminate\View\View | \Illuminate\Http\RedirectResponse */ public function delete($categoryId, $albumId) { $category = Category::findOrFail($categoryId); $album = Album::findOrFail($albumId); if (Request::isMethod('GET')) { return View::make('album.delete', compact('category', 'album')); } elseif (Request::isMethod('POST')) { $album->delete(); return Redirect::to('/categories/' . $categoryId . '/albums')->with('success', 'Album deleted'); } }
/** * Update the specified category in storage. * * @param int $id * @return Response */ public function update($id) { $category = Category::findOrFail($id); $rules = array('name' => 'required'); $validator = Validator::make($data = Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $category->update($data); return Redirect::route('admin.categories.index')->with('message', 'Item had updated!'); }
public function putEdit() { $id = Input::get('id'); $rules = ['name' => 'required', 'slug' => 'required']; $messages = ['name.required' => Config::get('site.validate.name.required'), 'slug.required' => Config::get('site.validate.slug.required')]; $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::to('/admin/cat/edit/' . $id)->withErrors($validator); } $category = Category::findOrFail($id); $category->name = Input::get('name'); $category->slug = Str::slug(Input::get('slug'), '-'); $category->save(); Cache::flush(); return Redirect::to('/admin/cat'); }
public function post_categoriesedit($id) { //Get our fields $name = Input::get('categoryName'); $parent = Input::get('categoryParent'); $validator = Validator::make(array('id' => $id, 'name' => $name, 'parent' => $parent), array('id' => 'required|integer', 'name' => 'required', 'parent' => 'integer'), array('id.required' => 'The category ID was not included with the request. This is an internal error. ', 'id.integer' => 'Invalid category ID format. This is an internal error.', 'name.required' => 'You forgot to enter a name. Please enter a name and try again.')); if ($validator->fails()) { // The given data did not pass validation $messages = $validator->messages(); $errorStr = ''; $count = count($messages); $i = 0; foreach ($messages->all(':message') as $message) { $i++; $errorStr .= '<span>' . $message . '</span>'; if ($i != $count) { $errorStr .= '<br /><hr />'; } } return Redirect::to('console/categories/edit/' . $id)->with('message', $errorStr); } //Great all of our validation is done. Hey, not so fast. Let's make sure that we are in fact modifying a valid category and the parent exists //Pull the category $category = Category::findOrFail($id); if ($parent != 0) { $check = Category::where('id', '=', $parent)->where('parentid', '=', '0')->firstOrFail(); } $category->name = $name; $category->parentid = $parent; if (Input::get('categoryHidden') == 1) { $category->hidden = 1; } else { $category->hidden = 0; } $category->save(); //Great, all done. Now to redirect the user. return Redirect::route('consolecategories')->with('message', 'Category successfully updated.'); }
/** * @param $id * @return mixed */ public function find($id) { return $this->category->findOrFail($id); }
public function edit($id) { $category = Category::findOrFail($id); return View::make('categories.edit')->with('category', $category)->with('title', "Edit category"); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { if (Session::get('user_level') < Config::get('cms.deleteCategory')) { return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning'); } try { $category = Category::findOrFail($id); $category->delete(); $category->newsCategories()->delete(); return Redirect::to(_l(URL::action('CategoryController@getIndex')))->with('message', Lang::get('admin.categoryDeleted'))->with('notif', 'success'); } catch (Exception $e) { return Redirect::to(_l(URL::action('CategoryController@getIndex')))->with('message', Lang::get('admin.noSuchCategory'))->with('notif', 'danger'); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $category = $this->category->findOrFail($id); return View::make('categories.show', compact('category')); }
public function post_getvasbycategory() { $id = Input::get('data'); $category = Category::findOrFail($id); $vas = User::where('categories', 'like', '%' . $id . ',%')->where('status', '=', '1')->orderBy('vaname', 'ASC')->get(); if (count($vas) == 0) { echo '<h4>No Virtual Airlines Found.</h4>'; } else { $maxwidth = Setting::fetch('banner_maxwidth'); $output = ''; foreach ($vas as $va) { //There is the potential that another number is before the category id and it got put in with this so let's double check this is just for this category $categories = explode(',', $va->categories); array_pop($categories); if (!in_array($id, $categories)) { continue; } $va->description = html_entity_decode($va->description); $va->vaname = html_entity_decode($va->vaname); $va->url = html_entity_decode($va->url); $banner_directory = $banner_directory = rtrim(Setting::fetch('banner_directory'), '/') . '/'; $banner = ''; if ($va->banner) { $banner = User::getBannerUrl($va->cid, $banner_directory); $output .= '<div class="bannerbg"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><img style="max-width:' . $maxwidth . ';" class="img-polaroid" src="' . $banner . '" alt="Banner" /></a></div><div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>'; } else { $output .= '<div class="well"><a target="_blank" href="' . URL::to('/click') . '/' . $va->cid . '"><h4>' . $va->vaname . '</h4></a><blockquote style="margin-top: 4px;">' . $va->description . '</blockquote></div>'; } } echo $output; } }
View::composer('view_user_profile', function ($view) { $id = $view->getData()["id"]; $data["user"] = User::findOrFail($id); $data["posts"] = $data["user"]->posts()->get(); $data["comments"] = $data["user"]->comments()->get(); $view->with('data', $data); }); View::composer('article_edit', function ($view) { $id = $view->getData()["data"]["id"]; if (isset($view->getData()["data"]["message"])) { $data["message"] = $view->getData()["data"]["message"]; } $data["post"] = Post::findOrFail($id); $view->with('data', $data); }); View::composer('category_view', function ($view) { $id = $view->getData()["id"]; $data["category"] = Category::findOrFail($id); $data["posts"] = $data["category"]->post()->paginate(5); $view->with('data', $data); }); View::composer('admin_page', function ($view) { $data["posts"] = Post::orderBy('id', 'DESC')->get()->take(10); $data["unmoderated"] = Post::where('moderated', '=', false)->orderBY('id', 'DESC')->get()->take(10); $data["comments"] = Comment::orderBy('id', 'DESC')->get()->take(10); $view->with('data', $data); }); View::composer('manage_users', function ($view) { $data["users"] = User::orderBy('id', 'DESC')->paginate(5); $view->with('data', $data); });
/** * Update the specified category in storage. * * @param int $id * @return Response */ public function update($id) { $category = Category::findOrFail($id); $validator = Validator::make($data = Input::all(), Category::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } if ($category->update($data)) { //Show message $alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Atualizado!']; Session::flash('alerts', $alert); } return Redirect::to(URL::previous()); }
public static function kategori($id) { $cat = Category::findOrFail($id); return $cat->nama; }
public function category($id) { $materies = Materi::where(['category_id' => $id])->paginate(10); $category = Category::findOrFail($id); return View::make('home.category', compact('materies', 'category')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { return View::make('category.show')->withCategory(DB::table('categories')->select(DB::raw('count(project) as count, name, id'))->where('id', '=', $id)->join('project_categories', 'project_categories.category', '=', 'categories.id')->first())->withProjects(Category::findOrFail($id)->projects->sortBy(function ($project) { return strtolower($project->name); })); }