laravel-5.3

laravel Echo does not listen to channel and events

穿精又带淫゛_ 提交于 2020-05-29 05:16:26
问题 To broadcast an event on a channel I used laravel Echo , redis and socket-io . this is my event : class ChatNewMessage implements ShouldBroadcast { use InteractsWithSockets, SerializesModels; public $targetUsers; public $message; public function __construct ($message) { $this->targetUsers = $message->chat->users->pluck('user_id'); $this->message = $message; } public function broadcastOn () { $userChannels = []; foreach ($this->targetUsers as $id) { $userChannels[] = 'user-channel.' . $id; }

laravel Echo does not listen to channel and events

為{幸葍}努か 提交于 2020-05-29 05:16:25
问题 To broadcast an event on a channel I used laravel Echo , redis and socket-io . this is my event : class ChatNewMessage implements ShouldBroadcast { use InteractsWithSockets, SerializesModels; public $targetUsers; public $message; public function __construct ($message) { $this->targetUsers = $message->chat->users->pluck('user_id'); $this->message = $message; } public function broadcastOn () { $userChannels = []; foreach ($this->targetUsers as $id) { $userChannels[] = 'user-channel.' . $id; }

Pagination with cache in Laravel

好久不见. 提交于 2020-05-28 08:05:14
问题 Can anyone help me? I use redis cache. But I see same results on every pages when I use pagination. How can I fix it? Thanks. 回答1: You should cache your results per page, with a key that is the current page. $currentPage = request()->get('page',1); $category = Cache::remember('sellcategory-' . $currentPage, 10, function(){ return DB::table('elans')->orderBy('updated_at', 'desc')->where(['derc' => 1,'elaninnovu' => 'Satılır'])->paginate(10); }); 来源: https://stackoverflow.com/questions/41976933

Distinguish between a call from web route vs API route?

强颜欢笑 提交于 2020-05-28 03:17:51
问题 In my web.php file, I have a route that looks like this: Route::get('/', 'HomeController@getFeed'); And in my api.php file, I have a route that looks like this: Route::get('feeds', 'HomeController@getFeed'); Notice that they both call the same method, getFeed() . Is there a way to distinguish whether the call came from the web route vs the API route in the controller's method? I need to be able to return two different responses, one for the web route and one for the API route. Here is the

Distinguish between a call from web route vs API route?

六眼飞鱼酱① 提交于 2020-05-28 03:16:11
问题 In my web.php file, I have a route that looks like this: Route::get('/', 'HomeController@getFeed'); And in my api.php file, I have a route that looks like this: Route::get('feeds', 'HomeController@getFeed'); Notice that they both call the same method, getFeed() . Is there a way to distinguish whether the call came from the web route vs the API route in the controller's method? I need to be able to return two different responses, one for the web route and one for the API route. Here is the

Password reset email getting 530 5.7.1 Authentication required

白昼怎懂夜的黑 提交于 2020-03-18 05:23:02
问题 When I try to send a password reset email, I get the following error: Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required" I'm not sure what's wrong here. I've looked at Stack Overflow and Laracasts and found similar problems. I've tried two different email addresses and servers. But I'm getting the same error. Here's my .env file: MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587

Password reset email getting 530 5.7.1 Authentication required

泄露秘密 提交于 2020-03-18 05:21:27
问题 When I try to send a password reset email, I get the following error: Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required" I'm not sure what's wrong here. I've looked at Stack Overflow and Laracasts and found similar problems. I've tried two different email addresses and servers. But I'm getting the same error. Here's my .env file: MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587

Password reset email getting 530 5.7.1 Authentication required

[亡魂溺海] 提交于 2020-03-18 05:21:18
问题 When I try to send a password reset email, I get the following error: Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required" I'm not sure what's wrong here. I've looked at Stack Overflow and Laracasts and found similar problems. I've tried two different email addresses and servers. But I'm getting the same error. Here's my .env file: MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587

Laravel Passport Route redirects to login page

倾然丶 夕夏残阳落幕 提交于 2020-03-13 03:35:35
问题 I'm using Laravel 5.3 & Passport. When using Postman to test any route I have set in api.php file it always returns the login page. Here is an example of my testing route: Route::get('/getKey', function() { return 'hello'; })->middleware('client_credentials'); Postman params: Accept application/json Authorization Bearer <then my key> I have set middleware to 'auth:api' per another solution I found while searching for the answer. protected function mapApiRoutes() { Route::prefix('api') -

Laravel Passport Route redirects to login page

瘦欲@ 提交于 2020-03-13 03:31:35
问题 I'm using Laravel 5.3 & Passport. When using Postman to test any route I have set in api.php file it always returns the login page. Here is an example of my testing route: Route::get('/getKey', function() { return 'hello'; })->middleware('client_credentials'); Postman params: Accept application/json Authorization Bearer <then my key> I have set middleware to 'auth:api' per another solution I found while searching for the answer. protected function mapApiRoutes() { Route::prefix('api') -