Esempio n. 1
0
 /**
  * @return User
  */
 public function getUser($gitterId)
 {
     $formatRelations = function (HasMany $query) {
         return $query->orderBy('created_at', 'desc');
     };
     return User::query()->with(['karma' => $formatRelations, 'thanks' => $formatRelations, 'achievements' => $formatRelations])->where('gitter_id', $gitterId)->first();
 }
 public static function attempt($credentials)
 {
     $user = User::query();
     foreach ($credentials as $field => $value) {
         if ($field != 'password') {
             $user->where($field, $value);
         }
     }
     $user = $user->first();
     // Bad Email
     if (!$user) {
         $_SESSION['ALERT'] = alert('Oh Snap!', 'No accounts found with that email address...', 'error');
         return false;
     }
     // Bad Password
     if ($user->password != encrypt($credentials['password'])) {
         $_SESSION['ALERT'] = alert('Oh Snap!', 'That doesn\'t look like the right password...', 'error');
         return false;
     }
     // Not Verified
     if (!$user->verified) {
         // Send Verification Email (Always)
         static::sendVerifyToken($user->email);
         $_SESSION['ALERT'] = alert("Housekeeping!", "We're trying to make sure we have a way to contact all of our players. You should have received an email at {$user->email} with a link to confirm you account. If you did not receive this email, please contact us at&nbsp;<a href='mailto:" . $_ENV['SUPPORT_EMAIL'] . "'>" . $_ENV['SUPPORT_EMAIL'] . "</a>.", "info");
         return false;
     }
     // All Set!
     $_SESSION['user'] = $user;
     return true;
 }
Esempio n. 3
0
 public function search($input)
 {
     $query = User::query();
     $columns = Schema::getColumnListing('users');
     $attributes = array();
     foreach ($columns as $attribute) {
         $attributes[$attribute] = null;
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         }
     }
     /*
      ** Filter
      */
     $this->filter($input, $query);
     /*
      ** Get count
      */
     $total = $query->count();
     /*
      ** Pagination
      */
     $this->pagination($input, $query);
     /*
      ** Order
      */
     $this->order($input, $query);
     return [$query->get(), $attributes, 'total' => $total];
 }
Esempio n. 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     dd($request['products']);
     $products = $request['products'];
     $user_id = \Auth::user()->id;
     $this->validate($request, ['street2' => 'required|max:255|string', 'house_nr2' => 'required|max:255|string', 'postalcode2' => 'required|max:255|string', 'city2' => 'required|max:255|string']);
     \App\User::query()->where('id', $user_id)->update(array('street2' => $request['street2'], 'house_nr2' => $request['house_nr2'], 'postalcode2' => $request['postalcode2'], 'city2' => $request['city2']));
     return Redirect::action('PagesController@pay', compact('products'));
 }
 public function displayRevisions()
 {
     if (!empty($this->revisions)) {
         $html = '<h2>Revision History</h2>';
         $revisions = $this->revisions;
         foreach ($revisions as $revision) {
             $html .= '<p>Revised By ' . User::query()->find($revision->user_id)->firstName . ' ' . User::query()->find($revision->user_id)->lastName . ' On ' . date('F d, Y, g:ia', strtotime($revision->created_at));
         }
     }
     return $html;
 }
 public function automate($email, $slugs = [])
 {
     $user = User::query()->where('email', $email)->first();
     foreach ($slugs as $slug) {
         $taskExemption = new TaskExemption();
         $task = Task::query()->where('slug', $slug)->first();
         $taskExemption->user_id = $user->id;
         $taskExemption->task_id = $task->id;
         $taskExemption->save();
     }
 }
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('App\\Contracts\\Storages\\CategoryStorageContract', function () {
         return new CategoryStorage(Category::query());
     });
     $this->app->singleton('App\\Contracts\\Storages\\ItemStorageContract', function () {
         return new ItemStorage(Item::query());
     });
     $this->app->singleton('App\\Contracts\\Storages\\UserStorageContract', function () {
         return new UserStorageProxy(new UserStorage(User::query()));
     });
 }
