コード例 #1
0
 /**
  *  @return a post
  * @param $id
  */
 public function showPostTag($id)
 {
     $tag = Tag::find($id);
     $posts = $tag->posts()->orderBy('date_start', 'DESC')->where('status', 'publish')->get();
     $name = $tag->name;
     return view('front.tag', compact('posts', 'name'));
 }
コード例 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $tag = \App\Tag::find($id);
     $tag->delete();
     return $tag;
 }
コード例 #3
0
 public function addTags($event, $maxTags = 5)
 {
     for ($i = 1; $i <= $maxTags; $i++) {
         $tag = \App\Tag::find($i);
         $event->tag()->attach($tag);
     }
 }
コード例 #4
0
 public function destroy($id)
 {
     $tag = Tag::find($id);
     $tag->delete();
     Flash::success('Se elimino el Tag : ' . $tag->nombre . ' satisfactoriamente!!');
     return redirect()->route('admin.tags.index');
 }
コード例 #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $t = \App\Tag::find($id);
     if ($t) {
         return ['mensagens' => $t->mensagens->toArray()];
     }
 }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
 public function getEdit($id)
 {
     $site = Site::find($id);
     $site->labels = explode(',', $site->keywords);
     $tag = Tag::find($site->tag_id);
     $tags = Tag::where('user_id', '=', Auth::id())->get();
     return view('site.edit', compact('site', 'tag', 'tags'));
 }
コード例 #8
0
 public function update(TagRequest $request, $id)
 {
     $tag = Tag::find($id);
     $tag->name = $request->name;
     $tag->save();
     Flash::warning("El Tag ha sido editado de manera exitosa!");
     return redirect()->route('admin.tags.index');
 }
コード例 #9
0
 public static function getDestroy($id)
 {
     if (Tag::find($id)->sites->count() == 0) {
         if (Tag::destroy($id)) {
             return true;
         }
     }
     return false;
 }
コード例 #10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $tag = Tag::find($id);
     // $task = Task::where('id',$id)->first();
     if (!$tag) {
         return Response::json(['error' => ['message' => 'La tag no existeix', 'code']], 404);
     }
     return Response::json([$this->tagTransfomer->transform($tag)], 200);
 }
コード例 #11
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data = Tag::find($id);
     if ($data) {
         return view(self::URI . "/edit", compact('data'));
     } else {
         return $this->redirectWithError('数据未找到');
     }
 }
コード例 #12
0
ファイル: TagController.php プロジェクト: jmickler/bocket
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = \App\Tag::find($id);
     if ($tag->user_id == Auth::user()->id) {
         $tag->delete();
         return $tag;
     } else {
         return response("Unauthorized", 403);
     }
 }
コード例 #13
0
ファイル: TagController.php プロジェクト: pdavila13/tasksAPI2
 /**
  * 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);
     $tag = Tag::find($id);
     if (!$tag) {
         return Response::json(['error' => ['message' => 'Task does not exist', 'code' => 195]], 404);
     }
     return Response::json(['data' => $tag->toArray()], 200);
     $this->saveTag($request, $tag);
 }
コード例 #14
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($tag_id = null)
 {
     if ($tag_id) {
         $ingredients = Ingredient::whereHas('tags', function ($query) use($tag_id) {
             $query->where('id', $tag_id);
         })->get();
     } else {
         $ingredients = Ingredient::all();
     }
     $tags = Tag::where('for', 'ingredient')->get();
     $tag = Tag::find($tag_id);
     return view('ingredients.index')->with(['ingredients' => $ingredients, 'tags' => $tags, 'the_tag' => $tag]);
 }
コード例 #15
0
ファイル: TagController.php プロジェクト: zettlr/zettlr
 /**
  *  Removes a tag from the database
  *
  *  @param   integer  $id  Tag id
  *
  *  @return  Response
  */
 public function delete($id)
 {
     if (!$id || $id <= 0) {
         return redirect(url('/tags/index'))->withErrors(['message' => 'No such tag']);
     }
     $tag = Tag::find($id);
     // First remove all relations to other models
     $tag->notes()->detach();
     $tag->outlines()->detach();
     // Second delete
     $tag->delete();
     return redirect(url('/tags/index'));
 }
コード例 #16
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($tag_id = null)
 {
     if ($tag_id) {
         $recipes = Recipe::whereHas('tags', function ($query) use($tag_id) {
             $query->where('id', $tag_id);
         })->get();
     } else {
         $recipes = Recipe::all();
     }
     $tags = Tag::where('for', 'recipe')->get();
     $tag = Tag::find($tag_id);
     return view('recipes.index')->with(['recipes' => $recipes, 'tags' => $tags, 'the_tag' => $tag]);
 }
