本文整理汇总了PHP中app\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: slots
public function slots()
{
$user = Auth::user();
$location = $user->location;
$slot = Slot::where('location', '=', $location)->first();
$input = Input::get('wager');
$owner = User::where('name', '=', $slot->owner)->first();
$num1 = rand(1, 10);
$num2 = rand(5, 7);
$num3 = rand(5, 7);
if ($user->name != $owner->name) {
if ($num1 & $num2 & $num3 == 6) {
$money = rand(250, 300);
$payment = $money += $input * 1.75;
$user->money += $payment;
$user->save();
session()->flash('flash_message', 'You rolled three sixes!!');
return redirect('/home');
} else {
$user->money -= $input;
$user->save();
$owner->money += $input;
$owner->save();
session()->flash('flash_message_important', 'You failed to roll three sixes!!');
return redirect(action('SlotsController@show', [$slot->location]));
}
} else {
session()->flash('flash_message_important', 'You own this slot!!');
return redirect(action('SlotsController@show', [$slot->location]));
}
}
示例2: viewUser
/**
* View a user.
*
* @param $username
* @return mixed
*/
public function viewUser($username)
{
$user = $this->user->where('username', $username);
if ($user->count() > 0) {
return view('Admin.Users.View')->withUser($user->first());
}
abort(404);
}
示例3: send
public function send(ResponseSchedule $schedule)
{
//Check for any new email/phone/in-person type types for this contact and reschedule responses based on the Note
// return $schedule->most_recent_note_id;
$note = $schedule->contact->notes()->where(function ($q) {
$q->where('note_type', 'Email');
$q->orWhere('note_type', 'Phone');
$q->orWhere('note_type', 'In-Person');
})->whereRaw('note_date > IFNULL((SELECT note_date FROM notes WHERE id = ' . $schedule->most_recent_note_id . " ),'" . $schedule->created_at . "')")->orderBy('note_date', 'desc')->first();
//If a notes exists, call a reschedule of all items in this Response Template using the Note Date and log Note ID to the scheduled response.
// return $note;
if ($note) {
//If a New Note exists, Reschedule Responses and Exit
$schedules = $this->reschedule($schedule, $note);
return $schedules;
}
// Else Send the scheduled response using the response detail template
// Log a Note to Contact containing copy of the message
// return $schedule->load('detail');
$note = view('emails.templates.' . $schedule->detail->template_file_name, ['contact' => $schedule->contact]);
$note_entry = $schedule->contact->notes()->create(['note_date' => Carbon::now(), 'title' => 'Sent: ' . $schedule->detail->template . ": " . $schedule->detail->subject, 'note_type' => 'Scheduled Response', 'create_user_id' => \App\User::where('email', 'chris@ltdsailing.com')->first()->id, 'note' => \Purifier::clean($note)]);
// Send the email
\Mail::send('emails.templates.' . $schedule->detail->template_file_name, ['contact' => $schedule->contact], function ($m) use($schedule) {
$m->to('chris@ltdsailing.com', 'Chris Rundlett')->cc('tim@alltrips.com', 'Tim Bradshaw')->from('info@ltdsailing.com', 'LTD Sailing')->subject($schedule->detail->subject);
});
//Mark the Scheduled Response as SENT
$schedule->sent_date = Carbon::now();
$schedule->save();
return $schedule;
// return $note_entry->note;
}
示例4: run
public function run()
{
// create roles
$admin = Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'performs administrative tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
$cashier = Role::create(['name' => 'cashier', 'display_name' => 'Cashier', 'description' => 'performs cashier tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
$user = Role::create(['name' => 'user', 'display_name' => 'Portal User', 'description' => 'performs all basic tasks like print receipt, etc...', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
// create permissions
$editUser = Permission::create(['name' => 'edit-user', 'display_name' => 'Edit Users', 'description' => 'manage users', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
$reporting = Permission::create(['name' => 'reporting', 'display_name' => 'Print Report, Print receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
$editReporting = Permission::create(['name' => 'edit-reporting', 'display_name' => 'Edit Report, Edit receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
$receipt = Permission::create(['name' => 'view-receipt', 'display_name' => 'View receipt, View Billings', 'description' => 'View recipent and view billings', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
// assign permissions to roles
$admin->attachPermissions(array($editUser, $reporting, $receipt, $editReporting));
$cashier->attachPermissions(array($reporting, $receipt, $editReporting));
$user->attachPermissions(array($reporting, $receipt));
// attach admin user to admin role
$userAdmin = User::where('email', env('ADMIN_EMAIL'))->firstOrFail();
$userAdmin->attachRole($admin);
// assign default role to users
$users = User::all();
foreach ($users as $normalUser) {
if ($normalUser->hasRole('user')) {
continue;
}
$normalUser->attachRole($user);
}
}
示例5: index
public function index()
{
$usersData = [];
$usersData['count'] = User::all()->count();
$usersData['incompleteCount'] = User::where('status', 0)->count();
$picsData = [];
$picsData['count'] = Pic::all()->count();
$clubsData = [];
$clubsData['count'] = Club::all()->count();
$badgesData = [];
$badgesData['count'] = Badge::all()->count();
$fixtures = Fixture::all();
$fixturesData = [];
$fixturesData['count'] = $fixtures->count();
$fixturesData['overCount'] = $fixtures->filter(function ($fxt) {
return $fxt->isOver();
})->count();
$fixturesData['closedNotOverCount'] = $fixtures->filter(function ($fxt) {
return $fxt->isClosed() and !$fxt->isOver();
})->count();
$gameweeks = Gameweek::all();
$gameweeksData = [];
$gameweeksData['count'] = $gameweeks->count();
$gameweeksData['completeCount'] = Gameweek::complete()->get()->count();
$gameweeksData['pendingCount'] = Gameweek::incomplete()->get()->filter(function ($gw) {
return $gw->hasCompletedFixture();
})->count();
$adminsData = [];
$adminsData['count'] = Admin::all()->count();
return view('admin.dashboard.index', compact('usersData', 'picsData', 'clubsData', 'badgesData', 'fixturesData', 'gameweeksData', 'adminsData'));
}
示例6: users
public function users()
{
$ppk = Auth::user()->ppk->id;
$level = Auth::user()->level->id;
$users = User::where('ppk_id', $ppk)->where('level_id', '>', $level)->get();
return View('ppk.rekod.users', compact('users'));
}
示例7: facebooklogin
public function facebooklogin(Request $request)
{
$user = User::where('email', '=', $request->input('email'))->first();
var_dump($user);
if ($user) {
echo 'exists';
} else {
echo '!!!!exists';
}
if (!$user) {
// return 'no user';
$newUser = new User();
$newUser->name = $request->input('name');
$newUser->surname = $request->input('surname');
$newUser->email = $request->input('email');
$newUser->ip = $request->getClientIp();
$newUser->is_facebook = true;
$newUser->isAdmin = 0;
$newUser->residcence = "";
$newUser->address = "";
$newUser->save();
Auth::login($newUser);
} else {
Auth::login($user);
}
return $user;
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$user = Auth::user();
$topic_exist = topic::where('question_topic', $request['question_topic'])->count();
if ($topic_exist !== 1) {
$profile = User::where('id', $user['id'])->first();
$profile->user_topic()->create($request->all());
//$topic=topic::where('profile_id',$user['id'])->count();
}
$topic = topic::where('question_topic', $request['question_topic'])->get()->first();
$count = $topic->count + 1;
$affected = DB::update('update topics set count = :vote where id = :id', ['vote' => $count, 'id' => $topic->id]);
//return $topic->id;
$question = new question();
$question->user_id = $user['id'];
$question->topic_id = $topic->id;
if ($request->anonymously === 'Yes') {
$question->anonymously = 1;
} else {
$question->anonymously = 0;
}
$question->question = $request->question;
$question->details = $request->details;
$question->save();
//$topic->question_topic()->create($request->all());
return redirect()->action('questionController@show');
}
示例9: newBatch
private function newBatch($dbId, $userId)
{
$expiresAt = Carbon::now()->subDay(2);
\DebugBar::warning('New Batch');
$ownBatch = \App\Batch::where('user_id', $userId)->where('remain_count', '>', 0)->first();
if ($ownBatch != null) {
\DebugBar::warning('You own a batch');
return $ownBatch;
// if a batch is still owns by a user, give it to our user.
}
$expireBatch = \App\Batch::where('updated_at', '<=', $expiresAt)->first();
$db = \App\Dataset::find($dbId);
if ($expireBatch == null) {
\DebugBar::warning('if($expireBatch == null)');
$current_standard_id = $db->current_standard_id;
if ($current_standard_id == 0) {
// no standard id
\DebugBar::warning('if($current_standard_id == 0)');
return null;
}
$current_standard = \App\StandardItem::find($current_standard_id);
$batches = \App\Batch::where('user_id', $userId)->orderBy('standard_item_id', 'desc')->first();
if ($current_standard->batch_count == 3) {
// all dispatched
\DebugBar::warning('if( $current_standard->batch_count == 3 )');
$current_standard = \App\StandardItem::where('id', '>', $current_standard_id)->first();
if ($current_standard == null) {
return null;
}
$current_standard_id = $current_standard->id;
$db->current_standard_id = $current_standard_id;
$db->save();
}
if ($batches) {
$max_standard_id = max($batches->standard_item_id + 1, $current_standard_id);
} else {
$max_standard_id = $current_standard_id;
}
$current_standard = \App\StandardItem::where("id", ">=", $max_standard_id)->first();
\DebugBar::warning('$current_standard:' . $current_standard);
if ($current_standard == null) {
return null;
}
$newBatch = new \App\Batch();
$newBatch->fill(['standard_item_id' => $current_standard->id, 'user_id' => $userId, 'remain_count' => count($current_standard->Items)]);
$newBatch->save();
$current_standard->batch_count++;
$current_standard->save();
\DebugBar::warning('$newBatch:' . $newBatch);
return $newBatch;
} else {
$expiredUserId = $expireBatch->user_id;
$expiredUser = \App\User::where("user_id", $expiredUserId);
$expiredUser->batch_id = -1;
$expiredUser->save();
$expireBatch->user_id = $userId;
$expireBatch->save();
return $expireBatch;
}
}
示例10: search
/**
* Returns HTML markup for search results in users search form.
*
* @return \Illuminate\View\View
*/
public function search()
{
$input = Input::get('input');
// Populates search results of users with first and last names similar to user input.
$user_results = User::where('first_name', 'LIKE', '%' . $input . '%')->orWhere('last_name', 'LIKE', '%' . $input . '%')->get();
return view('search.users', compact('user_results'));
}
示例11: addCashInvoice
public function addCashInvoice(Request $request)
{
$ci_data = $request->only('invoice_number', 'customer', 'order_date', 'vat_sales', 'vat', 'total', 'prepared_by', 'received_by');
$product = $request->input('product');
$quantity = $request->input('quantity');
$uprice = $request->input('unit_price');
$amount = $request->input('amount');
// Cash Invoice Header Entries
$employee = User::where('name', $ci_data['prepared_by'])->first();
$ci = new CashInvoice();
$ci->ci_date = date('Y-m-d', strtotime($ci_data['order_date']));
$ci->customer_id = $ci_data['customer'];
$ci->total = $ci_data['total'];
$ci->vat = $ci_data['vat'];
$ci->vat_sales = $ci_data['vat_sales'];
$ci->prepared_by = $employee->id;
$ci->received_by = $ci_data['received_by'];
$ci->record_status = CashInvoice::STATUS_ACTIVE;
$ci->save();
//Cash Invoice Detail Entries
for ($i = 0; $i < count($product); $i++) {
$cid = new CashInvoiceDetail();
$cid->ci_no = $ci_data['invoice_number'];
$cid->product_id = $product[$i];
$cid->quantity = $quantity[$i];
$cid->unit_price = $uprice[$i];
$cid->amount = $amount[$i];
$cid->record_status = CashInvoiceDetail::STATUS_ACTIVE;
$cid->save();
}
return redirect()->route('home')->with('msg', 'Order Saved');
}
示例12: findByUserNameOrCreate
public function findByUserNameOrCreate($userData)
{
$user = User::where('social_id', '=', $userData->id)->first();
if (!$user) {
$user = new User();
$user->social_id = $userData->id;
$user->email = $userData->email;
$user->first_name = $userData->user['first_name'];
$user->last_name = $userData->user['last_name'];
$name = str_random(32);
while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) {
$name = str_random(32);
}
$filename = $name . '.' . 'jpg';
Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename);
Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename);
$user->avatar = $filename;
$user->gender = $userData->user['gender'];
$user->verified = $userData->user['verified'];
$user->save();
\Session::put('auth_photo', $filename);
} else {
$this->checkIfUserNeedsUpdating($userData, $user);
\Session::put('auth_photo', $user->avatar);
}
return $user;
}
示例13: follow
public function follow($name)
{
if (\Auth::guest()) {
return redirect('/');
}
$follower = \Auth::user()->name;
$followee = $name;
if ($followee == $follower) {
return Redirect::back();
} else {
$count = User::where('name', '=', $name)->count();
if ($count == 0) {
\Flash::warning('ユーザー名:' . $name . 'は存在しません。');
} else {
if ($count == 1) {
if (FollowController::isFollow($name) == 0) {
DB::table('followings')->insert(array('follower' => $follower, 'followee' => $followee));
\Flash::success($name . 'をフォローしました。');
} else {
\Flash::warning($name . 'はすでにフォローしています。');
}
}
}
}
return Redirect::back();
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(MecanexUserRequest $request)
{
// $thematic_area=$request->interest;
// dd($thematic_area);
$mecanexuser = MecanexUser::create($request->all());
$username = $request->username;
$user = User::where('username', $username)->get()->first();
// create records in table users_terms-scores once a mecanex user has been created
$terms = Term::all();
$total_terms = $terms->count();
foreach ($terms as $term) {
$mecanexuser->term()->sync([$term->id => ['user_score' => 0]], false);
$mecanexuser->profilescore()->sync([$term->id => ['profile_score' => 0]], false);
}
//create record in table mecanex_user_term_home_term_neighbor once a mecanex user has been created
for ($i = 1; $i <= $total_terms; $i++) {
for ($j = $i + 1; $j <= $total_terms; $j++) {
$mec_matrix = new MecanexUserTermHomeTermNeighbour();
$mec_matrix->mecanex_user_id = $mecanexuser->id;
$mec_matrix->term_home_id = $i;
$mec_matrix->term_neighbor_id = $j;
$mec_matrix->link_score = 0.1;
$mec_matrix->save();
}
}
//the following is only needed for linking an existing authorized user (users_table) with a new mecanex user provided they have the same username
if (empty($user)) {
$response = array('message' => 'Store successful');
} else {
$mecanexuser->user_id = $user->id;
$mecanexuser->save();
$response = array('message' => 'Store successful');
}
return response($response, 201)->header('Content-Type', 'application/json');
}
示例15: borrow2
public function borrow2()
{
//$user = user::where('email', '=', Input::get('bemail'))->firstOrFail();
$returnData = "";
$name = Input::get("name");
$email = Input::get("email");
if (Request::ajax()) {
$userCount = User::where('email', '=', Input::get('email'))->count();
$bookCount = Book::where('barcode', '=', Input::get('barcode'))->count();
if ($userCount == 1) {
$returnData = $returnData . " user existed ";
$user = User::where('email', '=', Input::get('email'))->find(1);
}
if ($userCount == 0) {
$name = Input::get("name");
$email = Input::get("email");
$user = user::create(array('email' => $email, 'name' => $name));
$returnData = $returnData . " user is created ";
}
if ($bookCount == 1) {
$returnData = $returnData . " book existed ";
$book = Book::where('barcode', '=', Input::get('barcode'))->find(1);
}
if ($bookCount == 0) {
$title = Input::get('title');
$author = Input::get('author');
$barcode = Input::get('barcode');
$book = book::create(array('title' => $title, 'author' => $author, 'barcode' => $barcode));
$returnData = $returnData . " book is created ";
}
$borrow = Borrow::create(array('user_id' => $user->id, 'book_id' => $book->id));
$returnData = $returnData . " borrowing is successful user id =" . $user->id . " book id =" . $book->id;
}
return $returnData;
}