本文整理汇总了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);
}
示例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);
}
示例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');
}
}
示例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!!!');
}
示例5: updateAvatar
public function updateAvatar($avatar, $id)
{
$user = User::find($id);
$user->avatar = $avatar;
$user->save();
return $user;
}
示例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);
}
示例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']);
}
示例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');
});
}
示例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();
}
}
}
示例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]);
}
示例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();
}
示例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'));
}
示例13: approveUser
public function approveUser($id)
{
$user = User::find($id);
$user->approved = true;
$user->save();
return redirect()->back();
}
示例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'));
}
示例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();
}