本文整理匯總了PHP中App\Model\User::whereUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::whereUsername方法的具體用法?PHP User::whereUsername怎麽用?PHP User::whereUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Model\User
的用法示例。
在下文中一共展示了User::whereUsername方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: remindPost
public function remindPost(Request $request)
{
$user = User::whereUsername($request->input('username'))->first();
if ($user instanceof User) {
$user->sendPasswordReminder();
}
// Doesn't matter if it's not actually a success; don't tell them that.
$this->alert('success', 'Please check your email.');
return redirect('/login');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request, Guard $auth)
{
$v = \Validator::make($request->all(), ['email' => 'required|email', 'username' => 'required|max:255', 'password' => 'required|confirmed']);
if ($v->fails()) {
return redirect()->back()->withErrors($v->errors());
}
$user = new User();
if (User::whereEmail($request->input('email'))->count() < 1 && User::whereUsername($request->input('username'))->count() < 1) {
$user->username = $request->input('username');
$user->email = $request->input('email');
$user->password = \Hash::make($request->input('password'));
if ($user->save()) {
\Auth::login($user);
return redirect()->route('tasks.index');
}
}
return redirect()->back()->with("NOTIF_INFO", "Email or Username have been registered");
}
示例3: save
public function save(Request $request, $id = null)
{
if (!$this->user->isAdmin()) {
return redirect('crews');
}
\DB::beginTransaction();
$crew = Crew::findOrNew($id);
$crew->name = $request->input('name');
$crew->comments = $request->input('comments');
$crew->save();
// Save crew members.
\DB::table('crew_members')->where('crew_id', '=', $crew->id)->delete();
foreach (explode(',', $request->input('members')) as $member) {
$user = User::whereUsername($member)->first();
if ($user) {
$crewMember = new CrewMember();
$crewMember->user_id = $user->id;
$crewMember->crew_id = $crew->id;
$crewMember->save();
}
}
// Save availability dates.
\DB::table('crew_unavailabilities')->where('crew_id', '=', $crew->id)->delete();
foreach ($request->input('unavailabilities') as $unavail) {
if (empty($unavail['start_date']) && empty($unavail['end_date'])) {
continue;
}
$date = new \App\Model\CrewUnavailability();
$date->crew_id = $crew->id;
$date->start_date = $unavail['start_date'];
$date->end_date = $unavail['end_date'];
$date->save();
}
\DB::commit();
return redirect('crews');
}