コード例 #17
0
 public function save(Request $request)
 {
     $tag = null;
     if ($request->id) {
         //edit
         $tag = Tag::find($request->id);
     } else {
         //new
         $tag = new Tag();
     }
     $tag->title = $request->title;
     $tag->save();
     return $tag;
 }
コード例 #18
0
ファイル: TagController.php プロジェクト: nahid1991/LoginTest
 public function getDelete($tag)
 {
     //echo($tag);
     $tag = Tag::find($tag);
     //        $newTags = DB::table('tags')->where('name', $tag)->first();
     ////        echo($newTags);
     //        $oneMore = DB::table('tags')
     //            ->join('tag_faculty', 'tags.id', '=', $newTags)
     //            ->first();
     //        $user = \Auth::user();
     //
     //
     if (!$tag) {
         echo $tag;
     } else {
         $tag->delete();
         return redirect('/dash-board');
     }
 }
コード例 #19
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $tag = Tag::find($id);
     if (empty($tag)) {
         abort(404);
     }
     if ($request->user()->cannot('delete-tag', $tag)) {
         abort(403);
     }
     if ($request->has('force_delete')) {
         $tag->forceDelete();
     } elseif ($request->has('restore')) {
         $tag->restore();
     } else {
         $tag->delete();
     }
 }
コード例 #20
0
 public function showTag($id)
 {
     $tag = Tag::find($id);
     return view('tag.single', compact('tag'));
 }
コード例 #21
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $post_all = Post::latest()->published()->paginate(5);
     //get one to many
     $post = Post::find(11);
     if ($post) {
         $comments = $post->comments()->get();
     }
     //$comments->posts()->where('active', 1)->get();
     //$comments = Post::find(11)->comments()->where('title', 'foo')->first();
     //inverse
     $comment = Comment::find(1);
     if ($comment) {
         $post_found = $comment->post->title;
     }
     //many to many
     $user = User::find(32);
     if ($user) {
         $roles = $user->roles;
     }
     //$roles2 = User::find(11)->roles()->orderBy('role')->get();
     //Has Many Through
     $country = Country::find(1);
     $post_by_country = $country->posts;
     //Polymorphic
     //foreach ($post->likes as $like) {}
     //inverse
     $like = Like::find(1);
     if ($like) {
         $likeable = $like->likeable;
     }
     //Many To Many Polymorphic
     //$post = App\Post::find(1);
     //foreach ($post->tags as $tag) {}
     //inverse
     $tag = Tag::find(1);
     //Querying Relationship Existence
     // Retrieve all posts that have at least one comment...
     //$posts = Post::has('comments')->get();
     // Retrieve all posts that have three or more comments...
     $posts = Post::has('comments', '>=', 3)->get();
     // Retrieve all posts that have at least one comment with votes...
     //$posts = Post::has('comments.votes')->get();
     // Retrieve all posts with at least one comment containing words like foo%
     // $posts = Post::whereHas('comments', function ($query) {//orWhereHas
     //     $query->where('content', 'like', 'foo%');
     // })->get();
     //Eager loading
     $post2 = Post::with('user')->get();
     //Eager Loading Multiple Relationships
     //Sometimes you may need to eager load several different relationships in a single operation. To do so, just pass additional arguments to the with method:
     //$books = Post::with('user', 'publisher')->get();
     //Nested Eager Loading
     //To eager load nested relationships, you may use "dot" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts in one Eloquent statement:
     //$books = App\Book::with('author.contacts')->get();
     //Constraining Eager Loads
     //Sometimes you may wish to eager load a relationship, but also specify additional query constraints for the eager loading query. Here's an example:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->where('title', 'like', '%first%');
     // }])->get();
     //In this example, Eloquent will only eager load posts that if the post's title column contains the word first. Of course, you may call other query builder to further customize the eager loading operation:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->orderBy('created_at', 'desc');
     // }])->get();
     //Lazy Eager Loading
     //Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:
     //$books = App\Book::all();
     // if ($someCondition) {
     //     $books->load('author', 'publisher');
     // }
     //If you need to set additional query constraints on the eager loading query, you may pass a Closure to the load method:
     // $books->load(['author' => function ($query) {
     //     $query->orderBy('published_date', 'asc');
     // }]);
     return view('posts.index', compact('post', 'comments', 'post_found', 'user', 'roles', 'roles2', 'country', 'post_by_country', 'likeable', 'tag', 'post2', 'post_all'));
 }
