本文整理匯總了PHP中Groups::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Groups::where方法的具體用法?PHP Groups::where怎麽用?PHP Groups::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Groups
的用法示例。
在下文中一共展示了Groups::where方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
public function create()
{
$group = Groups::where("name", "admin")->first();
$user_ids = UsersGroups::where("group_id", $group->id)->lists("user_id");
if (sizeof($user_ids) > 0) {
$this->data["users"] = User::whereIn("id", $user_ids)->get();
} else {
$this->data["users"] = [];
}
return View::make('companies.create', $this->data);
}
示例2: all
public function all()
{
$user_ids = [];
if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
$department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
$department = Department::where('id', $department_admin->department_id)->first();
$department_ids = Department::where('company_id', $department->company_id)->lists('id');
$user_ids = DepartmentAdmins::whereIn('department_id', $department_ids)->lists('user_id');
} elseif (\KodeInfo\Utilities\Utils::isOperator(Auth::user()->id)) {
$department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
$department = Department::where('id', $department_admin->department_id)->first();
$department_ids = Department::where('company_id', $department->company_id)->lists('id');
$user_ids = DepartmentAdmins::whereIn('department_id', $department_ids)->lists('user_id');
} else {
$group = Groups::where("name", "department-admin")->first();
$user_ids = UsersGroups::where("group_id", $group->id)->lists("user_id");
}
if (sizeof($user_ids) > 0) {
$this->data["admins"] = User::whereIn("id", $user_ids)->orderBy('id', 'desc')->get();
} else {
$this->data["admins"] = [];
}
foreach ($this->data["admins"] as $admin) {
$department_admin = DepartmentAdmins::where('user_id', $admin->id)->first();
if (!empty($department_admin)) {
$admin->department = Department::find($department_admin->department_id);
}
$company_id = CompanyDepartmentAdmins::where("user_id", $admin->id)->pluck('company_id');
$admin->company = Company::find($company_id);
}
return View::make('department_admins.all', $this->data);
}
示例3: online
public function online()
{
if (\KodeInfo\Utilities\Utils::isDepartmentAdmin(Auth::user()->id)) {
$department_admin = DepartmentAdmins::where('user_id', Auth::user()->id)->first();
$department = Department::where('id', $department_admin->department_id)->first();
$user_ids = OperatorsDepartment::where('department_id', $department->id)->lists('user_id');
} else {
$group = Groups::where("name", "operator")->first();
$user_ids = UsersGroups::where("group_id", $group->id)->lists("user_id");
}
if (sizeof($user_ids) > 0) {
$this->data["operators"] = User::whereIn("id", $user_ids)->where("is_online", 1)->get();
} else {
$this->data["operators"] = [];
}
foreach ($this->data["operators"] as $operator) {
$department_id = OperatorsDepartment::where('user_id', $operator->id)->pluck("department_id");
$department = Department::find($department_id);
$company = Company::find($department->company_id);
$operator->department = $department;
$operator->company = $company;
}
$this->data['permissions'] = Permissions::all();
$this->data['departments'] = Department::all();
return View::make('operators.all', $this->data);
}