本文整理汇总了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'));
}
示例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;
}
示例3: addTags
public function addTags($event, $maxTags = 5)
{
for ($i = 1; $i <= $maxTags; $i++) {
$tag = \App\Tag::find($i);
$event->tag()->attach($tag);
}
}
示例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');
}
示例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()];
}
}
示例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);
}
示例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'));
}
示例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');
}
示例9: getDestroy
public static function getDestroy($id)
{
if (Tag::find($id)->sites->count() == 0) {
if (Tag::destroy($id)) {
return true;
}
}
return false;
}
示例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);
}
示例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('数据未找到');
}
}
示例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);
}
}
示例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);
}
示例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]);
}
示例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'));
}