本文整理汇总了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');
}
示例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);
}
示例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();
}
示例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');
}
示例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');
}
示例6: destroy
public function destroy($id)
{
//
$tag = Tag::findOrFail($id);
$tag->delete();
return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
}
示例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'));
}
示例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;
}
示例9: update
public function update(Request $request, $id)
{
$tag = Tag::findOrFail($id);
$tag->name = $request->name;
$tag->slug = $request->slug;
$tag->save();
}
示例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('/');
}
示例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);
}
示例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'));
}
示例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'));
}
示例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'));
}
示例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");
}