Viewing file: UserRepository.php (1.04 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace Webkul\User\Repositories;
use Webkul\Core\Eloquent\Repository;
class UserRepository extends Repository { /** * Searchable fields */ protected $fieldSearchable = [ 'name', 'email', 'status', 'view_permission', 'role_id', ];
/** * Specify Model class name * * @return mixed */ public function model() { return 'Webkul\User\Contracts\User'; }
/** * This function will return user ids of current user's groups * * @return array */ public function getCurrentUserGroupsUserIds() { $userIds = $this->scopeQuery(function ($query) { return $query->select('users.*') ->leftJoin('user_groups', 'users.id', '=', 'user_groups.user_id') ->leftJoin('groups', 'user_groups.group_id', 'groups.id') ->whereIn('groups.id', auth()->guard('user')->user()->groups()->pluck('id')); })->get()->pluck('id')->toArray();
return $userIds; } }
|