diff options
author | Marvin Borner | 2018-06-30 23:44:50 +0200 |
---|---|---|
committer | Marvin Borner | 2018-06-30 23:44:50 +0200 |
commit | b1c501e2f239ef6dcbf5e55e403834d793c6a0f6 (patch) | |
tree | 4532adc1e40f0da7580132b2a82c67c946a478f3 /app/Http | |
parent | 70233ba2d306019d415b94e270d3a90672236544 (diff) |
Finished websocket integration
Diffstat (limited to 'app/Http')
-rw-r--r-- | app/Http/Controllers/Auth/LoginController.php | 2 | ||||
-rw-r--r-- | app/Http/Controllers/Auth/RegisterController.php | 2 | ||||
-rw-r--r-- | app/Http/Controllers/Auth/ResetPasswordController.php | 4 | ||||
-rw-r--r-- | app/Http/Controllers/SocketController.php | 44 |
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)); + } + } +} |