本文整理汇总了PHP中app\Tag::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::where方法的具体用法?PHP Tag::where怎么用?PHP Tag::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Tag
的用法示例。
在下文中一共展示了Tag::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postImport
public function postImport(Request $req)
{
$color = ['red', 'pink', 'blue', 'purple', 'green', 'yellow', 'indigo', 'cyan', 'lime', 'brown', 'orange', 'gray'];
$data = [];
$status = true;
if ($req->input('tags')) {
$data = explode("\n", $req->input('tags'));
for ($i = 0; $i < count($data); $i++) {
list($cate, $name) = explode('-', $data[$i]);
$category = DB::table('categories')->where('name', $cate)->first();
$cateId = 0;
if ($category) {
$cateId = $category->id;
} else {
$cateId = DB::table('categories')->insertGetId(['name' => $cate, 'color' => $color[rand(0, count($color) - 1)]]);
}
$tag = Tag::where('name', $name)->first();
if ($tag) {
$tag->category_id = $cateId;
$tag->save();
} else {
Tag::create(['name' => $name, 'category_id' => $cateId]);
}
}
}
return ['status' => $status, 'tags' => $this->getIndex()];
}
示例2: userPhotos
public function userPhotos()
{
$tags = Tag::where('id', '>', 0)->get();
$phototags = PhotoTag::where('image_id', '>', 0)->get();
$images = Image::where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(10);
return view('user.photos')->with(['images' => $images, 'tags' => $tags, 'phototags' => $phototags]);
}
示例3: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
$router->bind('articles', function ($id) {
$article = Article::findOrFail($id);
// If the owner return all articles else return only published.
if (Auth::user() && $article->user_id === Auth::user()->id) {
$articles = Article::findOrFail($id);
} else {
$articles = Article::published()->findOrFail($id);
}
return $articles;
});
$router->bind('questions', function ($id) {
return Question::findOrFail($id);
});
$router->bind('answers', function ($id) {
return Answer::findOrFail($id);
});
$router->bind('tags', function ($name) {
return Tag::where('name', $name)->firstOrFail();
});
$router->bind('users', function ($id) {
return User::findOrFail($id);
});
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//$member = Member::find($id);
$profileUser = User::where('slug', $id)->first();
$member = Member::where('user_id', $profileUser->id)->first();
$user = Auth::user();
$isMemberProfile = false;
$isFollowing = false;
$showWelcomeMessage = false;
if (Auth::check()) {
if ($member->user_id == Auth::User()->id) {
$isMemberProfile = true;
if (!$user->welcomed) {
$showWelcomeMessage = true;
$user->welcomed = true;
$user->save();
}
}
if (Follower::where('user_id', $member->user->id)->where('follower_id', $user->id)->count()) {
$isFollowing = true;
}
}
$artists = Artist::where('verified', true)->orderBy('firstname', 'asc')->get();
$categories = Tag::where('isCategory', true)->get();
return view('pages.member', ['member' => $member, 'isMemberProfile' => $isMemberProfile, 'isFollowing' => $isFollowing, 'artists' => $artists, 'categories' => $categories, 'showWelcomeMessage' => $showWelcomeMessage]);
}
示例5: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
/*Route::model*/
/**
* Route model binding altering default logic
* $router->bind('articles',function($id){
* return \App\Article::published()->findOrFail($id);
* });
*/
/*Using wildcard*/
/*$router->model('articles','App\Article');*/
$router->bind('articles', function ($id) {
return \App\Article::published()->findOrFail($id);
});
$router->bind('rates', function ($id) {
return \App\Rate::where('id', $id)->firstOrFail();
});
$router->bind('customers', function ($id) {
return \App\Customer::where('id', $id)->firstOrFail();
});
$router->bind('tags', function ($name) {
return \App\Tag::where('name', $name)->firstOrFail();
});
$router->bind('motherboards', function ($name) {
return \App\Motherboard::where('name', $name)->firstOrFail();
});
}
示例6: tag
public function tag($name)
{
$tag = \App\Tag::where('name', '=', $name)->firstOrFail();
$tags = \App\Tag::all();
$posts = $tag->posts;
return view('frontend.pages.tag')->with('posts', $posts)->with('tags', $tags)->with('tag', $tag);
}
示例7: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
/**
* Binding the model
*/
// $router->model('articles', 'App\Article');
/**
* Optional custom bind
*/
$router->bind('articles', function ($id) {
/**
* Show only the published articles
*/
return \App\Article::published()->findOrFail($id);
});
// $router->model('tags', 'App\Tag');
$router->bind('tags', function ($name) {
/**
* Show only the related same tag by name
*/
return \App\Tag::where('name', $name)->firstOrFail();
});
}
示例8: search
public function search(Request $request)
{
$searchTerm = is_null($request->input('query')) ? "" : $request->input('query');
$city = is_null($request->input('city')) ? '' : $request->input('city');
$category = is_null($request->input('category')) ? "" : $request->input('category');
$participants = is_null($request->input('participants')) ? "" : $request->input('participants');
$min = is_null($request->input('min_budget')) ? 0 : $request->input('min_budget');
$max = is_null($request->input('max_budget')) ? 2147483647 : $request->input('max_budget');
$entries = Entry::where('title', 'LIKE', "%{$searchTerm}%")->where('city', 'LIKE', "%{$city}%")->where('address', 'LIKE', "%{$city}%")->where('categories', "LIKE", "%{$category}%")->where('participants', 'LIKE', "%{$participants}%")->where('budget', '>=', $min)->where('budget', '<=', $max)->with('days')->with('hours')->with('tags');
/*if($searchTerm != ''){
$entries = Entry::where('title','LIKE',"%$searchTerm%");
} else if($city != ''){
$entries = $entries->where('description','LIKE',"%$searchTerm%");
} else if($category != ''){
$entries = $entries->where('categories','LIKE',"%$categories%");
} else if($participants != ''){
$entries = $entries->where('participants','LIKE',"");
}*/
$entries = $entries->get();
$tags = Tag::where('description', 'LIKE', "%{$searchTerm}%")->get();
foreach ($tags as $tag) {
$entries->merge($tag->entry()->get());
}
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true ");
header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, \n X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
return $entries->toJson();
}
示例9: getEdit
/**
* Edit a bookmark
* @param Integer $id The bookmark_id of the bookmark
* @return View A view for editing the bookmark
*/
public function getEdit($id)
{
$userID = Auth::user()->id;
try {
//Find the bookmark with ID=$id
$bookmark = Bookmark::findOrFail($id);
//Now find it's tags
$tagsForBookmark = BookmarkTag::where('bookmark_id', $bookmark->bookmark_id)->get();
if (sizeof($tagsForBookmark) > 0) {
$tagNames = [];
foreach ($tagsForBookmark as $tagItem) {
$tagName = Tag::where('tag_id', $tagItem->tag_id)->get()[0]->tag_name;
$tagNames[] = $tagName;
}
$tags = $tagNames;
} else {
//Create a new PageContentParser with the bookmark's content
$contentParser = new PageContentParser($bookmark->content);
//Get 5 suggested tags
$tags = $contentParser->getTags(5);
}
$data = ['bookmark' => $bookmark, 'userID' => $userID, 'tags' => implode(",", $tags)];
return view('bookmark/edit-bookmark')->with($data);
} catch (ModelNotFoundException $e) {
return "Bookmark not found: " . $e->getMessage();
}
}
示例10: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
$router->bind('tags', function ($name) {
return \App\Tag::where('name', $name)->firstOrFail();
});
}
示例11: 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'));
}
示例12: gettag
public function gettag(Request $request)
{
if (Auth::check()) {
$tag = Tag::where('id', $request->input('id'))->get()->first();
$articles = $tag->articles()->where('article_uid', Auth::id())->orderBy('updated_at', 'desc')->simplePaginate(20);
return view('tag', ['articles' => $articles, 'tag' => $tag]);
}
}
示例13: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($slug)
{
$tag = Tag::where('slug', $slug)->firstOrFail();
$posts = Post::with('tags')->whereHas('tags', function ($q) use($tag) {
$q->where('tag_id', $tag->id);
})->orderBy('created_at', 'desc')->paginate(15);
return view('tags.show', compact('tag', 'posts'));
}
示例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: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
$tag = Tag::where('slug', $slug)->first();
$articles = $tag->articles()->get();
$tags = Tag::all();
$categories = Category::all();
return view('articles.tags.show', compact('articles', 'categories', 'tags'));
}