本文整理汇总了PHP中app\models\User::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP User::whereIn方法的具体用法?PHP User::whereIn怎么用?PHP User::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::whereIn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFriend
public static function getFriend($user_id)
{
$list_following_id = collect(FollowEvent::where('follower_id', $user_id)->get(['following_id']));
$list_follower_id = collect(FollowEvent::where('following_id', $user_id)->get(['follower_id']));
$list_id = $list_following_id->merge($list_follower_id);
$result = User::whereIn('user_id', $list_id)->get(['username', 'name', 'user_id', 'avatar_link']);
return $result;
}
示例2: get
public function get()
{
$user_id = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
$depth = isset($_GET['depth']) ? (int) $_GET['depth'] : 1;
if ($user_id == 0 or $depth == 0) {
echo json_encode([]);
return;
}
$fields = ['level1.user_id AS user', 'level1.friend_id AS friend'];
$joins = [];
if ($depth > 1) {
foreach (range(2, $depth) as $l) {
$fields[] = 'level' . $l . '.friend_id AS mutual' . ($l - 1);
$joins[] = 'LEFT JOIN friends level' . $l . ' ON (level' . ($l - 1) . '.`friend_id` = level' . $l . '.`user_id` AND level' . $l . '.`friend_id` != level' . ($l - 1) . '.`user_id`)';
}
}
$query = 'SELECT ';
$query .= implode(',', $fields);
$query .= ' FROM friends level1 ';
$query .= implode(' ', $joins);
$query .= ' WHERE level1.user_id = ' . $user_id;
$user_ids = [];
$records = json_decode(json_encode(DB::select($query)), true);
foreach ($records as $r => $record) {
foreach ($record as $key => $id) {
$id = (int) $id;
if (!($id > 0)) {
unset($records[$r][$key]);
continue;
}
if (in_array($id, $user_ids)) {
continue;
}
$user_ids[] = $id;
}
}
$Users = User::whereIn('id', $user_ids)->get();
$users = [];
foreach ($Users as $User) {
$users[$User->id] = $User->toArray();
}
foreach ($records as $r => $record) {
foreach ($record as $key => $id) {
$id = (int) $id;
if (!($id > 0)) {
continue;
}
$records[$r][$key] = $users[$id];
}
}
echo json_encode($records);
}
示例3: includeUsers
public function includeUsers(BeatmapsetDiscussion $discussion)
{
$userIds = [$discussion->beatmapset->user_id];
foreach ($discussion->beatmapDiscussions as $beatmapDiscussion) {
$userIds[] = $beatmapDiscussion->user_id;
foreach ($beatmapDiscussion->beatmapDiscussionPosts as $post) {
$userIds[] = $post->user_id;
$userIds[] = $post->last_editor_id;
}
}
$userIds = array_unique($userIds);
$users = User::whereIn('user_id', $userIds)->get();
return $this->collection($users, new UserCompactTransformer());
}
示例4: byhxids
public function byhxids()
{
$str = Input::get('hxids');
$str = rtrim($str, ',');
$hxids = explode(',', $str);
if (count($hxids) == 0) {
return $this->outputError('no hxids');
}
$users = User::whereIn('hxid', $hxids)->get();
foreach ($users as $v) {
$v->school;
$v->tags;
}
return $this->output(array('userList' => $users));
}
示例5: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
if (\Auth::user()->admin == "Yes") {
$users = \App\Models\User::whereIn("id", function ($query) {
$query->select('id')->from("users")->where('site_id', \Auth::user()->site_id);
})->get();
}
if (\Auth::user()->super == "Yes") {
$users = \App\Models\User::whereIn("id", function ($query) {
$query->select('users.id')->from("users")->join("sites", "site_id", "=", "sites.id")->where('company_id', \Auth::user()->site->company_id);
})->get();
}
return view('allUsers', ['users' => $users]);
}
示例6: tableCheck
public function tableCheck(Request $request, Scoring $scoring, Application $application, $id)
{
$users = $application->users()->where('role', 'admin')->all();
if (!$users) {
throw new AdminIsNotActivatedException();
}
$userIds = [];
foreach ($users as $user) {
$userIds[] = strval($user['user_id']);
}
$users = User::whereIn('_id', $userIds)->where('active', true);
if ($users->count() == 0) {
throw new AdminIsNotActivatedException();
}
return $this->response->json($scoring->check($id, $request->all(), $application->_id, $application->getSettingsElem('show_meta', false)));
}
示例7: findOrCreateByVk
public function findOrCreateByVk($data) : User
{
$user = User::whereHas('connections', function ($query) use($data) {
$query->where('driver', 'vk');
$query->whereRaw('cast(("socials".data->>\'id\') as varchar) = ?', [$data->id]);
})->first();
if (!empty($user)) {
return $user;
}
$user = User::whereIn('username', [$data->nickname, $data->email])->first();
if (!empty($user)) {
$this->addConnection($user, 'vk', $data);
return $user;
}
/** @var User $user */
$user = User::create(['first_name' => $data->user['first_name'], 'last_name' => $data->user['last_name'], 'username' => $data->nickname ?? $data->email, 'avatar' => $data->avatar]);
$this->addConnection($user, 'vk', $data);
return $user;
}
示例8: checkWhenUsernameAvailable
public static function checkWhenUsernameAvailable($username)
{
$user = User::whereIn('username', [str_replace(' ', '_', $username), str_replace('_', ' ', $username)])->first();
if ($user === null) {
$lastUsage = UsernameChangeHistory::where('username_last', $username)->orderBy('change_id', 'desc')->first();
if ($lastUsage === null) {
return Carbon::now();
}
return Carbon::parse($lastUsage->timestamp)->addMonths(6);
}
if ($user->group_id !== 2 || $user->user_type === 1) {
//reserved usernames
return Carbon::now()->addYears(10);
}
$playCount = array_reduce($user->statisticsAll(true), function ($result, $stats) {
return $result + $stats->value('playcount');
}, 0);
return $user->user_lastvisit->addMonths(6)->addDays($playCount * 0.75);
//bonus based on playcount
}
示例9: notifyReply
public function notifyReply($event)
{
$topic = $event->topic->fresh();
$userIds = model_pluck(TopicWatch::where(['topic_id' => $topic->topic_id, 'notify_status' => false]), 'user_id');
foreach (User::whereIn('user_id', $userIds)->get() as $user) {
if (!present($user->user_email)) {
continue;
}
if ($user->user_id === $topic->last_poster_id) {
continue;
}
if (!priv_check_user($user, 'ForumTopicWatchAdd', $topic)->can()) {
continue;
}
Mail::queue(['text' => i18n_view('emails.forum.new_reply')], compact('topic', 'user'), function ($message) use($topic, $user) {
$message->to($user->user_email);
$message->subject(trans('forum.email.new_reply', ['title' => $topic->topic_title]));
});
TopicWatch::where(['topic_id' => $topic->topic_id, 'user_id' => $user->user_id])->update(['notify_status' => true]);
}
}
示例10: includeUsers
public function includeUsers(BeatmapsetDiscussion $discussion)
{
$userIds = [$discussion->beatmapset->user_id];
foreach ($discussion->beatmapDiscussions as $beatmapDiscussion) {
if (!priv_check('BeatmapDiscussionShow', $beatmapDiscussion)->can()) {
continue;
}
$userIds[] = $beatmapDiscussion->user_id;
foreach ($beatmapDiscussion->beatmapDiscussionPosts as $post) {
if (!priv_check('BeatmapDiscussionPostShow', $post)->can()) {
continue;
}
$userIds[] = $post->user_id;
$userIds[] = $post->last_editor_id;
$userIds[] = $post->deleted_by;
}
}
$userIds = array_unique($userIds);
$users = User::whereIn('user_id', $userIds)->get();
return $this->collection($users, new UserCompactTransformer());
}
示例11: getAllValidSponsors
public static function getAllValidSponsors()
{
$userMeta = UserMeta::where('meta_key', '=', UserMeta::TYPE_INDEPENDENT_SPONSOR)->where('meta_value', '=', 1)->get();
$groups = Group::where('status', '=', Group::STATUS_ACTIVE)->get();
$results = new Collection();
$userIds = array();
foreach ($userMeta as $m) {
$userIds[] = $m->user_id;
}
if (!empty($userIds)) {
$users = User::whereIn('id', $userIds)->get();
foreach ($users as $user) {
$row = array('display_name' => "{$user->fname} {$user->lname}", 'sponsor_type' => 'individual', 'id' => $user->id);
$results->add($row);
}
}
foreach ($groups as $group) {
$row = array('display_name' => $group->display_name, 'sponsor_type' => 'group', 'id' => $group->id);
$results->add($row);
}
return $results;
}
示例12: moveTo
public function moveTo($destinationForum)
{
if ($this->forum_id === $destinationForum->forum_id) {
return true;
}
if (!$this->forum->isOpen()) {
return false;
}
return DB::transaction(function () use($destinationForum) {
$originForum = $this->forum;
$this->forum()->associate($destinationForum);
$this->save();
$this->posts()->update(['forum_id' => $destinationForum->forum_id]);
$this->logs()->update(['forum_id' => $destinationForum->forum_id]);
$this->userTracks()->update(['forum_id' => $destinationForum->forum_id]);
if ($originForum !== null) {
$originForum->refreshCache();
}
if ($this->forum !== null) {
$this->forum->refreshCache();
}
$users = User::whereIn('user_id', model_pluck($this->posts(), 'poster_id'))->get();
foreach ($users as $user) {
$user->refreshForumCache();
}
Log::logModerateForumTopicMove($this, $originForum);
return true;
});
}
示例13: getUimodal
public function getUimodal()
{
$Id = \Input::get('Id') ? \Input::get('Id') : Null;
$modalType = \Input::get('type') ? \Input::get('type') : Null;
if ($modalType != Null && $modalType == 'backer-lists') {
$results = \DB::select(\DB::raw("SELECT DISTINCT(`U_ID`) as user_id FROM project_funds WHERE P_ID = '{$Id}'"));
if (count($results) > 0) {
for ($k = 0; $k < count($results); $k++) {
$backerIDS[] = $results[$k]->user_id;
}
}
if (count($backerIDS) > 0) {
$backerListsByProjectId = User::whereIn('id', $backerIDS)->where('status', '1')->orderBy('id', 'desc')->get();
} else {
$backerListsByProjectId = Null;
}
return view('home.partials._backer_lists_modal', ['modalFor' => $modalType, 'project_id' => $Id, 'backerListsByProjectId' => $backerListsByProjectId]);
} else {
$myInboxLists = \App\Models\MessageHeader::where('parent_id', $Id)->orderBy('created_at', 'desc')->get();
return view('home.partials._reply_msg_modal', ['modalFor' => 'reply', 'msgId' => $Id, 'myInboxLists' => $myInboxLists]);
}
}
示例14: postBulkSave
/**
* Soft-delete bulk users
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0]
* @return Redirect
*/
public function postBulkSave()
{
if (!Input::has('edit_user') || count(Input::has('edit_user')) == 0) {
return redirect()->back()->with('error', 'No users selected');
} elseif (!Input::has('status_id') || count(Input::has('status_id')) == 0) {
return redirect()->route('users')->with('error', 'No status selected');
} else {
$user_raw_array = Input::get('edit_user');
$asset_array = array();
if (($key = array_search(Auth::user()->id, $user_raw_array)) !== false) {
unset($user_raw_array[$key]);
}
if (!Auth::user()->isSuperUser()) {
return redirect()->route('users')->with('error', trans('admin/users/message.insufficient_permissions'));
}
if (!config('app.lock_passwords')) {
$users = User::whereIn('id', $user_raw_array)->get();
$assets = Asset::whereIn('assigned_to', $user_raw_array)->get();
$accessories = DB::table('accessories_users')->whereIn('assigned_to', $user_raw_array)->get();
$licenses = DB::table('license_seats')->whereIn('assigned_to', $user_raw_array)->get();
$license_array = array();
$accessory_array = array();
foreach ($assets as $asset) {
$asset_array[] = $asset->id;
// Update the asset log
$logaction = new Actionlog();
$logaction->asset_id = $asset->id;
$logaction->checkedout_to = $asset->assigned_to;
$logaction->asset_type = 'hardware';
$logaction->user_id = Auth::user()->id;
$logaction->note = 'Bulk checkin asset and delete user';
$logaction->logaction('checkin from');
Asset::whereIn('id', $asset_array)->update(array('status_id' => e(Input::get('status_id')), 'assigned_to' => null));
}
foreach ($accessories as $accessory) {
$accessory_array[] = $accessory->accessory_id;
// Update the asset log
$logaction = new Actionlog();
$logaction->accessory_id = $accessory->id;
$logaction->checkedout_to = $accessory->assigned_to;
$logaction->asset_type = 'accessory';
$logaction->user_id = Auth::user()->id;
$logaction->note = 'Bulk checkin accessory and delete user';
$logaction->logaction('checkin from');
}
foreach ($licenses as $license) {
$license_array[] = $license->id;
// Update the asset log
$logaction = new Actionlog();
$logaction->asset_id = $license->id;
$logaction->checkedout_to = $license->assigned_to;
$logaction->asset_type = 'software';
$logaction->user_id = Auth::user()->id;
$logaction->note = 'Bulk checkin license and delete user';
$logaction->logaction('checkin from');
}
LicenseSeat::whereIn('id', $license_array)->update(['assigned_to' => null]);
foreach ($users as $user) {
$user->accessories()->sync(array());
$user->delete();
}
return redirect()->route('users')->with('success', 'Your selected users have been deleted and their assets have been updated.');
} else {
return redirect()->route('users')->with('error', 'Bulk delete is not enabled in this installation');
}
}
}
示例15: getFollower
public static function getFollower($user_id)
{
$list_id = FollowEvent::where('following_id', $user_id)->get(['follower_id']);
$result = User::whereIn('user_id', $list_id)->get(['username', 'name', 'user_id']);
return $result;
}