Esempio n. 8
0
 public function index()
 {
     // キーワード受け取り
     $keyword = \Input::get('keyword');
     // クエリ生成
     $query = User::query();
     if (!empty($keyword)) {
         $query->where('email', 'like', '%' . $keyword . '%')->orWhere('name', 'like', '%' . $keyword . '%');
     }
     $users = $query->orderBy('id', 'asc')->paginate(10);
     return view('user.index', compact('users', 'keyword'));
 }
Esempio n. 9
0
 public function getExample4()
 {
     $grid = new Grid((new GridConfig())->setDataProvider(new EloquentDataProvider(User::query()))->setName('example_grid4')->setPageSize(15)->setColumns([(new FieldConfig())->setName('id')->setLabel('ID')->setSortable(true)->setSorting(Grid::SORT_ASC), (new FieldConfig())->setName('name')->setLabel('Name')->setCallback(function ($val) {
         return "<span class='glyphicon glyphicon-user'></span>{$val}";
     })->setSortable(true)->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig())->setName('email')->setLabel('Email')->setSortable(true)->setCallback(function ($val) {
         $icon = '<span class="glyphicon glyphicon-envelope"></span>&nbsp;';
         return '<small>' . $icon . HTML::link("mailto:{$val}", $val) . '</small>';
     })->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig())->setName('phone_number')->setLabel('Phone')->setSortable(true)->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig())->setName('country')->setLabel('Country')->setSortable(true), (new FieldConfig())->setName('company')->setLabel('Company')->setSortable(true)->addFilter((new FilterConfig())->setOperator(FilterConfig::OPERATOR_LIKE)), (new FieldConfig())->setName('birthday')->setLabel('Birthday')->setSortable(true), (new FieldConfig())->setName('posts_count')->setLabel('Posts')->setSortable(true), (new FieldConfig())->setName('comments_count')->setLabel('Comments')->setSortable(true)])->setComponents([(new THead())->setComponents([new ColumnHeadersRow(), (new FiltersRow())->addComponents([(new RenderFunc(function () {
         return HTML::style('js/daterangepicker/daterangepicker-bs3.css') . HTML::script('js/moment/moment-with-locales.js') . HTML::script('js/daterangepicker/daterangepicker.js') . "<style>\n                                                .daterangepicker td.available.active,\n                                                .daterangepicker li.active,\n                                                .daterangepicker li:hover {\n                                                    color:black !important;\n                                                    font-weight: bold;\n                                                }\n                                           </style>";
     }))->setRenderSection('filters_row_column_birthday'), (new DateRangePicker())->setName('birthday')->setRenderSection('filters_row_column_birthday')->setDefaultValue(['1990-01-01', date('Y-m-d')])]), (new OneCellRow())->setRenderSection(RenderableRegistry::SECTION_END)->setComponents([new RecordsPerPage(), new ColumnsHider(), (new CsvExport())->setFileName('my_report' . date('Y-m-d')), new ExcelExport(), (new HtmlTag())->setContent('<span class="glyphicon glyphicon-refresh"></span> Filter')->setTagName('button')->setRenderSection(RenderableRegistry::SECTION_END)->setAttributes(['class' => 'btn btn-success btn-sm'])])]), (new TFoot())->setComponents([new TotalsRow(['posts_count', 'comments_count']), (new TotalsRow(['posts_count', 'comments_count']))->setFieldOperations(['posts_count' => TotalsRow::OPERATION_AVG, 'comments_count' => TotalsRow::OPERATION_AVG]), (new OneCellRow())->setComponents([new Pager(), (new HtmlTag())->setAttributes(['class' => 'pull-right'])->addComponent(new ShowingRecords())])])]));
     $grid = $grid->render();
     return view('demo.default', compact('grid'));
 }
