当前位置: 首页>>代码示例>>PHP>>正文


PHP User::query方法代码示例

本文整理汇总了PHP中app\User::query方法的典型用法代码示例。如果您正苦于以下问题:PHP User::query方法的具体用法?PHP User::query怎么用?PHP User::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\User的用法示例。


在下文中一共展示了User::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUser

 /**
  * @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();
 }
开发者ID:Dualse,项目名称:GitterBot,代码行数:10,代码来源:UsersController.php

示例2: attempt

 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;
 }
开发者ID:MadeByGlutard,项目名称:GreenMountainGaming.com,代码行数:30,代码来源:Auth.php

示例3: search

 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];
 }
开发者ID:ardiqghenatya,项目名称:koptel2,代码行数:30,代码来源:UserRepository.php

示例4: update

 /**
  * 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'));
 }
开发者ID:justmemaarten,项目名称:vlambeer,代码行数:16,代码来源:UserController.php

示例5: displayRevisions

 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;
 }
开发者ID:BrandonSPT,项目名称:ServicePortal,代码行数:11,代码来源:ServiceEstimate.php

示例6: automate

 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();
     }
 }
开发者ID:PLANKandre,项目名称:dashboard,代码行数:11,代码来源:TaskExemptionSeeder.php

示例7: register

 /**
  * 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()));
     });
 }
开发者ID:yayatoure42,项目名称:service-exchange,代码行数:17,代码来源:AppServiceProvider.php

示例8: index

 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'));
 }
开发者ID:wakin-,项目名称:bbs,代码行数:12,代码来源:UserController.php

示例9: getExample4

 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'));
 }
开发者ID:hwit0308,项目名称:grids-demo,代码行数:13,代码来源:DemoController.php

示例10: getData

 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];
 }
开发者ID:xparthx,项目名称:Angular-datatable,代码行数:51,代码来源:User_endpoint.php

示例11: my_query

 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');
 }
开发者ID:Jiumiking,项目名称:MingCrm,代码行数:14,代码来源:UserController.php

示例12: getIndex

 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);
 }
开发者ID:CodeForCharlotte,项目名称:cmpd-holiday-gift-backend,代码行数:15,代码来源:DashboardController.php

示例13: index

 /**
  * 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]);
     }
 }
开发者ID:santakani,项目名称:santakani.com,代码行数:20,代码来源:UserController.php

示例14: printCustomer

 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();
     }
 }
开发者ID:BrandonSPT,项目名称:ServicePortal,代码行数:15,代码来源:ServiceEstimateController.php

示例15: user

 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]);
 }
开发者ID:santakani,项目名称:santakani.com,代码行数:15,代码来源:AdminController.php


注:本文中的app\User::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。