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


PHP User::select方法代码示例

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


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

示例1: getDatatable

 public static function getDatatable()
 {
     $id = Session::get('user_id');
     $first_day = date("Y-m-01");
     $last_day = date("Y-m-t");
     $today = date("Y-m-d");
     /* MONTH user consumption*/
     $monthUserConsumption = WaterRegister::where('state', '=', 'Mendoza')->where('user_id', '=', $id)->whereBetween('date', [$first_day, $last_day])->sum('value');
     /* MONTH city consumption total and average lts/hour*/
     $user = User::select(['city_id'])->with('state', 'city')->where('id', $id)->first();
     $cityConsumption = WaterRegister::select(DB::raw('sum(value) as total, avg(value) as avg'))->where('city', '=', $user->city->name)->whereBetween('date', [$first_day, $last_day])->groupBy('city')->get();
     $cityTotalConsumption = $cityConsumption[0]->total;
     $cityAverage = $cityConsumption[0]->avg;
     /*current consumption and liters per hour (DAY)*/
     $consumption = WaterRegister::where('date', '=', $today)->where('user_id', '=', $id)->sum('value');
     $consumptionPerHour = $consumption / 60;
     /*water price*/
     $waterPrice = WaterPrice::select('price')->active()->get();
     /*water bill*/
     $price = $waterPrice[0]->price;
     $liters = WaterRegister::where('date', '=', $today)->where('user_id', '=', $id)->sum('value');
     $bill = $liters * $price;
     $aux = new stdClass();
     $aux->monthUserConsumption = $monthUserConsumption;
     $aux->cityTotalConsumption = $cityTotalConsumption;
     $aux->cityAverage = $cityAverage;
     $aux->consumptionPerHour = $consumptionPerHour;
     $aux->consumption = $consumption;
     $aux->waterPrice = $price;
     $aux->bill = $bill;
     $data = [collect($aux)];
     $datatable = Datatables::of(collect($data));
     return $datatable->make(true);
 }
开发者ID:mauhftw,项目名称:mizustats,代码行数:34,代码来源:ClientReportsController.php

示例2: query

 private function query()
 {
     $users = User::select("users.*");
     $users->leftJoin('people', 'users.person_id', '=', 'people.id');
     if (Auth::check() && !Auth::user()->active_contact->isE80()) {
         $users->leftJoin('company_person', 'company_person.person_id', '=', 'people.id');
         $users->where("company_person.company_id", "=", Auth::user()->active_contact->company_id);
     }
     return $users;
 }
开发者ID:pinkynrg,项目名称:convergence2.0,代码行数:10,代码来源:UsersController.php