コード例 #22
0
ファイル: TagController.php プロジェクト: Kaelcao/colormev2
 public function delete_tag($id)
 {
     Tag::find($id)->delete();
     return redirect('manage/producttags');
 }
コード例 #23
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $tag = Tag::find($id);
     $tag->delete();
     Flash::error('El tag ' . $tag->name . ' ha sido eliminado correctamente.');
     return redirect()->route('admin.tags.index');
 }
コード例 #24
0
 /**
  * Display a listing of the posts with a specific tag.
  *
  * @return \Illuminate\Http\Response
  */
 public function getAllWithTag($id)
 {
     return view('cms.posts', ['posts' => $this->postRepo->getAllWithTag($id), 'blurb' => 'With Tag: ' . Tag::find($id)['name']]);
 }
コード例 #25
0
 public function showProductByTags(Request $request, $id, $tag = '')
 {
     $products = Tag::find($id)->products()->with('category', 'picture')->paginate(5);
     $lastPage = $products->lastPage();
     if ($request->ajax()) {
         $resultat = array();
         $resultat[0] = json_encode($lastPage);
         $resultat[1] = json_encode(View::make('front.partials.product', compact('products'))->render());
         return $resultat;
     }
     return view('front.index', compact('products'));
 }
コード例 #26
0
 public function getAllWithTag($id, $sort = "desc")
 {
     $taggedPosts = Tag::find($id)->posts->lists('id')->toArray();
     $posts = $this->_postsRelationships()->whereIn('id', $taggedPosts)->orderBy('id', $sort)->paginate(20);
     return $posts;
 }
コード例 #27
0
 public function delete(Request $r)
 {
     $type = $r->input('type');
     $id = $r->input('id');
     if ($type == 'categories') {
         $index = Category::find($id);
         $pa = $index->parent;
         $children = Category::where('parent', $id)->get();
         foreach ($children as $child) {
             $child->parent = $pa;
             $child->save();
         }
         $index->delete();
         return redirect('admin');
     } else {
         if ($type == 'researches') {
             $index = Content::find($id)->research;
             $index->delete();
             $index = Content::find($id);
             $index->delete();
             return redirect('admin');
         } else {
             if ($type == 'events') {
                 $index = Content::find($id)->event;
                 $index->delete();
                 $index = Content::find($id);
                 $index->delete();
                 return redirect('admin');
             } else {
                 if ($type == 'members') {
                     $index = Member::find($id);
                     $index->delete();
                     return redirect('admin');
                 } else {
                     if ($type == 'tags') {
                         $index = Tag::find($id);
                         $index->delete();
                     } else {
                         $index = Content::find($id);
                         $index->delete();
                     }
                 }
             }
         }
     }
     return redirect('admin');
 }
コード例 #28
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Tag::find($id)->delete();
     return redirect('admin/tags');
 }
コード例 #29
0
 public function showProductByTag(Request $request, $tag_id, $name = '', $byType = 'bydate')
 {
     if ($request->order) {
         $order = $request->order;
     } else {
         $order = 'desc';
     }
     if ($byType == 'bydate') {
         $tag = Tag::find($tag_id);
         $products = $tag->products()->with('tags', 'category', 'picture')->online()->orderBy('published_at', $order)->paginate(5);
         return view('front.tag', compact('products', 'tag', 'order'));
     } else {
         if ($byType == 'byname') {
             $tag = Tag::find($tag_id);
             $products = $tag->products()->with('tags', 'category', 'picture')->online()->orderBy('name', $order)->paginate(5);
             return view('front.tag', compact('products', 'tag', 'order'));
         } else {
             if ($byType == 'byprice') {
                 $tag = Tag::find($tag_id);
                 $products = $tag->products()->with('tags', 'category', 'picture')->online()->orderBy('price', $order)->paginate(5);
                 return view('front.tag', compact('products', 'tag', 'order'));
             } else {
                 if ($byType == 'byscore') {
                     $tag = Tag::find($tag_id);
                     $products = $tag->products()->with('tags', 'category', 'picture')->online()->orderBy('score', $order)->paginate(5);
                     return view('front.tag', compact('products', 'tag', 'order'));
                 }
             }
         }
     }
 }
コード例 #30
0
 /**
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  *
  * SHOW PRODUCTS BY TAGS
  */
 public function showProductByTag($id)
 {
     $products = Tag::find($id)->products->where('status', 1);
     return view('front.tags.index', compact('products'));
 }