Esempio n. 10
0
 public function getData()
 {
     $draw = Input::get('draw');
     if (Input::get('order') && Input::get('columns')) {
         $columns = Input::get('columns');
         $sort_cri = Input::get('order');
         if ($sort_cri[0]) {
             $sort_field = $columns[$sort_cri[0]['column']]['data'];
             $sort_order = $sort_cri[0]['dir'];
         }
     }
     $length = Input::get('length');
     $start = Input::get('start');
     $search_fields_or_search_text = Input::get('searchFields');
     if (isset($limitFrom) && isset($rec_per_page) && isset($search_fields_or_search_text)) {
         if (is_array($search_fields_or_search_text)) {
             $usertotal_search_query = User::query();
             $userdata_search_query = User::query();
             foreach ($search_fields_or_search_text as $search_field => $search_value) {
                 $totalUsers = $usertotal_search_query->where($search_field, 'LIKE', '%' . $search_value . '%');
                 $users = $userdata_search_query->where($search_field, 'LIKE', '%' . $search_value . '%');
             }
             $totalUsers = $usertotal_search_query->count();
             $users = $userdata_search_query->skip($limitFrom)->take($rec_per_page)->get();
         } else {
             $user_fields = \Schema::getColumnListing('users');
             $usertotal_search_query = User::query();
             $userdata_search_query = User::query();
             foreach ($user_fields as $user_field) {
                 $totalUsers = $usertotal_search_query->orWhere($user_field, 'LIKE', '%' . $search_fields_or_search_text . '%');
                 $users = $userdata_search_query->orWhere($user_field, 'LIKE', '%' . $search_fields_or_search_text . '%');
             }
             $totalUsers = $usertotal_search_query->count();
             $users = $userdata_search_query->skip($limitFrom)->take($rec_per_page)->get();
         }
     } else {
         if (isset($start) && isset($length) && isset($sort_field) && isset($sort_order)) {
             $totalUsers = User::count();
             $users = User::orderBy($sort_field, $sort_order)->skip($start)->take($length)->get();
         } else {
             if (isset($start) && isset($length)) {
                 $totalUsers = User::count();
                 $users = User::skip($start)->take($length)->get();
             } else {
                 $totalUsers = User::count();
                 $users = User::all();
             }
         }
     }
     return ['draw' => (int) $draw, 'recordsFiltered' => $totalUsers, 'recordsTotal' => $totalUsers, 'data' => $users];
 }
Esempio n. 11
0
 private function my_query(Request $request, array $fields)
 {
     $query = User::query();
     foreach ($fields as $field) {
         if ($request->has($field)) {
             if ($field == 'id' || $field == 'status') {
                 $query->where($field, '=', trim($request->{$field}));
             } else {
                 $query->where($field, 'like', '%' . trim($request->{$field}) . '%');
             }
         }
     }
     return $query->orderBy('id', 'desc');
 }
 public function getIndex()
 {
     $stats = array();
     $stats['accounts_pending_approval'] = User::query()->pending()->count();
     // TODO: unify 'Y'/'N'/0/1
     $stats['nominations_pending_review'] = Household::where('draft', 'N')->where('reviewed', 0)->count();
     $stats['nominations_approved'] = Household::where('reviewed', 1)->count();
     $stats['nominations_reviewed'] = Household::where('approved', 1)->count();
     $stats['children_approved'] = Household::where('reviewed', 1)->join('child', 'child.household_id', '=', 'household.id')->count();
     $stats['children_reviewed'] = Household::where('household.approved', 1)->join('child', 'child.household_id', '=', 'household.id')->count();
     $stats['children_pending'] = Household::where('household.reviewed', 0)->where('household.draft', 'N')->join('child', 'child.household_id', '=', 'household.id')->count();
     $stats['drafts'] = Household::query()->draft()->count();
     $stats['orgs'] = DB::table('household')->select('affiliation.type', DB::raw('count(case when household.approved = 1 then 1 else null end) as approved'), DB::raw('count(case when household.reviewed = 1 then 1 else null end) as reviewed'), DB::raw('count(case when household.draft = "N" and household.reviewed = 0 then 1 else null end) as pending'))->join('users', 'users.id', '=', 'household.nominator_user_id')->join('affiliation', 'affiliation.id', '=', 'users.affiliation_id')->groupBy('affiliation.type')->get();
     return view('admin.dashboard.index', $stats);
 }
