當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。