public function addCommentToRequest($data, $rid) { $comment = Comment::create(['text' => $data->text, 'user_id' => Auth::user()->id, 'review_request_id' => $rid]); $last_comment_id = $comment->id; $last_comment = $comment->with('user')->find($last_comment_id); // Push last comment with user to all subscribers $data = ['topic_id' => 'request/' . $rid . '/comments', 'data' => $last_comment]; \App\Socket\Pusher::sendDataToServer($data); return $last_comment; }
| | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return Redirect::to('books'); }); Route::get('/home', function () { return View('welcome'); }); Route::post('/send_message', function () { $input = \Illuminate\Support\Facades\Input::all(); $data = ['topic_id' => 'onNewMessage', 'data' => $input['message']]; \App\Socket\Pusher::sendDataToServer($data); return redirect('/home'); }); Route::resource('users', 'UserController'); Route::resource('books', 'BookController'); // Route for list of book which having some user with id Route::get('users/{uid}/books', 'BookController@usersBooks'); // Route for returning the book Route::delete('users/{uid}/books/{bid}', 'BookController@returnBook'); // Route to list for adding books to user with id Route::get('books/users/{id}', 'BookController@listAddingBook'); // Route to store books to user with id Route::get('users/{uid}/books/{bid}', 'BookController@addBook'); // Authentication routes... Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin');