Example #1
0
 public function destroy($id, EditTag $request)
 {
     $tag = Tag::findOrFail($id);
     $tag->delete();
     \Session::flash('flash_message', 'Tag został usunięty!');
     return redirect('/admin/tags');
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|min:2']);
     TagModel::findOrFail($id)->update($request->all());
     \Session::flash('status', 'The tag has been updated successfully');
     return redirect()->action('Tag@edit', $id);
 }
Example #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(TagRequest $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $tag->update($request->all());
     flash('Tag has been updated');
     return Redirect::back();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\TagRequest $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $input = $request->all();
     $tag->update($input);
     return redirect()->action('Goenitz\\TagController@index');
 }
Example #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
     $tag = Tag::findOrFail($id);
     $tag->update($request->all());
     return redirect('tag');
 }
 public function destroy($id)
 {
     //
     $tag = Tag::findOrFail($id);
     $tag->delete();
     return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
 }
Example #7
0
 /**
  * Display a listing of products by each tag
  *
  * @param $id
  * @param string $slug
  */
 public function showProductByTag($id, $slug = '')
 {
     $tag = Tag::findOrFail($id);
     $products = $tag->products()->with('category', 'picture')->paginate($this->paginate);
     $title = "Tag {$tag->name}";
     return view('front.tag', compact('products', 'tag', 'title'));
 }
Example #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $this->authorize('update-destroy', $tag);
     $tag->delete();
     return $tag;
 }
Example #9
0
 public function update(Request $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $tag->name = $request->name;
     $tag->slug = $request->slug;
     $tag->save();
 }
Example #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $tag->articles()->detach();
     $tag->delete();
     return redirect('/');
 }
 /**
  * Test Tag -> Post relationship
  *
  * @return void
  */
 public function testTagPostRelationship()
 {
     $this->assertTrue(Tag::findOrFail(1) instanceof Tag);
     $relationshipCollection = Tag::find(1)->posts()->get();
     $collection = collect([]);
     $this->assertTrue($relationshipCollection instanceof $collection);
 }
Example #12
0
 public function tag($id)
 {
     $categories = $this->categories();
     $articles = Tag::findOrFail($id)->articles()->orderBy('id', 'desc')->paginate(10);
     $tag = Tag::findOrFail($id);
     return view('home.tag', compact('categories', 'tag', 'articles'));
 }
Example #13
0
 /**
  * Display a listing of the resource.
  *
  * @param \App\Http\Requests\FilterArticlesRequest $request
  * @param int|null                                 $id
  * @return \Illuminate\Http\Response
  */
 public function index(FilterArticlesRequest $request, $id = null)
 {
     $query = $id ? Tag::findOrFail($id)->articles() : new Article();
     // If you are relying on 'file' or 'database' cache, cacheTags() methods is not available
     $query = taggable() ? $query->with('comments', 'author', 'tags', 'attachments')->remember(5)->cacheTags('articles') : $query->with('comments', 'author', 'tags', 'solution', 'attachments')->remember(5);
     $articles = $this->filter($request, $query)->paginate(10);
     return view('articles.index', compact('articles'));
 }
Example #14
0
 public function articlesbytag($id)
 {
     $choosenLang = \Session::get('locale');
     $tags = Tag::where('lang', '=', $choosenLang)->get();
     $tag = Tag::findOrFail($id);
     $articles = $tag->articles()->paginate(2);
     return view('index', compact('articles', 'tags'));
 }
Example #15
0
 public function tag($tagid)
 {
     $tag = Tag::findOrFail($tagid);
     if (!$tag->articles->isEmpty()) {
         $articles = $tag->articles;
         return view('pages.articles.articles', compact('articles'));
     }
     return Redirect::to("/articles");
 }
Example #16
0
 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     if ($id = $request->get('tag')) {
         $tag = Tag::findOrFail($id);
         return $tag->posts()->with('tags')->get();
     } else {
         return Post::with('tags')->latest()->take(5)->get();
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $game = Game::findOrFail($id);
     $query = $game->tags;
     $tag = Tag::findOrFail($query);
     $thread = DB::table('thread')->where('game', $id)->get();
     $posts = DB::table('posts')->where('thread_id', $id)->get();
     return view('games.game', compact('game', 'tag', 'posts'));
 }
Example #18
0
 public function actionUpdate($id, Requests\UpdateTagRequest $request)
 {
     // Find tag in database.
     $tag = Tag::findOrFail($id);
     // Update tag in database.
     $tag->update($request->all());
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully updated a tag.');
     return redirect('/tags/' . $tag->id);
 }
 public function showProductByTag($id, $slug = '')
 {
     try {
         $tag = Tag::findOrFail($id);
         $products = $tag->products()->paginate(10);
     } catch (\Exception $e) {
         return view('front.no_tag');
     }
     $title = "{$tag->name}";
     return view('front.showProductByTag', compact('products', 'title'));
 }
