當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::find方法代碼示例

本文整理匯總了PHP中app\User::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::find方法的具體用法?PHP User::find怎麽用?PHP User::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\User的用法示例。


在下文中一共展示了User::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  \App\Http\Requests\UserDestroyRequest  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(UserDestroyRequest $request, $id)
 {
     $user = $this->user->find($id);
     $this->user->destroy($id);
     event(new UserDestroyBroadcastEvent($user->toArray()));
     return response($user);
 }
開發者ID:xzxzyzyz,項目名稱:laravel-websocket-sample,代碼行數:14,代碼來源:UserController.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $hash = $request->segment(3);
     $post = $this->post->byHash($hash);
     if ($post->being_edited_by != null && $post->being_edited_by != $this->auth->user()->getAuthIdentifier()) {
         $user = $this->user->find($post->being_edited_by)->fullName;
         session()->flash('notify', ['danger', trans('blogify::posts.notify.being_edited', ['name' => $user])]);
         return redirect()->route('admin.posts.index');
     }
     return $next($request);
 }
開發者ID:raccoonsoftware,項目名稱:Blogify,代碼行數:18,代碼來源:DenyIfBeingEdited.php

示例3: facebookLogin

 public function facebookLogin(Request $request)
 {
     $fb = new Facebook();
     // если код не предоставлен
     if (Input::get('code') === null) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/rejected-by-user');
     }
     // если код предоставлен, но он не верен (кто то вмешался по середине)
     $authResult = $fb->auth(Input::get('code'));
     if (!$authResult) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/auth-error');
     }
     // если все в порядке, выполним нужные нам действия (авторизация, регистрация)
     $fbUserData = $fb->api('/me');
     // нужно ли зарегистрировать пользователя или авторизовать?
     if (isset($fbUserData->email)) {
         $user = User::findByEmail($fbUserData->email);
         if (!$user) {
             $user = User::create(array('name' => $fbUserData->name, 'email' => $fbUserData->email, 'password' => md5(Func::hash(8))));
         }
         Auth::login($user, true);
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/success/');
     }
     //echo var_dump($fbUserData);
     // нужно ли только авторизовать пользователя даже если емейл не предоставлен?
     $userSocGlueData = UserSocGlue::where(['provider' => 'facebook', 'provider_user_id' => $fbUserData->id])->first();
     if ($userSocGlueData) {
         Auth::login(User::find($userSocGlueData->user_id), true);
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/success/');
     }
     // если не хватает данных о юзере и он не зарегистрирован
     if (!isset($fbUserData->email)) {
         return Redirect::to('http://what-it-means.ru/#/site/auth/facebook/error/no-email');
     }
 }
開發者ID:pavvell,項目名稱:open-language,代碼行數:35,代碼來源:oAuthController.php

示例4: getDelMember

 public function getDelMember($id)
 {
     $staff = User::find($id);
     if (\Auth::user()->role_id == 1) {
         return view('html.error-403');
     }
     if ($staff->role_id == 4) {
         return view('html.error-403');
     }
     $teams = Team::where('created_user_id', $staff->id)->get();
     if (!empty($team)) {
         foreach ($teams as $key => $value) {
             TeamDetail::where('team_id', $value->id)->delete();
         }
         foreach ($teams as $key => $value) {
             $value->delete();
         }
     }
     $detail = TeamDetail::where('staff_id', $staff->id)->get();
     if (!empty($detail)) {
         foreach ($detail as $key => $value) {
             $value->delete();
         }
     }
     Profile::where('user_id', $staff->id)->first()->delete();
     $staff->delete();
     return redirect()->route('admin.index')->with('success', 'Deleted Successfully!!!');
 }
開發者ID:trongtri0705,項目名稱:elinext_project,代碼行數:28,代碼來源:DepartmentController.php

示例5: updateAvatar

 public function updateAvatar($avatar, $id)
 {
     $user = User::find($id);
     $user->avatar = $avatar;
     $user->save();
     return $user;
 }
開發者ID:nutsdo,項目名稱:mz-service,代碼行數:7,代碼來源:UserRepository.php

示例6: sign

 public function sign(Request $request)
 {
     $id = $request->session()->get('id');
     $proId = $request->input('pro_id');
     $user = User::find($id);
     return Goods::sign($id, $proId, $user->username);
 }
開發者ID:lxyeinsty,項目名稱:TuhaoReviewByLaravel,代碼行數:7,代碼來源:GoodsController.php