示例3: getDatatable

 public static function getDatatable()
 {
     $users = User::select(['id', 'name', 'lastname', 'state_id', 'city_id'])->with('state', 'city')->get();
     foreach ($users as $user) {
         $user->state_name = $user->state->name;
         $user->city_name = $user->city->name;
     }
     $datatable = Datatables::of($users);
     $datatable->addColumn('actions', '<a href="{{ URL::to(\'users/\' . $id.\'/edit\') }}" class="btn btn-default" title="Editar" ><i class="fa fa-edit"></i></a>
                                     <a href="#deleteModal" class="mb-xs mt-xs mr-xs modal-with-zoom-anim btn btn-danger delete-link" data-href="{{ URL::to(\'users/\' . $id) }}" title="Eliminar" ><i class="fa fa-trash"></i></a>');
     return $datatable->make(true);
 }
开发者ID:mauhftw,项目名称:mizustats,代码行数:12,代码来源:UsersController.php

示例4: run

 public function run()
 {
     $comment_list = ['看見麥兜總召的格局', '所以我說那個醬汁呢', '李嚴,你怎麼帥成這樣', '那些年,子洋的粉色泡泡', '刁難哥奇遇記', '轉角遇到典型的政大資管人', '喔~問題來了', '你這樣不Work', '資管迎新茶會 5/22 商院101 熱血開踢', '5/13 科技組晚上上課有演講者,歡迎到場', 'Hakuna Matata', '老王的五十個案子', '杰哥的衣服Queue', '中央資管,我愛你們全部', '阿~我們就全班宅男啊', '我都參考貝克漢穿搭耶', '這個大叔是哪來的', '現在放棄的話,就可以放暑假了', '潮水退了就知道誰沒穿褲子', '聽完周老師這番話,全資管系都驚呆了', '左手寫詩,右手寫程式', '啊不就好棒棒', '吃吃看,你吃一口就知道了', '德國拳王倒下去,莎拉布萊曼照唱  Time to say goodbye', '面對現實,不然現實就面對你', '棉被再怎麼抖都會有灰塵', '務必冷靜理性透徹,暫時把好惡丟到河流另一邊去', '怕熱就不要進廚房', '拿破崙說 由馴鹿所領導的獅子軍團 就在也不是獅子軍團', '甜甜圈~', '在非洲,每六十秒,就有一分鐘過去', '當你的左臉被人打,那你的左臉就會痛', '英國研究 生日過越多的人就越老', '當蝴蝶在南半球拍了兩下翅膀,牠就會稍微飛高一點點', '我買了130元的高級鵝肉飯'];
     //echo count($comment_list);
     $user_list = User::select('id')->lists('id');
     //echo var_dump($user_list);
     foreach ($user_list as $user_key => $user_value) {
         $app_ran_list = App::orderByRaw("RAND()")->take(35)->lists('id');
         foreach ($app_ran_list as $app_key => $app_value) {
             User_App_Comment::create(['u_id' => $user_value, 'a_id' => $app_value, 'comment' => $comment_list[$app_key]]);
         }
     }
 }
开发者ID:exile1205,项目名称:AppRecoBackend,代码行数:13,代码来源:CommentTableSeeder.php

示例5: anyData

    public function anyData()
    {
        $canUpdateUser = auth()->user()->can('update-user');
        $users = User::select(['id', 'name', 'email', 'work_number']);
        return Datatables::of($users)->addColumn('namelink', function ($users) {
            return '<a href="users/' . $users->id . '" ">' . $users->name . '</a>';
        })->add_column('edit', '
                <a href="{{ route(\'users.edit\', $id) }}" class="btn btn-success" >Edit</a>')->add_column('delete', '
                <form action="{{ route(\'users.destroy\', $id) }}" method="POST">
            <input type="hidden" name="_method" value="DELETE">
            <input type="submit" name="submit" value="Delete" class="btn btn-danger" onClick="return confirm(\'Are you sure?\')"">

            {{csrf_field()}}
            </form>')->make(true);
    }
开发者ID:Bottelet,项目名称:Flarepoint-crm,代码行数:15,代码来源:UsersController.php

示例6: userComments

 /**
  * Get all comments of a user, paginated
  *
  * @param $user_id
  *
  * @param Request $request
  *
  * @return array
  */
 public function userComments($user_id, Request $request)
 {
     // get limit
     $limit = $request->get('limit') ?: 5;
     $limit = $limit > 5 ? 5 : $limit;
     try {
         // Get user
         $user = User::select('user_id', 'username', 'created_at')->findOrFail($user_id);
         // Get comments of user, paginated
         $comments = $user->comments()->select('comment_id', 'comment', 'created_at')->paginate($limit);
     } catch (ModelNotFoundException $e) {
         return ResponseHelper::write(404, 1001, 'The requested user does not exist.');
     }
     // Get transformer for user and user comments
     $userTransformer = new UserTransformer();
     $commentTransformer = new UserCommentTransformer();
     // Return transformed user and comments
     return ResponseHelper::withPaginationData(['user' => $userTransformer->transform($user->toArray()), 'comments' => $commentTransformer->transformCollection($comments->toArray()['data'])], $comments);
 }
开发者ID:devboxr,项目名称:rest-dev-test,代码行数:28,代码来源:CommentsController.php

示例7: openid_grant

 public static function openid_grant($email, $token)
 {
     $user = User::select('users.*')->where('email', '=', $email)->join('user_openids', 'user_openids.user_id', '=', 'users.id')->where('access_token', '=', $token)->where('expires_at', '>', Carbon::now())->first();
     return $user ? "user:{$user->id}" : false;
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:5,代码来源:AuthController.php

示例8: getusers

 /**
  * Gets All users for datatables
  * @return Array json Users
  */
 public function getusers()
 {
     $users = User::select(array('users.id', 'users.email', 'users.permissions', 'users.last_login', 'users.created_at'));
     return Datatables::of($users)->add_column('actions', '
                  <center>
                     <a href="{{  URL::route(\'admin.edituser\', array($id) )}}" class="btn btn-info btn-mini"><i class="icon-edit icon-white"></i> Edit </a>')->make();
 }
开发者ID:acrixl,项目名称:Reportula,代码行数:11,代码来源:UsersController.php

示例9: postUsers

 public function postUsers(Request $request)
 {
     $outputMessage = array();
     if ($request->has('action')) {
         switch ($request->get('action')) {
             case 'new':
                 $email = $request->get('email');
                 $password = $request->get('password');
                 $firstname = $request->get('firstname');
                 $lastname = $request->get('lastname');
                 //$groupName = $request->get('group');
                 $groupID = $request->get('group');
                 try {
                     $user = Sentry::register(array('email' => $email, 'first_name' => $firstname, 'last_name' => $lastname, 'password' => $password, 'activated' => true));
                     if ($user) {
                         $outputMessage[] = array("type" => "success", "msg" => "User created successfuly.");
                         if ($groupID == 1) {
                             $group = Sentry::findGroupByName('user');
                             $user->addGroup($group);
                             $outputMessage[] = array("type" => "alert", "msg" => "The God is unique.User is added to User group ;)");
                         } else {
                             $group = Sentry::findGroupById($groupID);
                             if ($group) {
                                 $user->addGroup($group);
                                 $outputMessage[] = array("type" => "success", "msg" => "User added to " . $group->name . " successfuly");
                             } else {
                                 $group = Sentry::findGroupByName('user');
                                 $user->addGroup($group);
                                 $outputMessage[] = array("type" => "alert", "msg" => "Group " . $group->name . " not found.User is added to User group ;)");
                             }
                         }
                     }
                 } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
                     $outputMessage[] = array("type" => "alert", "msg" => "Login field is required.");
                 } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
                     $outputMessage[] = array("type" => "alert", "msg" => "Login field is required.");
                 } catch (\Cartalyst\Sentry\Users\UserExistsException $e) {
                     $outputMessage[] = array("type" => "alert", "msg" => "User with this login already exists.");
                 } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
                     $outputMessage[] = array("type" => "alert", "msg" => "Group was not found.");
                 }
                 break;
         }
     }
     $groups = Sentry::findAllGroups();
     $users = User::select(array('id', 'first_name', 'last_name', 'email'))->paginate(20);
     return view('admin.users')->with('users', $users)->with('groups', $groups)->with('messages', $outputMessage);
 }
开发者ID:sajjadrad,项目名称:larauth,代码行数:48,代码来源:AdminController.php

示例10: function

    Route::get('/', 'MemberController@managementAccount');
    //view
    Route::get('/changepassword', 'MemberController@viewChangePassword');
    Route::get('/changename', 'MemberController@viewName');
    Route::get('/change-email', 'MemberController@viewEmail');
    Route::get('/permissions', 'MemberController@allMember');
    //- send data
    Route::post('/changePassword/{id}', 'MemberController@changePassword');
    Route::post('/changeName/{id}', 'MemberController@changeName');
    Route::post('/changeEmail/{id}', 'MemberController@changeEmail');
});
Route::post('/addManager', 'MemberController@addManager');
Route::post('/delManager', 'MemberController@delManager');
//------------------------------------------------------------Auto
Route::get('/autocomplete/member', function () {
    $user = Models\User::select('id', 'email', 'name')->where('level_id', '!=', 1)->get();
    $allUser = [];
    $allUser['users'] = $user;
    return Response::json($user);
});
//---------------------------------------------------------------------------------------
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\\AuthController@getRegister');
Route::post('auth/register', 'Auth\\AuthController@postRegister');
// use for @break in blade
Blade::extend(function ($value) {
    return preg_replace('/(\\s*)@(break|continue)(\\s*)/', '$1<?php $2; ?>$3', $value);
开发者ID:DearNatthawut,项目名称:kanban,代码行数:31,代码来源:routes.php

示例11: function

    });
});
$app->get('/comments', function (Request $request) {
    $comments = App\Models\Comment::orderBy('created_at', 'desc')->with('author')->get();
    $ids = $comments->lists('user_id')->unique()->sort()->values();
    $authors = App\Models\User::select('id', 'nickname')->whereIn('id', $ids)->get();
    return response()->json($comments)->header('Access-Control-Allow-Origin', '*');
});
$app->post('/comments', function (Request $request) {
    $author = App\Models\User::findOrFail($request->input('user_id'));
    $author->comments()->create(['text' => $request->input('text')]);
    $comments = App\Models\Comment::orderBy('created_at', 'desc')->with('author')->get()->all();
    return response($comments)->header('Access-Control-Allow-Origin', '*');
});
$app->get('/users', function (Request $request) {
    $users = App\Models\User::select('id', 'nickname')->get();
    return response()->json($users)->header('Access-Control-Allow-Origin', '*');
});
$app->group(['middleware' => 'auth'], function ($app) {
    $app->post('/conversations', function (Request $request) {
        $user = Auth::user();
        $conversations = $user->conversations()->withoutUser($user->id)->messagesCount()->get();
        $conversations = $conversations->each(function ($item) {
            $item['user'] = $item['users']->first();
            unset($item['users']);
            return $item;
        });
        return response(['success' => true, 'conversations' => $conversations])->header('Access-Control-Allow-Origin', '*');
    });
    $app->post('/conversations/last_id', function (Request $request) {
        $conv_id = Auth::user()->messages()->orderBy('created_at', 'desc')->first()->conversation_id;
开发者ID:gultaj,项目名称:react-tutorial-backend,代码行数:31,代码来源:routes.php

示例12: onDelete

 /**
  * Function Remove
  * Process Delete the Brand Data
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function onDelete()
 {
     $id = Input::get('id');
     $Model = \App\Models\User::select(['id'])->where('id', $id)->first();
     if ($Model) {
         \App\Models\User::where('id', $id)->delete();
         $param['message'] = Lang::get('message.has deleted');
         $param['error'] = false;
     } else {
         $param['message'] = Lang::get('message.has error');
         $param['error'] = true;
     }
     return json_encode($param);
 }
开发者ID:suhe,项目名称:bdoportal,代码行数:20,代码来源:UserController.php

示例13: getDatatable

 /**
  * Return JSON response with a list of user details for the getIndex() view.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v1.6]
  * @see UsersController::getIndex() method that consumed this JSON response
  * @return string JSON
  */
 public function getDatatable(Request $request, $status = null)
 {
     if (Input::has('offset')) {
         $offset = e(Input::get('offset'));
     } else {
         $offset = 0;
     }
     if (Input::has('limit')) {
         $limit = e(Input::get('limit'));
     } else {
         $limit = 50;
     }
     if (Input::get('sort') == 'name') {
         $sort = 'first_name';
     } else {
         $sort = e(Input::get('sort'));
     }
     $users = User::select(array('users.id', 'users.employee_num', 'users.email', 'users.username', 'users.location_id', 'users.manager_id', 'users.first_name', 'users.last_name', 'users.created_at', 'users.notes', 'users.company_id', 'users.deleted_at', 'users.activated'))->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company', 'throttle');
     $users = Company::scopeCompanyables($users);
     switch ($status) {
         case 'deleted':
             $users = $users->withTrashed()->Deleted();
             break;
     }
     if (Input::has('search')) {
         $users = $users->TextSearch(Input::get('search'));
     }
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     switch (Input::get('sort')) {
         case 'manager':
             $users = $users->OrderManager($order);
             break;
         case 'location':
             $users = $users->OrderLocation($order);
             break;
         default:
             $allowed_columns = ['last_name', 'first_name', 'email', 'username', 'employee_num', 'assets', 'accessories', 'consumables', 'licenses', 'groups', 'activated', 'created_at'];
             $sort = in_array($sort, $allowed_columns) ? $sort : 'first_name';
             $users = $users->orderBy($sort, $order);
             break;
     }
     $userCount = $users->count();
     $users = $users->skip($offset)->take($limit)->get();
     $rows = array();
     foreach ($users as $user) {
         $group_names = '';
         $inout = '';
         $actions = '<nobr>';
         foreach ($user->groups as $group) {
             $group_names .= '<a href="' . config('app.url') . '/admin/groups/' . $group->id . '/edit" class="label  label-default">' . $group->name . '</a> ';
         }
         if (!is_null($user->deleted_at)) {
             if (Gate::allows('users.delete')) {
                 $actions .= '<a href="' . route('restore/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-share icon-white"></i></a> ';
             }
         } else {
             if (Gate::allows('users.delete')) {
                 if ($user->accountStatus() == 'suspended') {
                     $actions .= '<a href="' . route('unsuspend/user', $user->id) . '" class="btn btn-default btn-sm"><span class="fa fa-clock-o"></span></a> ';
                 }
             }
             if (Gate::allows('users.edit')) {
                 $actions .= '<a href="' . route('update/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
                 $actions .= '<a href="' . route('clone/user', $user->id) . '" class="btn btn-info btn-sm"><i class="fa fa-clone"></i></a>';
             }
             if (Gate::allows('users.delete')) {
                 if (Auth::user()->id !== $user->id && !config('app.lock_passwords')) {
                     $actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/user', $user->id) . '" data-content="Are you sure you wish to delete this user?" data-title="Delete ' . htmlspecialchars($user->first_name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
                 } else {
                     $actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
                 }
             } else {
                 $actions .= 'foo';
             }
         }
         $actions .= '</nobr>';
         $rows[] = array('id' => $user->id, 'checkbox' => $status != 'deleted' ? '<div class="text-center hidden-xs hidden-sm"><input type="checkbox" name="edit_user[' . e($user->id) . ']" class="one_required"></div>' : '', 'name' => '<a title="' . e($user->fullName()) . '" href="../admin/users/' . e($user->id) . '/view">' . e($user->fullName()) . '</a>', 'email' => $user->email != '' ? '<a href="mailto:' . e($user->email) . '" class="hidden-md hidden-lg">' . e($user->email) . '</a>' . '<a href="mailto:' . e($user->email) . '" class="hidden-xs hidden-sm"><i class="fa fa-envelope"></i></a>' . '</span>' : '', 'username' => e($user->username), 'location' => $user->userloc ? e($user->userloc->name) : '', 'manager' => $user->manager ? '<a title="' . e($user->manager->fullName()) . '" href="users/' . e($user->manager->id) . '/view">' . e($user->manager->fullName()) . '</a>' : '', 'assets' => $user->assets->count(), 'employee_num' => e($user->employee_num), 'licenses' => $user->licenses->count(), 'accessories' => $user->accessories->count(), 'consumables' => $user->consumables->count(), 'groups' => $group_names, 'notes' => e($user->notes), 'created_at' => $user->created_at != '' ? e($user->created_at->format('F j, Y h:iA')) : '', 'activated' => $user->activated == '1' ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>', 'actions' => $actions ? $actions : '', 'companyName' => is_null($user->company) ? '' : e($user->company->name));
     }
     $data = array('total' => $userCount, 'rows' => $rows);
     return $data;
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:89,代码来源:UsersController.php

示例14: getUserJson

 public function getUserJson(\Illuminate\Http\Request $request)
 {
     $users = User::select('id', 'name', 'email', 'mobile')->paginate(10);
     return $users->toJson();
 }
开发者ID:samuraime,项目名称:k5,代码行数:5,代码来源:AdminManageController.php

示例15: index

 public function index()
 {
     $data = User::select('nguoidung_id', 'tendaydu', 'email', 'diachi', 'sodienthoai', 'tencongty', 'masothue', 'gioitinh', 'terms')->get()->toArray();
     // $orderCount = Order::count();
     return view('backend.user.list', compact('data'));
 }
开发者ID:quannh02,项目名称:thuexeweb,代码行数:6,代码来源:UserController.php


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