aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Http
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http')
-rw-r--r--app/Http/Controllers/Auth/LoginController.php2
-rw-r--r--app/Http/Controllers/Auth/RegisterController.php2
-rw-r--r--app/Http/Controllers/Auth/ResetPasswordController.php4
-rw-r--r--app/Http/Controllers/SocketController.php44
4 files changed, 48 insertions, 4 deletions
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index b2ea669..191b2b6 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -25,7 +25,7 @@ class LoginController extends Controller
*
* @var string
*/
- protected $redirectTo = '/home';
+ protected $redirectTo = '/';
/**
* Create a new controller instance.
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index e749c07..be65e85 100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -28,7 +28,7 @@ class RegisterController extends Controller
*
* @var string
*/
- protected $redirectTo = '/home';
+ protected $redirectTo = '/';
/**
* Create a new controller instance.
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
index cf726ee..f5edc22 100644
--- a/app/Http/Controllers/Auth/ResetPasswordController.php
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -16,7 +16,7 @@ class ResetPasswordController extends Controller
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
- */
+ */
use ResetsPasswords;
@@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
- protected $redirectTo = '/home';
+ protected $redirectTo = '/';
/**
* Create a new controller instance.
diff --git a/app/Http/Controllers/SocketController.php b/app/Http/Controllers/SocketController.php
new file mode 100644
index 0000000..dc49fcf
--- /dev/null
+++ b/app/Http/Controllers/SocketController.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Http\Controllers\Controller;
+use App\Message;
+use Auth;
+use Illuminate\Http\Request;
+use LRedis;
+
+class SocketController extends Controller
+{
+ //Write Message
+ public function writeMessage()
+ {
+ $messages = Message::leftJoin('users', function ($join) {
+ $join->on('messages.user_id', '=', 'users.id');
+ })->select(
+ 'users.name', 'messages.message')->orderBy('messages.created_at')
+ ->get();
+
+ return view('writeMessage', compact('messages'));
+ }
+
+ //Send Message
+ public function sendMessage(Request $request)
+ {
+ $user = Auth::user();
+
+ $input = $request->all();
+ $redis = LRedis::connection();
+
+ if (!isset($input['message']) || trim($input['message']) === '') {
+ } else {
+ Message::create([
+ 'user_id' => $user->id,
+ 'message' => $input['message'],
+ ]);
+
+ $data = ['message' => $input['message'], 'user' => $user->name];
+ $redis->publish('message', json_encode($data));
+ }
+ }
+}