示例7: validateMerchantOtp

 public function validateMerchantOtp(request $request)
 {
     $apiKey = $request->only('api_key');
     $validator = Validator::make($apiKey, ['api_key' => 'required']);
     if ($validator->fails()) {
         $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
         return $response;
     }
     $role = Role::find(2);
     $key = Config::get('custom.JWTkey');
     $decoded = JWT::decode($apiKey['api_key'], $key, array('HS256'));
     if ($decoded->type != 'merchant') {
         return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
     }
     $user = User::find($decoded->sub);
     // check the current user
     if (empty($user) || !$user->hasRole(['merchant']) || !$user->status) {
         return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
     }
     $user_id = $user->id;
     $input = $request->only('otp');
     $matchThese = ['user_id' => $user_id, 'code' => $input['otp']];
     $sms = UserSmsCode::where($matchThese)->first();
     if ($sms == '' || empty($sms)) {
         return response()->json(['response_code' => 'RES_IOG', 'messages' => 'Invalid OTP Given'], 422);
     }
     $sms->status = true;
     $sms->save();
     $user->is_mobile_verified = true;
     $user->save();
     return response()->json(['response_code' => 'RES_MV', 'messages' => 'Mobile Verified']);
 }
開發者ID:abhilash698,項目名稱:projectK,代碼行數:32,代碼來源:ValidateMobileController.php

示例8: emailAccident

 /**
  * Email Accident
  */
 public function emailAccident()
 {
     $site = Site::findOrFail($this->site_id);
     $email_list = env('EMAIL_ME');
     if (\App::environment('dev', 'prod')) {
         $email_list = "robert@capecod.com.au; gary@capecod.com.au; tara@capecod.com.au; jo@capecod.com.au; " . $email_list;
         foreach ($site->supervisors as $super) {
             if (preg_match(VALID_EMAIL_PATTERN, $super->email)) {
                 $email_list .= '; ' . $super->email;
             }
         }
     }
     $email_list = trim($email_list);
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = \App::environment('dev', 'prod') ? Auth::user()->email : '';
     $data = ['id' => $this->id, 'site' => $site->name . ' (' . $site->code . ')', 'address' => $site->address . ', ' . $site->SuburbStatePostcode, 'date' => $this->date->format('d/m/Y g:i a'), 'worker' => $this->name . ' (age: ' . $this->age . ')', 'occupation' => $this->occupation, 'location' => $this->location, 'nature' => $this->nature, 'referred' => $this->referred, 'damage' => $this->damage, 'description' => $this->info, 'user_fullname' => User::find($this->created_by)->fullname, 'user_company_name' => User::find($this->created_by)->company->name, 'submit_date' => $this->created_at->format('d/m/Y g:i a'), 'site_owner' => $site->client->clientOfCompany->name];
     Mail::send('emails.siteAccident', $data, function ($m) use($email_list, $email_user) {
         $m->from('do-not-reply@safeworksite.net');
         $m->to($email_list);
         if (preg_match(VALID_EMAIL_PATTERN, $email_user)) {
             $m->cc($email_user);
         }
         $m->subject('WHS Accident Notification');
     });
 }
開發者ID:unclefudge,項目名稱:whs,代碼行數:30,代碼來源:SiteAccident.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $days_to_wait = Config::get('store.days_to_remind');
     //\DB::enableQueryLog();
     $this->info("Checks If there are orders to be rated ({$days_to_wait} Days Old)");
     //Checks all closed orders that has not been rated nor mail has been sent and where updated 5 days ago
     //and the mails has not been sent yet
     $orders = Order::where('rate', null)->where('status', 'closed')->where('rate_mail_sent', false)->where('updated_at', '<', Carbon::now()->subDays($days_to_wait))->get();
     //$this->info(print_r(\DB::getQueryLog()));
     $this->info("Orders That need mail: " . $orders->count());
     foreach ($orders as $order) {
         $this->info("Order: " . $order->id . ' Needs to be rated, and mail has not been sent');
         $buyer = User::find($order->user_id);
         if ($buyer) {
             $email = $buyer->email;
             $mail_subject = trans('email.cron_emails.remind_rate_order_subject');
             $data = ['email_message' => $mail_subject, 'email' => $email, 'subject' => $mail_subject, 'order_id' => $order->id];
             Mail::queue('emails.cron.rate_order', $data, function ($message) use($data) {
                 $message->to($data['email'])->subject($data['subject']);
             });
             $order->rate_mail_sent = true;
             $order->save();
         }
     }
 }