Esempio n. 13
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $this->validate($request, ['search' => 'string|max:20']);
     $query = User::query();
     if ($request->has('search')) {
         $search = $request->input('search');
         $query->where('name', 'like', $search . '%')->orWhere('email', 'like', $search . '%');
     }
     $users = $query->paginate(15);
     if ($request->wantsJSON()) {
         return response()->json($users->toArray(), 200);
     } else {
         return view('pages.user.index', ['users' => $users]);
     }
 }
 public function printCustomer($id)
 {
     $si = ServiceEstimate::query()->find($id);
     $user = $si->user;
     $inspectedByFirst = $user->firstName;
     $inspectedByLast = $user->lastName;
     if (!empty($si->authid)) {
         $authUser = User::query()->find($si->authid);
         $authFirst = $authUser->firstName;
         $authLast = $authUser->lastName;
         return PDF::loadView('pages.serviceestimate.formPrintCustomer', ['si' => $si, 'inspectedByFirst' => $inspectedByFirst, 'inspectedByLast' => $inspectedByLast, 'authFirst' => $authFirst, 'authLast' => $authLast])->stream();
     } else {
         return PDF::loadView('pages.serviceestimate.formPrintCustomer', ['si' => $si, 'inspectedByFirst' => $inspectedByFirst, 'inspectedByLast' => $inspectedByLast])->stream();
     }
 }
Esempio n. 15
0
 public function user(Request $request)
 {
     $query = User::query();
     if ($request->has('role')) {
         $query->where('role', $request->input('role'));
     }
     if ($request->has('name')) {
         $query->where('name', 'like', '%' . $request->input('name') . '%');
     }
     if ($request->has('email')) {
         $query->where('email', 'like', '%' . $request->input('email') . '%');
     }
     $users = $query->orderBy('id', 'desc')->paginate(100);
     return view('pages.admin.user', ['users' => $users]);
 }
Esempio n. 16
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //検索キーワード受け取り
     $keyword = Input::get('keyword');
     //page受け取り
     $page = Input::get('page');
     //クエリ生成
     $query = User::query();
     //もしkeywordがあったら
     if (!empty($keyword)) {
         $query->where('email', 'like', '%' . $keyword . '%')->orWhere('name', 'like', '%' . $keyword . '%');
     }
     //検索実行(検索条件は和となる)
     $users = $query->orderBy('id', 'desc')->paginate(10);
     //reteurn
     return view('admin.users.index')->with('users', $users)->with('keyword', $keyword)->with('page', $page);
 }
Esempio n. 17
0
 public function getData()
 {
     $sort_field = Input::get('sortField');
     $sort_order = Input::get('sortOrder');
     $rec_per_page = Input::get('recPerPage');
     $current_page = Input::get('currentPage');
     $limitFrom = ($current_page - 1) * $rec_per_page;
     $search_fields_or_search_text = Input::get('searchFields');
     if (isset($limitFrom) && isset($rec_per_page) && isset($search_fields_or_search_text)) {
         if (is_array($search_fields_or_search_text)) {
             $usertotal_search_query = User::query();
             $userdata_search_query = User::query();
             foreach ($search_fields_or_search_text as $search_field => $search_value) {
                 $totalUsers = $usertotal_search_query->where($search_field, 'LIKE', '%' . $search_value . '%');
                 $users = $userdata_search_query->where($search_field, 'LIKE', '%' . $search_value . '%');
             }
             $totalUsers = $usertotal_search_query->count();
             $users = $userdata_search_query->skip($limitFrom)->take($rec_per_page)->get();
         } else {
             $user_fields = \Schema::getColumnListing('users');
             $usertotal_search_query = User::query();
             $userdata_search_query = User::query();
             foreach ($user_fields as $user_field) {
                 $totalUsers = $usertotal_search_query->orWhere($user_field, 'LIKE', '%' . $search_fields_or_search_text . '%');
                 $users = $userdata_search_query->orWhere($user_field, 'LIKE', '%' . $search_fields_or_search_text . '%');
             }
             $totalUsers = $usertotal_search_query->count();
             $users = $userdata_search_query->skip($limitFrom)->take($rec_per_page)->get();
         }
     } else {
         if (isset($limitFrom) && isset($rec_per_page) && isset($sort_field) && isset($sort_order)) {
             $totalUsers = User::count();
             $users = User::orderBy($sort_field, $sort_order)->skip($limitFrom)->take($rec_per_page)->get();
         } else {
             if (isset($limitFrom) && isset($rec_per_page)) {
                 $totalUsers = User::count();
                 $users = User::skip($limitFrom)->take($rec_per_page)->get();
             } else {
                 $totalUsers = User::count();
                 $users = User::all();
             }
         }
     }
     return ['userCount' => $totalUsers, 'users' => $users];
 }