Example #20
0
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $articles = Article::all();
     foreach ($articles as $article) {
         $article_ids[] = $article->id;
     }
     //删除与文章关联的tag
     $tag->articles()->detach($article_ids);
     if ($tag->delete()) {
         return redirect('admin/tags')->with('message', '删除成功!');
     } else {
         return back()->withInput()->with('errors', '保存失败!');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(TagRequest $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $attributes = $request->all();
     if ($tag->slug != str_slug($request->input('name'))) {
         $slug = $this->getSlug($request->input('name'), false);
         if ($slug == false) {
             flash()->error('You need a different name!');
             return redirect('admin/tags/' . $id . '/edit');
         }
         $attributes['slug'] = $slug;
     }
     $tag->update($attributes);
     return redirect('admin/tags');
 }
Example #22
0
 public function postSearch(Request $request)
 {
     $keywords = \Request::input('keywords');
     $tag = Tag::findOrFail($request->tag);
     $courses = $tag->courses()->published()->done()->latest('published_at')->get();
     $searchCourses = new \Illuminate\Database\Eloquent\Collection();
     if ($keywords == null) {
         return view::make('courses.searchedCourses')->with('searchCourses', $courses);
     }
     foreach ($courses as $course) {
         if (Str_contains(Strtolower($course->title), Strtolower($keywords))) {
             $searchCourses->add($course);
         }
     }
     return View::make('courses.searchedCourses')->with('searchCourses', $searchCourses);
 }
Example #23
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $tag->instrumentos()->detach();
     $tag->delete();
     Session::flash("message", "Se han eliminado los datos!");
     return redirect()->route('tags.index');
 }
Example #24
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(UpdateTagRequest $request, $id)
 {
     $data = $request->only(['name']);
     Tag::findOrFail($id)->update($data);
     return redirect()->route('admin.' . self::URI . '.index');
 }
Example #25
0
 public function showTag($tagId)
 {
     $tag = Tag::findOrFail($tagId);
     return view('tag.tag', ['tag' => $tag]);
 }
Example #26
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::findOrFail($id);
     $tag->delete();
     return redirect("/admin/tag")->withSuccess("El '{$tag->tag}' ha sido borrado.'");
 }
Example #27
0
 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  *
  * @return Response
  */
 public function update(TagRequest $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $tag->update($request->all());
     return redirect('admin/tags/index');
 }
Example #28
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     //
     $tag = Tag::findOrFail($id);
     $this->saveTag($request, $tag);
 }
 public function scrollProd(Request $request, $byType = 'bydate')
 {
     //        $url = $request->url;
     $url = $request->getPathInfo();
     $offset = $request->offset;
     $numberItems = $request->numberItems;
     //        return $url;
     $field = 'published_at';
     if ($request->order) {
         $order = $request->order;
     } else {
         $order = 'desc';
     }
     if (strstr($url, 'home') !== false) {
         if ($byType == 'bydate') {
             $field = 'published_at';
             //                $order = 'DESC';
         } elseif ($byType == 'byname') {
             $field = 'name';
             //                $order = 'ASC';
         } elseif ($byType == 'byprice') {
             $field = 'price';
             //                $order = 'DESC';
         } elseif ($byType == 'byscore') {
             $field = 'score';
             //                $order = 'DESC';
         }
         $products = Product::with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get();
         $number_DB_products = count(Product::all());
         //                return Response::json(View::make('front.productscroll', compact('products'))->render());
         return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]);
     } elseif (strstr($url, 'cat') !== false) {
         if ($byType == 'bydate') {
             $field = 'published_at';
             //                $order = 'DESC';
         } elseif ($byType == 'byname') {
             $field = 'name';
             //                $order = 'ASC';
         } elseif ($byType == 'byprice') {
             $field = 'price';
             //                $order = 'DESC';
         } elseif ($byType == 'byscore') {
             $field = 'score';
             //                $order = 'DESC';
         }
         preg_match('#cat/([0-9]+)#', $url, $matches);
         $category_id = $matches[1];
         $products = Category::findOrFail($category_id)->products()->with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get();
         $number_DB_products = count(Category::findOrFail($category_id)->products()->get());
         return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]);
     } elseif (strstr($url, 'tag') !== false) {
         if ($byType == 'bydate') {
             $field = 'published_at';
             //                $order = 'DESC';
         } elseif ($byType == '') {
             $field = 'name';
             //                $order = 'ASC';
         } elseif ($byType == 'byprice') {
             $field = 'price';
             //                $order = 'DESC';
         } elseif ($byType == 'byscore') {
             $field = 'score';
             //                $order = 'DESC';
         }
         preg_match('#tag/([0-9]+)#', $url, $matches);
         $tag_id = $matches[1];
         $products = Tag::findOrFail($tag_id)->products()->with('tags', 'category', 'picture')->online()->orderBy($field, $order)->skip($offset)->take($numberItems)->get();
         $number_DB_products = count(Tag::findOrFail($tag_id)->products()->get());
         return response()->json(['data' => $number_DB_products, 'html' => view('front.productscroll', compact('products'))->render()]);
     }
 }
Example #30
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required|max:255', 'category_id' => 'required|numeric']);
     $tag = Tag::findOrFail($id);
     if ($request->sort_id > 0) {
         $tag->sort_id = $request->sort_id;
     }
     $tag->category_id = $request->category_id;
     $tag->slug = str_slug($request->title);
     $tag->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
     $tag->title = $request->title;
     if ($request->status == 'on') {
         $tag->status = 1;
     } else {
         $tag->status = 0;
     }
     $tag->save();
     return redirect('admin/tags')->with('status', 'Тег обновлен!');
 }