開發者ID:masterpowers,項目名稱:antVel,代碼行數:30,代碼來源:SendRateMails.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $last = new Last();
     $last->user_id = $user->id;
     $last->name = $request->Last;
     $last->date = $request->Date;
     $last->notifyInteger = $request->Notification;
     $last->lastNotify = \Carbon\Carbon::now()->addDays($last->notifyInteger);
     $last->save();
     $lasts = User::find($user->id)->last;
     foreach ($lasts as $key) {
         $created = new \Carbon\Carbon($key->date);
         $now = \Carbon\Carbon::now();
         $difference = $created->diffInDays($now);
         $key['dateWords'] = $created->format('l, F jS, Y');
         $key['datediff'] = $difference;
     }
     Mail::send('email.create', ['user' => $user, 'name' => $last->name], function ($m) use($user) {
         $m->from('samuelyerkes@gmail.com', 'The last time @samyerkes...');
         $m->to($user->email, $user->name)->subject('You made a new last record!');
     });
     $request->session()->flash('status', 'Record was created.');
     return view('lasts.index', ['lasts' => $lasts]);
 }
開發者ID:samyerkes,項目名稱:last.samyerkes.com,代碼行數:32,代碼來源:LastsController.php

示例11: material_update_material_cost_form_submit_correct

 /**
  * @test
  */
 public function material_update_material_cost_form_submit_correct()
 {
     $this->visit('/material/13/edit')->see('MTech MIS Login Screen');
     $user = User::find(46);
     $this->actingAs($user)->visit('/material/13/edit')->type("32", 'mat_cost_cost_kg')->type(\Carbon\Carbon::create(2016, 03, 01), 'mat_cost_date')->press("Update Price")->assertSessionHas('flash');
     $this->assertResponseOk();
 }
開發者ID:buys-fran,項目名稱:mtech-mis,代碼行數:10,代碼來源:MaterialViewsTest.php

示例12: show

 public function show($id)
 {
     $task = Task::findOrFail($id);
     $user = User::find(1);
     foreach ($user->tasks as $t) {
         dump($t->name);
     }
     //dump($task->user->name);
     foreach ($task->category as $c) {
         dump($c->name);
     }
     // Save manytomany
     // $catEssai = new Category();
     // $catEssai->name = "bonjour";
     // $task->category()->save($catEssai);
     // Save onetomany
     // $task = new Task();
     // $task->name = "essai avec un user";
     // $userEssai = new User();
     // $userEssai->name = "bonjour";
     // $userEssai->email = "bonjour@gmail.com";
     // $userEssai->password = "coucou";
     // $userEssai->save();
     // $task->user()->associate($userEssai);
     // $task->save();
     // die('ok');
     return view('task.show', compact('task'));
 }
開發者ID:unpetitlu,項目名稱:laravel-ecommerce,代碼行數:28,代碼來源:TaskController.php

示例13: approveUser

 public function approveUser($id)
 {
     $user = User::find($id);
     $user->approved = true;
     $user->save();
     return redirect()->back();
 }
開發者ID:jubaedprince,項目名稱:rkt,代碼行數:7,代碼來源:UserController.php

示例14: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $user = User::findOrFail($id);
     $roles_user = User::find($id)->roles()->lists('role_id')->toArray();
     $roles = Role::orderBy('display_name', 'asc')->lists('display_name', 'id');
     return view('admin.users.edit', compact('user', 'roles', 'roles_user'));
 }
開發者ID:wilderguzman,項目名稱:lugrawibe,代碼行數:14,代碼來源:UsersController.php

示例15: updateProfile

 public function updateProfile(Request $request)
 {
     $input = Input::except('_token', 'image', 'x', 'y', 'w', 'h', 'old_image');
     foreach ($input as $key => $value) {
         $update = User::find(Auth::user()->id);
         $update->{$key} = $value;
         $update->save();
     }
     $image = Input::file('image');
     if (!empty($image)) {
         $filename = time() . '.' . $image->getClientOriginalExtension();
         $path = public_path('profiles/' . $filename);
         $image_x = $request->x;
         $image_y = $request->y;
         $image_width = $request->w;
         $image_height = $request->h;
         $old_image = $request->old_image;
         Image::make($image->getRealPath())->crop($image_width, $image_height, $image_x, $image_y)->resize(250, 250)->save($path);
         File::delete($old_image);
         $update = User::find(Auth::user()->id);
         $update->image = $filename;
         $update->save();
     }
     return Redirect::back();
 }
開發者ID:keshavkatwe,項目名稱:advsystem,代碼行數:25,代碼來源:Member.php


注:本文中的app\User::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。