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


PHP Tag::where方法代码示例

本文整理汇总了PHP中app\models\Tag::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::where方法的具体用法?PHP Tag::where怎么用?PHP Tag::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Tag的用法示例。


在下文中一共展示了Tag::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display the home page.
  *
  * @return Response
  */
 public function index()
 {
     $url = config('medias.image-host');
     $film_url = config('medias.film-host');
     //hien thi film hot, sap xep moi nhat len tren
     $filmCondition = ['publish' => 1, 'isHot' => 1];
     $films = $this->film->where($filmCondition)->orderBy('created_at', 'desc')->get();
     //$banners = $this->getBanner();
     $cond = ['publish' => 1, 'sub_cat_id' => 5];
     $banners = Banner::where($cond)->get();
     return view('front.index', compact('films', 'url', 'film_url', 'banners'));
 }
开发者ID:thaida,项目名称:CMS,代码行数:17,代码来源:HomeController.php

示例2: postUpload

 public function postUpload(Request $request)
 {
     $input = $request->all();
     $rules = array('image' => 'image|max:204800');
     $validation = \Validator::make($input, $rules);
     if ($validation->fails()) {
         return \Response::json([$validation->errors->first()], 400);
     }
     if ($media = $this->handleMediaUpload($request, 'image')) {
         $tagIDs = [];
         if ($request->has('tags')) {
             $tagList = explode(',', $request->input('tags'));
             foreach ($tagList as $tag) {
                 $tag = trim($tag);
                 $tagORM = \App\Models\Tag::where('name', $tag)->first() ?: new \App\Models\Tag();
                 $tagORM->name = $tag;
                 if (empty($tagORM->slug)) {
                     $tagORM->slug = \App\Helpers\Text::slugify($tagORM->name);
                 }
                 $tagORM->save();
                 $tagIDs[] = $tagORM->id;
             }
             if (count($tagIDs)) {
                 $media->tags()->sync($tagIDs);
             }
         }
         return \Response::json('success', 200);
     } else {
         return \Response::json('error', 400);
     }
 }
开发者ID:joshhudnall,项目名称:beancounter,代码行数:31,代码来源:AssetsController.php

示例3: search

 public function search()
 {
     $ss = Input::get('searchbox');
     $data['orgs'] = Organisation::where('organisation', 'like', '%' . $ss . '%')->get();
     $data['pros'] = Project::where('project', 'like', '%' . $ss . '%')->get();
     $data['tags'] = Tag::where('tag', 'like', '%' . $ss . '%')->get();
     $data['ss'] = $ss;
     return view('search', $data);
 }
开发者ID:bishopm,项目名称:ncc,代码行数:9,代码来源:HomeController.php

示例4: getSortedTags

 /**
  * Get all tags in sorted order according to number of posts a tag belongs to.
  * @return array [tag1, tag2, ...]
  */
 private function getSortedTags()
 {
     $tags = Tag::where('confession_tag', 'REGEXP', '#[a-z]+')->get()->filter(function ($tag) {
         return $tag->confessions()->approved()->count() > 0;
     })->sortBy(function ($tag) {
         return -$tag->confessions()->approved()->count();
     });
     return array_values($tags->toArray());
 }
开发者ID:nekonekonik,项目名称:nuswhispers,代码行数:13,代码来源:TagsController.php

示例5: saved

 public function saved($model)
 {
     foreach ($model->tags as $tag) {
         $new_tag = Tag::where('type', '=', $tag->type)->where('tag', '=', $tag->tag)->first();
         if (!$new_tag) {
             $new_tag = new Tag(['type' => $tag->type, 'tag' => $tag->tag]);
             $new_tag->save();
         }
     }
 }
开发者ID:erickmo,项目名称:CapcusAPI,代码行数:10,代码来源:EmbedTagsObserver.php

示例6: leftMenuCounts

 private function leftMenuCounts()
 {
     view()->composer('dashboard._partials.left.menu_bar', function ($view) {
         $view->with('usersCount', User::count());
         $view->with('categoriesCount', Category::count());
         $view->with('venuesCount', Venue::count());
         $view->with('spacesCount', Space::count());
         $view->with('amenitiesCount', Tag::where('type', 'amenity')->count());
     });
 }
开发者ID:optimatec,项目名称:cowork,代码行数:10,代码来源:ViewComposerServiceProvider.php

示例7: tagIndexData

 /**
  * Return data for a tag index page
  *
  * @param string $tag
  * @return array
  */
 protected function tagIndexData($tag)
 {
     $tag = Tag::where('tag', $tag)->firstOrFail();
     $reverse_direction = (bool) $tag->reverse_direction;
     $posts = Post::where('published_at', '<=', Carbon::now())->whereHas('tags', function ($q) use($tag) {
         $q->where('tag', '=', $tag->tag);
     })->where('is_draft', 0)->orderBy('published_at', $reverse_direction ? 'asc' : 'desc')->simplePaginate(config('upload.posts_per_page'));
     $posts->addQuery('tag', $tag->tag);
     $page_image = $tag->page_image ?: config('upload.page_image');
     return ['title' => $tag->title, 'subtitle' => $tag->subtitle, 'posts' => $posts, 'page_image' => $page_image, 'tag' => $tag, 'reverse_direction' => $reverse_direction, 'meta_description' => $tag->meta_description ?: config('upload.description')];
 }
开发者ID:saviorZSC,项目名称:zsc_laravel,代码行数:17,代码来源:BlogIndexData.php

示例8: 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->model('articles','App\Models\Article');
     $router->bind('articles', function ($id) {
         return Article::published()->findOrFail($id);
     });
     $router->bind('tag', function ($name) {
         return Tag::where('name', $name)->firstOrFail();
     });
 }