Esempio n. 18
0
 public function getIndex()
 {
     $user = Auth::user();
     //取得會員清單
     $amountPerPage = 50;
     //搜尋
     $userQuery = User::query();
     if (Input::has('q')) {
         $q = Input::get('q');
         //模糊匹配
         $q = '%' . $q . '%';
         //搜尋:信箱、暱稱、註解
         $userQuery->where(function ($query) use($q) {
             $query->where('email', 'like', $q)->orWhere('nickname', 'like', $q);
         });
     }
     $totalCount = $userQuery->count();
     $userList = $userQuery->paginate($amountPerPage);
     return view('user.list')->with('userList', $userList)->with('amountPerPage', $amountPerPage)->with('totalCount', $totalCount);
 }
Esempio n. 19
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $query = User::query();
     if (Input::query('keyword')) {
         $query->where('name', 'like', '%' . Input::query('keyword') . '%');
     }
     $page = Input::query('page') ? Input::query('page') : 1;
     $per_page = Input::query('per_page') ? Input::query('per_page') : false;
     $list_total = $query->count();
     if ($per_page) {
         $query->skip(($page - 1) * $per_page)->take($per_page);
         $list_start = ($page - 1) * $per_page + 1;
         $list_end = ($page - 1) * $per_page + $per_page;
         if ($list_end > $list_total) {
             $list_end = $list_total;
         }
     } else {
         $list_start = 1;
         $list_end = $list_total;
     }
     $results = $query->get();
     return response($results)->header('Items-Total', $list_total)->header('Items-Start', $list_start)->header('Items-End', $list_end);
 }
 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $users = User::query();
     return $this->applyScopes($users);
 }
Esempio n. 21
0
<?php

