当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::where方法代码示例

本文整理汇总了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()];
 }
开发者ID:newset,项目名称:wx,代码行数:27,代码来源:Tags.php

示例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]);
 }
开发者ID:Night0nly,项目名称:ImageSharingWeb,代码行数:7,代码来源:ImageController.php

示例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);
     });
 }
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:33,代码来源:RouteServiceProvider.php

示例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]);
 }
开发者ID:axovel,项目名称:tattoo,代码行数:32,代码来源:MemberController.php

示例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();
     });
 }
开发者ID:sephestrito,项目名称:learning-laravel-5,代码行数:35,代码来源:RouteServiceProvider.php

示例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);
 }
开发者ID:KirillVladimirov,项目名称:usefulcode.ru-laravel,代码行数:7,代码来源:BlogController.php

示例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();
     });
 }
开发者ID:rudbast,项目名称:laravel-tutorial,代码行数:31,代码来源:RouteServiceProvider.php

示例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();
 }
开发者ID:jmramos02,项目名称:roamio,代码行数:29,代码来源:FrontController.php

示例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();
     }
 }
开发者ID:kings0c,项目名称:bookmarquee,代码行数:32,代码来源:BookmarksController.php

示例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();
     });
 }
开发者ID:peterhan92,项目名称:laravel_project,代码行数:14,代码来源:RouteServiceProvider.php

示例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'));
 }
开发者ID:excitedcat,项目名称:bookmarks,代码行数:8,代码来源:SiteController.php

示例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]);
     }
 }
开发者ID:Byron-Z,项目名称:LaravelProject,代码行数:8,代码来源:SelfMainpageController.php

示例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'));
 }
开发者ID:joaumg-deprecated,项目名称:joaumg_com,代码行数:14,代码来源:TagsController.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: 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'));
 }
开发者ID:joandong2,项目名称:blog,代码行数:14,代码来源:TagsController.php


注:本文中的app\Tag::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。