/** * 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(); }); }
public function test_a_user_may_register_for_an_account_but_must_confirm_their_email_address() { $this->visit('register')->type('jhn', 'name')->type('*****@*****.**', '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]); }
/** * 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('*****@*****.**', '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]); }
/** * 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')); }
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); }
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]]); }
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); }
/** @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('*****@*****.**', '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]); }
/** * 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); }
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; } }
/** * 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]); }
/** * API for retrieving details of a single user */ public function apiUserDetails(User $user) { return $userWithRoles = User::whereName($user->name)->with('roles')->first(); }
public function getUser() { return User::whereName('sam')->first(); }
public function findUser($name) { return User::whereName($name)->first(); }
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"; } } }
/** * Returns a view with all of the user's details * * @param $name Node 'name' label to match when showing a User * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show($name) { $user = User::whereName($name)->first(); // TODO: This returns a relationship, which is handy, but I cannot fetch the name, only the ID - attempts to modify this behaviour have been unsuccessful thus far. $country = $user->country(); return view('admin.users.show', compact('user'))->with('country', $country); }
public function run() { DB::table('role_user')->delete(); /* Role::create(['name' => 'receipt' , 'display_name' => 'Receiver' , 'description' => 'Receiver worker at a rework table' ]); Role::create(['name' => 'putAwayReserve', 'display_name' => 'Put Away to reserve' , 'description' => 'Put Away to reserve locations' ]); Role::create(['name' => 'putAwayPick' , 'display_name' => 'Put Away to pick face' , 'description' => 'Put Away to pick face locations' ]); Role::create(['name' => 'replen' , 'display_name' => 'Replen' , 'description' => 'Move Inventory from reserve to pick face locations']); Role::create(['name' => 'poReconcile' , 'display_name' => 'PO Receipt Reconciliator', 'description' => 'Reconcile Receipt POs variances' ]); Role::create(['name' => 'teamLead' , 'display_name' => 'Shift Team Leader' , 'description' => 'Team Lead for the shift' ]); Role::create(['name' => 'super' , 'display_name' => 'Shift Supervisor' , 'description' => 'Supervising the shift' ]); Role::create(['name' => 'manager' , 'display_name' => 'Shift Manager' , 'description' => 'Managing shift activities' ]); Role::create(['name' => 'admin' , 'display_name' => 'Administrator' , 'description' => 'Administrates users of this application']); Role::create(['name' => 'support' , 'display_name' => 'IT Support' , 'description' => 'IT Support for this application' ]); User::create(['name' => 'worker' , 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'teamLead' , 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'super' , 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'manager', 'email' => '*****@*****.**', 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'admin' , 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'rbowers', 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); User::create(['name' => 'pneal' , 'email' => '*****@*****.**' , 'password' => Hash::make( 'vital123' )]); */ $roles = Role::whereRaw("name in ('receipt', 'putAwayReserve', 'putAwayPick', 'replen')")->get(); $users = User::whereRaw("name in ('worker')")->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } $roles = Role::whereRaw("name in ('receipt', 'putAwayReserve', 'putAwayPick', 'replen', 'poReconcile', 'teamLead')")->get(); $users = User::whereRaw("name in ('teamLead')")->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } $roles = Role::whereRaw("name in ('receipt', 'putAwayReserve', 'putAwayPick', 'replen', 'poReconcile', 'teamLead', 'super')")->get(); $users = User::whereRaw("name in ('super')")->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } $roles = Role::whereRaw("name in ('receipt', 'putAwayReserve', 'putAwayPick', 'replen', 'poReconcile', 'teamLead', 'super', 'manager')")->get(); $users = User::whereRaw("name in ('manager', 'rbowers')")->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } $roles = Role::whereName('admin')->get(); $users = User::whereRaw("name in ('admin', 'rbowers')")->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } $roles = Role::get(); $users = User::whereName('pneal')->get(); foreach ($roles as $role) { foreach ($users as $user) { DB::table('role_user')->insert(['role_id' => $role->id, 'user_id' => $user->id]); } } }