SELECT dt,
SUM(mx) AS sm
FROM
(
-- Максимальные значения по каждому каналу за каждый день
SELECT channel_id,
CAST(created_at AS DATE) AS dt,
MAX(participants_count) AS mx
FROM table
WHERE created_at BETWEEN @dateStart AND @dateFinish
GROUP BY channel_id, CAST(created_at AS DATE)
) AS t1
GROUP BY dt
public function login()
{
//находим номер
$phone = Phones::where('phone', $phone)->with('user')->firstOrFail();
//BelongTo
$user = $phone->user;
//проверяем пароль
if (!Hash::check($password, $user->password)) return false;
//авторизуем
auth()->login($user, true);
//перенаправляем
return redirect()->route('home')->with('message', 'Вы успешно вошли');
}
$userInfo = UserInfo::where('phone', $request->get('phone', ''))->firstOrFail();
$user = User::findOrFail($userInfo->user_id);
if(\Hash::check($request->get('password', ''), $user->password))
{
auth()->login($user, true);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'current_password' => 'required_with:password',
'password' => 'required_with:current_password|confirmed',
'name' => 'required|unique:users,name,' . $this->user()->id
];
}
/**
* Configure the validator instance.
*
* @param \Illuminate\Validation\Validator $validator
* @return void
*/
public function withValidator($validator)
{
$validator->after(function ($validator) {
$currentPassword = $this->current_password;
if (! empty($currentPassword) && ! Hash::check($currentPassword, $this->user()->password)) {
$validator->errors()->add('current_password', 'Текущий пароль не совпадает с указанным паролем.');
}
if (! empty($currentPassword) && ! strcmp($currentPassword, $this->password)) {
$validator->errors()->add('password', 'Новый пароль не может совпадать с текущим паролем.');
}
if (! empty($this->password) && mb_strlen($this->password) < 6) {
$validator->errors()->add('password', 'Пароль должен содержать минимум 6 символов.');
}
});
}
This is useful if your application or package allows views to be customized or overwritten:
return view()->first(['custom.admin', 'admin'], $data);