开发者ID:ruslankus,项目名称:lavarel-lessons,代码行数:18,代码来源:RouteServiceProvider.php

示例9: savePostTags

 protected function savePostTags($postID, $tags)
 {
     foreach ($tags as $tag) {
         $resultTag = Tag::where(\DB::Raw('BINARY name'), $tag);
         if ($resultTag->count()) {
             $tagID = $resultTag->first()->id;
         } else {
             $resultTag = Tag::create(array('name' => $tag));
             $tagID = $resultTag->id;
         }
         PostTag::create(array('post_id' => $postID, 'tag_id' => $tagID));
     }
 }
开发者ID:vanhonit,项目名称:lazada,代码行数:13,代码来源:PostController.php

示例10: getSearch

 public function getSearch(Request $request)
 {
     $search = $request->get('query');
     $articles = Article::published()->join('users', 'users.id', '=', 'articles.user_id')->where(function ($q) use($search) {
         $q->where('title', 'like', '%' . $search . '%')->orWhere(function ($query) use($search) {
             $query->where('users.name', 'like', '%' . $search . '%')->orWhere('users.surname', 'like', '%' . $search . '%')->orWhere(\DB::raw('concat(users.name, \' \', users.surname)'), 'like', '%' . $search . '%');
         })->orWhere(function ($query) use($search) {
             $tag = array_flatten(Tag::where('name', 'like', '%' . $search . '%')->get(['id'])->toArray());
             $articleTagMapper = array_flatten(ArticleTagMapper::whereIn('tag_id', $tag)->distinct()->get(['article_id'])->toArray());
             $query->whereIn('id', $articleTagMapper);
         });
     })->get(['articles.id', 'articles.title']);
     return response()->json($articles);
 }
开发者ID:psiskova,项目名称:blog-academy,代码行数:14,代码来源:SearchController.php

示例11: saveTags

 public function saveTags(Product $product, array $tags)
 {
     $results = [];
     foreach ($tags as $tag) {
         $tag = trim($tag);
         $find = Tag::where('name', $tag)->first();
         if (!$find) {
             $find = Tag::create(['name' => $tag]);
         }
         $results[] = $find;
     }
     $product_ids = collect($results)->pluck('id');
     $product->tags()->attach($product_ids->toArray());
     return $results;
 }
开发者ID:amteknologi,项目名称:e-commerce,代码行数:15,代码来源:ProductRepository.php

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

示例13: store

 public function store()
 {
     $tags = \Input::get('tags');
     if ($tags && count($tags)) {
         $results = array();
         foreach ($tags as $tag) {
             $resultTag = Tag::where(\DB::Raw('BINARY name'), $tag);
             if (!$resultTag->count()) {
                 $resultTag = Tag::create(array('name' => $tag));
                 array_push($results, array($tag => $resultTag));
             } else {
                 array_push($results, array($tag => 'Exsiting'));
             }
         }
         Cache::forget('all_tag');
         return self::makeResponse($results, 201);
     } else {
         return self::makeResponse(array(), 400, 'Bad Request');
     }
 }
开发者ID:vanhonit,项目名称:lazada,代码行数:20,代码来源:TagController.php

示例14: tagSubscribe

 public function tagSubscribe(Request $request, $slug)
 {
     $tag = Tag::where('slug', $slug)->first();
     $message = [];
     if ($currentUser = \Auth::user()) {
         if ($tag->subscribers->contains($currentUser)) {
             // $this->dispatch(new RemoveLikeFromAnswer($tag, \Auth::user()));
             $tag->subscribers()->detach($currentUser);
             $message['type'] = 'unsubscribe';
         } else {
             $tag->subscribers()->attach($currentUser);
             $message['type'] = 'subscribe';
             // $this->dispatch(new AddLikeToAnswer($tag, \Auth::user()));
         }
     }
     if ($request->ajax()) {
         $message['count'] = $tag->subscribersCount;
         $message['title'] = count_subscribers($message['count']);
         return $message;
     }
     return back();
 }
开发者ID:gultaj,项目名称:toster,代码行数:22,代码来源:SubscribesController.php

示例15: postCreate

 /**
  * Responds to requests to POST /article/create
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function postCreate(Request $request)
 {
     $input = $request->all();
     $input['user_id'] = Auth::id();
     $input['tags'] = array_map('trim', explode(',', $input['tags']));
     $input['task_id'] = $input['task_id'] ? $input['task_id'] : null;
     if ($input['action'] == "Odoslať") {
         $input['state'] = Article::PUBLISHED;
     } else {
         $input['state'] = Article::DRAFT;
     }
     if ($article = Article::findBySlugOrId($input['id'])) {
         $article->update($input);
         $article->resluggify()->save();
     } else {
         $article = Article::create($input);
     }
     ArticleTagMapper::where('article_id', '=', $article->id)->delete();
     foreach ($input['tags'] as $tagName) {
         if ($tagName) {
             if (!($tag = Tag::where('name', '=', $tagName)->first())) {
                 $tag = Tag::create(['name' => $tagName]);
             }
             ArticleTagMapper::create(['article_id' => $article->id, 'tag_id' => $tag->id]);
         }
     }
     if ($request->ajax()) {
         $count = Auth::user()->articles()->draft()->count();
         return response()->json(['id' => $article->id, 'status' => 'success', 'count' => $count]);
     } else {
         if ($input['action'] == "Odoslať") {
             flash()->success('Článok bol publikovaný');
             return redirect()->action('UserController@getProfile', ['id' => Auth::user()->slug]);
         } else {
             flash()->success('Článok bol uložený');
             return redirect(URL::action('ArticleController@getDraft', ['id' => $article->slug]));
         }
     }
 }
开发者ID:psiskova,项目名称:blog-academy,代码行数:45,代码来源:ArticleController.php


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