本文整理汇总了PHP中app\models\Tag::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::findOrFail方法的具体用法?PHP Tag::findOrFail怎么用?PHP Tag::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Tag
的用法示例。
在下文中一共展示了Tag::findOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: problems
/**
* Display a listing of the resource with its problems connected;
*
* @return \Illuminate\Http\Response
*/
public function problems($id)
{
$tag = Tag::findOrFail($id);
$tags = TagService::getTagWithProblem($tag->id);
$title = '문제 목록 - ' . $tag->name . ' - ' . $tags->currentPage() . ' 페이지';
$resultAccCode = Result::acceptCode;
return view('tags.problems', compact('tag', 'tags', 'title', 'resultAccCode'));
}
示例2: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
Route::bind('article', function ($slug) {
if (!Auth::user()) {
return Article::published()->slug($slug)->first();
}
return Article::where('slug', $slug)->first() ?: Article::findOrFail((int) $slug);
});
Route::bind('tag', function ($slug) {
if (!Auth::user()) {
return Tag::slug($slug)->first();
}
return Tag::where('slug', $slug)->first() ?: Tag::findOrFail((int) $slug);
});
Route::bind('page', function ($id) {
return Page::find($id);
});
}
示例3: getTagById
/**
* Get tag name by id.
*
* @param int $tag_id
* @return string
*/
public function getTagById($tag_id)
{
return $this->tag->findOrFail($tag_id)->tag;
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$tag = Tag::findOrFail($id);
$tag->delete();
return redirect('/admin/tag')->withSuccess("The '{$tag->tag}' tag has been deleted.");
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$data = Tag::findOrFail($id);
return view('admin.tag.edit', ['data' => $data]);
}
示例6: getById
public function getById($id)
{
$tag = Tag::findOrFail($id);
return $tag;
}
示例7: getTagWithProblem
/**
* 해당 태그를 가지고 있는 문제 목록을 카운트 순으로 가져오기
*
* @param int $tag_id
* @return paginate of Tag with problem
*/
public function getTagWithProblem($tag_id)
{
if (Tag::findOrFail($tag_id)->status != Tag::openCode) {
return abort(404);
}
return $this->service->getTagWithProblem($tag_id);
}