Route::group([
'namespace'=>'Kdes70\Chatter\Http\Controllers',
'prefix' => 'messages',
'middleware' => ['web', 'auth'],
], function (){
Route::get('/', 'ChatterController@index')->name('messages');
Route::get('/chat/{conversation_id}', 'ChatterController@chat')->name('chat');
});
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if(Yii::$app->request->isAjax && Yii::$app->request->post('LoginForm'))
{
if ($model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
$response = ActiveForm::validate($model);
if(!empty($response))
{
return $response;
}else{
return $model->login(true);
}
//return $this->goBack();
}
}
else {
return $this->renderAjax('login', [
'model' => $model,
]);
}
}