本文整理汇总了PHP中app\User::whereName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::whereName方法的具体用法?PHP User::whereName怎么用?PHP User::whereName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::whereName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
$router->bind('username', function ($username) {
return User::whereName($username)->firstOrFail();
});
}
示例2: test_a_user_may_register_for_an_account_but_must_confirm_their_email_address
public function test_a_user_may_register_for_an_account_but_must_confirm_their_email_address()
{
$this->visit('register')->type('jhn', 'name')->type('j@example.com', 'email')->type('password', 'password')->press('Register');
$this->see('Please Confirm your Email')->seeInDatabase('users', ['name' => 'jhn', 'verified' => 0]);
$user = User::whereName('jhn')->first();
// $this->login($user)->see('Could Not Sign In');
$this->visit("register/confirm/{$user->token}")->see('You are Now Verified Please Login')->seeInDatabase('users', ['name' => 'jhn', 'verified' => 1]);
}
示例3: a_user_may_register_for_an_account_but_must_confirm_their_email_address
/**
* A basic functional test example.
*
* @return void
*/
public function a_user_may_register_for_an_account_but_must_confirm_their_email_address()
{
$this->visit('register')->type('JohnDoe', 'name')->type('john@example.com', 'email')->type('password', 'password')->press('Register');
$this->see('Please confirm your email address')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 0]);
$user = User::whereName('JohnDoe')->first();
// $this->login($user)->see('Could not sign you in.');
$this->visit("register/confirm/{$user->token}")->see('You are now confirmed. Please login.')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 1]);
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @param \Slayerfat\PhoneParser\Interfaces\PhoneParserInterface $phoneParser
* @return \Symfony\Component\HttpFoundation\Response
*/
public function show($id, PhoneParserInterface $phoneParser)
{
$user = User::whereName($id)->first();
if (!$user) {
$user = User::findOrFail($id);
}
$user->load('personalDetails', 'personalDetails.professor', 'personalDetails.events');
return View::make('users.show', compact('user', 'phoneParser'));
}
示例5: show
public function show($user, Post $post)
{
$user = User::whereName($user)->with('posts.votes')->with('comments.posts')->firstOrFail();
$comments = $user->comments;
$linkKarma = $user->votes()->sum('value');
$commentKarma = $user->commentvotes()->sum('value');
$total_comments = $user->comments->count();
$isModerator = false;
return view('user/profile')->with('user', $user)->with('linkKarma', $linkKarma)->with('commentKarma', $commentKarma)->with('comments', $comments)->with('total_comments', $total_comments)->with('isModerator', $isModerator);
}
示例6: run
public function run()
{
DB::table('role_user')->delete();
$user = User::whereName('corean')->FirstOrFail();
$role_id = Role::whereName('manager')->pluck('id');
$user->saveRoles([$role_id[0]]);
$user = User::whereName('test')->FirstOrFail();
$role_id = Role::whereName('member')->pluck('id');
$user->saveRoles([$role_id[0]]);
}
示例7: index
public function index($userName)
{
$gallery_owner = User::whereName($userName)->firstOrFail();
if (!Auth::check()) {
return redirect('/uzivatel/' . $gallery_owner->id);
}
if (Auth::user()->name != $gallery_owner->name) {
return redirect('/uzivatel/' . $gallery_owner->id);
}
return view('home')->with('author', Auth::user()->name);
}
示例8: a_user_may_register_for_an_account_but_must_confirm_their_email_address
/** @test */
public function a_user_may_register_for_an_account_but_must_confirm_their_email_address()
{
// When we register...
$this->visit('register')->type('JohnDoe', 'name')->type('john@example.com', 'email')->type('password', 'password')->press('Register');
// We should have an account - but one that is not yet confirmed/verified.
$this->see('Please confirm your email address.')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 0]);
$user = User::whereName('JohnDoe')->first();
// You can't login until you confirm your email address.
$this->login($user)->see('Could not sign you in.');
// Like this...
$this->visit("register/confirm/{$user->token}")->see('You are now confirmed. Please login.')->seeInDatabase('users', ['name' => 'JohnDoe', 'verified' => 1]);
}
示例9: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
// Route Bindings
$router->bind('categories', function ($value) {
return Category::whereSlug($value)->first();
});
$router->bind('posts', function ($value) {
return Post::whereSlug($value)->first();
});
$router->bind('author', function ($value) {
return User::whereName($value)->first();
});
parent::boot($router);
}
示例10: ensure_unique_name
function ensure_unique_name($name)
{
// $addition = substr(uniqid(),0,3); //uniqid USES LETTERS AND NUMBERS
$selection = '0123456789';
$addition = substr(str_shuffle($selection), 0, 3);
if (User::whereName($name)->count() > 0) {
return $name . '_' . $addition;
} else {
return $name;
}
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Rodri
$userId = User::whereName('Rodri')->first()->id;
DB::table('product_user')->insert(['user_id' => $userId, 'product_code' => 14525]);
}
示例12: apiUserDetails
/**
* API for retrieving details of a single user
*/
public function apiUserDetails(User $user)
{
return $userWithRoles = User::whereName($user->name)->with('roles')->first();
}
示例13: getUser
public function getUser()
{
return User::whereName('sam')->first();
}
示例14: findUser
public function findUser($name)
{
return User::whereName($name)->first();
}
示例15: updatePoints
public function updatePoints()
{
if (Request::ajax()) {
$user = User::whereName(Input::get('user'))->first();
$points = Input::get('points');
if ($user === null) {
return "DENIED";
} elseif ($points === null) {
return "DENIED";
} else {
$user->points += $points;
$user->save();
return "OK";
}
}
}