use App\User;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get('/', function () use($app) {
    return $app->welcome();
});
$app->get('/users', function () {
    return User::all();
});
$app->get('/user/{id}', function ($id) use($app) {
    $user = User::query()->findOrFail($id);
    return $user;
});
Esempio n. 22
0
 /**
  * Display a listing of the resource.
  *
  * @author MS
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $users = User::query();
     $this->limitToMerchant($users);
     return $this->standardIndexAction($users, 'user.index', 'users', ['merchant_id' => $this->fetchAssociateFilterValues($users, 'merchant')]);
 }
 public function searchPending(Request $request)
 {
     $search = trim($request->input("search")["value"] ?: "", " ,");
     $start = $request->input("start") ?: 0;
     $length = $request->input("length") ?: 25;
     $columns = $request->input("columns");
     $order = $request->input("order");
     $users = User::query()->select("users.*", "affiliation.type", "affiliation.name")->join("affiliation", "affiliation.id", "=", "users.affiliation_id")->where("name_last", "LIKE", "{$search}%")->pending()->orderBy($columns[$order[0]["column"]]["name"], $order[0]["dir"]);
     $count = $users->count();
     $users = $users->take($length)->skip($start)->get()->toArray();
     return $this->dtResponse($request, $users, $count);
 }
Esempio n. 24
0
 /**
  * Retrieve a user by their unique identifier.
  *
  * @param  mixed $identifier
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($identifier)
 {
     return User::query()->where('ID', $identifier)->first();
     //UserID
 }
Esempio n. 25
0
 /**
  * Обрабатываем стандартный и расширенный поиск для категории "Техника и мебель"
  */
 public function getStuffQuery(Request $request)
 {
     $auctions = Auction::query();
     $auctions = $auctions->where('category', '=', $request->category);
     if ($request->lot_type) {
         $auctions = $auctions->where('lot_type', '=', $request->lot_type);
     }
     if ($request->region) {
         $auctions = $auctions->where('region', '=', $request->region);
     }
     if ($request->title) {
         $auctions = $auctions->where('title', 'like', '%' . $request->title . '%')->orWhere('id', '=', $request->title);
     }
     if ($request->city) {
         $auctions = $auctions->where('city', 'like', '%' . $request->city . '%');
     }
     if ($request->lot_DebtorName) {
         $auctions = $auctions->where('lot_DebtorName', 'like', '%' . $request->lot_DebtorName . '%');
     }
     if ($request->lot_EDRPOU) {
         $auctions = $auctions->where('lot_EDRPOU', '=', $request->lot_EDRPOU);
     }
     if ($request->property_type) {
         $auctions = $auctions->whereIn('property_type', $request->property_type);
     }
     if ($request->price_from) {
         $auctions = $auctions->where('starting_price', '<=', $request->price_from);
     }
     if ($request->price_to) {
         $auctions = $auctions->where('starting_price', '<=', $request->price_to);
     }
     if ($request->date_start) {
         $auctions = $auctions->where('data_start', '>=', Carbon::parse($request->date_start)->format('Y-m-d'));
     }
     if ($request->date_end) {
         $auctions = $auctions->where('date_end', '<=', Carbon::parse($request->date_end)->format('Y-m-d'));
     }
     if ($request->lot_number) {
         $auctions = $auctions->where('id', '=', $request->lot_number);
     }
     if ($request->lot_user) {
         $searchTerms = explode(' ', $request->lot_user);
         $query = User::query();
         foreach ($searchTerms as $searchTerm) {
             $query->where(function ($q) use($searchTerm) {
                 $q->where('first_name', 'like', '%' . $searchTerm . '%')->orWhere('last_name', 'like', '%' . $searchTerm . '%')->orWhere('legal_entity', 'like', '%' . $searchTerm . '%');
             });
         }
         $users = $query->get();
         // Массив для ID обнаруженных пользователей
         $users_id = [];
         // Если есть пользователи, соответствующие запросу
         if ($users->count() > 0) {
             // Перебираем каждого пользователя
             foreach ($users as $user) {
                 // Добавляем ID пользователя в массив $users_id
                 array_push($users_id, $user->id);
             }
         }
         // Применяем фильтрацию по совпадению с ID в массиве $users_id
         $auctions = $auctions->whereIn('user', $users_id);
     }
     if ($request->stuff_brand) {
         $auctions = $auctions->where('stuff_brand', '=', $request->stuff_brand);
     }
     if ($request->stuff_model) {
         $auctions = $auctions->where('stuff_model', '=', $request->stuff_model);
     }
     if ($request->stuff_year) {
         $auctions = $auctions->where('stuff_year', '=', $request->stuff_year);
     }
     if ($request->stuff_diagonal) {
         $auctions = $auctions->where('stuff_diagonal', '=', $request->stuff_diagonal);
     }
     $auctions = $auctions->paginate(10);
     $categories = Cat::roots()->get();
     $currentCategory = Cat::find($request->category);
     return view('auction.search', ['auctions' => $auctions, 'categories' => $categories, 'currentCategory' => $currentCategory, 'request' => $request]);
 }
 public function index()
 {
     // Don't select all fields to keep password hash and tokens private
     $Users = \App\User::query()->select(["id", "name_first", "name_last", "rank", "phone", "affiliation_id", "email", "created_at", "updated_at"])->paginate(5);
     return $Users;
 }
 /**
  * Поиск по зарегистрированным пользователям
  */
 public function searchUsers(Request $request)
 {
     $query = App\User::query();
     $what = $request->s;
     if ($request->group) {
         $query = $query->where('user_group', '=', $request->group);
     }
     if ($request->s) {
         $query = $query->orWhere('first_name', 'like', '%' . $what . '%')->orWhere('last_name', 'like', '%' . $what . '%')->orWhere('middle_name', 'like', '%' . $what . '%')->orWhere('email', 'like', '%' . $what . '%')->orWhere('phone', 'like', '%' . $what . '%')->orWhere('id', '=', $what);
     }
     $query = $query->get();
     return view('dashboard.users.search', ['what' => $what, 'query' => $query, 'request' => $request]);
 }
 /**
  * @param $username
  * @param array $with
  * @return mixed
  */
 public function findByUsername($username, $with = [])
 {
     $query = $this->model->query();
     $query->where('username', $username)->orWhere('email', $username)->with($with);
     return $query->first();
 }