本文整理汇总了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]);
}
示例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'));
}