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


PHP Project::whereHas方法代码示例

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


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

示例1: users

 public function users()
 {
     if (Gate::denies('all-users')) {
         abort(403);
     }
     $users = User::paginate(20);
     $suspended = $users->where('role', 'suspended')->count();
     $active = $users->where('role', 'active')->count();
     $rush = $users->where('role', 'rush')->count();
     $admin = $users->where('role', 'admin')->count();
     $superadmin = $users->where('role', 'superadmin')->count();
     $suspended_queries = Project::whereHas('user', function ($project) {
         // $suspended_queries = Query::whereHas( 'user', function ($query) {
         $project->where('role', '=', 'suspended');
     })->count();
     $active_queries = Project::whereHas('user', function ($project) {
         // $active_queries = Query::whereHas( 'user', function ($query) {
         $project->where('role', '=', 'active');
     })->count();
     $rush_queries = Project::whereHas('user', function ($project) {
         // $rush_queries = Query::whereHas( 'user', function ($query) {
         $project->where('role', '=', 'rush');
     })->count();
     $admin_queries = Project::whereHas('user', function ($project) {
         // $admin_queries = Query::whereHas( 'user', function ($query) {
         $project->where('role', '=', 'admin');
     })->count();
     $superadmin_queries = Project::whereHas('user', function ($project) {
         // $superadmin_queries = Query::whereHas( 'user', function ($query) {
         $project->where('role', '=', 'superadmin');
     })->count();
     return view('users', ['users' => $users, 'suspended' => $suspended, 'active' => $active, 'rush' => $rush, 'admin' => $admin, 'superadmin' => $superadmin, 'suspended_queries' => $suspended_queries, 'active_queries' => $active_queries, 'rush_queries' => $rush_queries, 'admin_queries' => $admin_queries, 'superadmin_queries' => $superadmin_queries]);
 }
开发者ID:hvs-fasya,项目名称:seo_padawan,代码行数:33,代码来源:UserController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $projects = Project::whereHas('tasks', function ($query) {
         $query->whereNull('closed_at');
     })->with(['tasks' => function ($query) {
         $query->whereNull('closed_at')->orderBy('urgent', 'desc')->orderBy('created_at', 'desc');
     }, 'client'])->orderBy('rate', 'desc')->orderBy('name')->get();
     return view('task.index', compact('projects'));
 }
开发者ID:Rhenan,项目名称:tasks,代码行数:14,代码来源:TaskController.php


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