当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::find方法代码示例

本文整理汇总了PHP中app\Tag::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::find方法的具体用法?PHP Tag::find怎么用?PHP Tag::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Tag的用法示例。


在下文中一共展示了Tag::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showPostTag

 /**
  *  @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'));
 }
开发者ID:AndryRana,项目名称:ConfPHP,代码行数:11,代码来源:ConfPhpController.php

示例2: destroy

 /**
  * 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;
 }
开发者ID:fasteddiegarcia,项目名称:bocket,代码行数:13,代码来源:TagsController.php

示例3: addTags

 public function addTags($event, $maxTags = 5)
 {
     for ($i = 1; $i <= $maxTags; $i++) {
         $tag = \App\Tag::find($i);
         $event->tag()->attach($tag);
     }
 }
开发者ID:jonbrobinson,项目名称:aaulyp,代码行数:7,代码来源:EventTableSeeder.php

示例4: destroy

 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');
 }
开发者ID:kyrayagami,项目名称:proyecto,代码行数:7,代码来源:TagsController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $t = \App\Tag::find($id);
     if ($t) {
         return ['mensagens' => $t->mensagens->toArray()];
     }
 }
开发者ID:edsonmichaque,项目名称:grafite-ng,代码行数:12,代码来源:MensagemDeTagController.php

示例6: testTagPostRelationship

 /**
  * 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);
 }
开发者ID:joaumg-deprecated,项目名称:joaumg_com,代码行数:12,代码来源:RelationshipsTest.php

示例7: getEdit

 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'));
 }
开发者ID:excitedcat,项目名称:bookmarks,代码行数:8,代码来源:SiteController.php

示例8: update

 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');
 }
开发者ID:gratereaux,项目名称:practicing-laravel,代码行数:8,代码来源:TagsController.php

示例9: getDestroy

 public static function getDestroy($id)
 {
     if (Tag::find($id)->sites->count() == 0) {
         if (Tag::destroy($id)) {
             return true;
         }
     }
     return false;
 }
开发者ID:excitedcat,项目名称:bookmarks,代码行数:9,代码来源:TagController.php

示例10: show

 /**
  * 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);
 }
开发者ID:sergipineda,项目名称:tasksAPI,代码行数:15,代码来源:TagController.php

示例11: edit

 /**
  * 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('数据未找到');
     }
 }
开发者ID:abcsun,项目名称:ForoneAdminDemo,代码行数:15,代码来源:TagController.php

示例12: destroy

 /**
  * 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);
     }
 }
开发者ID:jmickler,项目名称:bocket,代码行数:16,代码来源:TagController.php

示例13: update

 /**
  * 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);
 }
开发者ID:pdavila13,项目名称:tasksAPI2,代码行数:17,代码来源:TagController.php

示例14: index

 /**
  * 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]);
 }
开发者ID:Carderon,项目名称:intendant,代码行数:18,代码来源:IngredientController.php

示例15: delete

 /**
  *  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'));
 }
开发者ID:zettlr,项目名称:zettlr,代码行数:20,代码来源:TagController.php


注:本文中的app\Tag::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。