當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tag::findOrFail方法代碼示例

本文整理匯總了PHP中app\Tag::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::findOrFail方法的具體用法?PHP Tag::findOrFail怎麽用?PHP Tag::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Tag的用法示例。


在下文中一共展示了Tag::findOrFail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: destroy

 public function destroy($id, EditTag $request)
 {
     $tag = Tag::findOrFail($id);
     $tag->delete();
     \Session::flash('flash_message', 'Tag został usunięty!');
     return redirect('/admin/tags');
 }
開發者ID:Zlyy,項目名稱:adceg,代碼行數:7,代碼來源:TagsController.php

示例2: 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)
 {
     $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);
 }
開發者ID:no-global-state,項目名稱:Mabbit,代碼行數:14,代碼來源:Tag.php

示例3: update

 /**
  * 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();
 }
開發者ID:jentleyow,項目名稱:pcf,代碼行數:14,代碼來源:TagsController.php

示例4: update

 /**
  * 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');
 }
開發者ID:tianyirenjian,項目名稱:laravel-blog,代碼行數:14,代碼來源:TagController.php

示例5: update

 /**
  * 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');
 }
開發者ID:abhatia2107,項目名稱:cat,代碼行數:13,代碼來源:TagController.php

示例6: destroy

 public function destroy($id)
 {
     //
     $tag = Tag::findOrFail($id);
     $tag->delete();
     return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
 }
開發者ID:edom-huang,項目名稱:personalBlog,代碼行數:7,代碼來源:TagController.php

示例7: showProductByTag

 /**
  * 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'));
 }
開發者ID:yinilauriot,項目名稱:StarWars,代碼行數:13,代碼來源:FrontController.php

示例8: destroy

 /**
  * 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;
 }
開發者ID:nickdunn2,項目名稱:bocket,代碼行數:13,代碼來源:TagsController.php

示例9: update

 public function update(Request $request, $id)
 {
     $tag = Tag::findOrFail($id);
     $tag->name = $request->name;
     $tag->slug = $request->slug;
     $tag->save();
 }
開發者ID:BobbyHoltzner,項目名稱:BH2016,代碼行數:7,代碼來源:TagController.php

示例10: destroy

 /**
  * 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('/');
 }
開發者ID:xiaoterry,項目名稱:blog,代碼行數:13,代碼來源:TagController.php

示例11: 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

示例12: tag

 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'));
 }
開發者ID:hushibing,項目名稱:laravel51,代碼行數:7,代碼來源:HomeController.php

示例13: index

 /**
  * 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'));
 }
開發者ID:mwasa,項目名稱:l5essential,代碼行數:15,代碼來源:ArticlesController.php

示例14: articlesbytag

 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'));
 }
開發者ID:ramigit3D,項目名稱:article,代碼行數:8,代碼來源:HomeController.php

示例15: tag

 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");
 }
開發者ID:Cih2001,項目名稱:hamidreza,代碼行數:9,代碼來源:ArticlesController.php


注:本文中的app\Tag::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。