laravel

Laravel Echo not listening for pusher events

爷,独闯天下 提交于 2021-02-10 20:23:48
问题 Trying to create a kind of chat app with laravel and vuejs. Once the message is sent, I fire the event from laravel which reflects on the pusher debug console with the right event class but the listen callback from vuejs is not called at all. created () { window.Echo.channel('chat') .listen('MessageSent', (e) => { console.log(e); //not getting this this.sentMessages.push({ message: e.message.message, user: e.user }); }); }, Below is a screenshot of the debug console from pusher see the image

Laravel Echo not listening for pusher events

梦想与她 提交于 2021-02-10 20:21:52
问题 Trying to create a kind of chat app with laravel and vuejs. Once the message is sent, I fire the event from laravel which reflects on the pusher debug console with the right event class but the listen callback from vuejs is not called at all. created () { window.Echo.channel('chat') .listen('MessageSent', (e) => { console.log(e); //not getting this this.sentMessages.push({ message: e.message.message, user: e.user }); }); }, Below is a screenshot of the debug console from pusher see the image

Laraadmin and sqlite “SHOW”: syntax error (SQL: SHOW TABLES)

柔情痞子 提交于 2021-02-10 19:38:15
问题 I have installed laraadmin as for quick admin with using sqlite. But problem is when i am going to create something getting SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error (SQL: SHOW TABLES) Thanks 回答1: Unfortunately SQLite doesn't know SHOW TABLES , but instead it has: special command line commands, like .schema or .tables (with optional LIKE patterns) a master metadata table, called sqlite_master So let's say you have the following tables: sqlite> CREATE TABLE A(a INT, b, INT, c

Laraadmin and sqlite “SHOW”: syntax error (SQL: SHOW TABLES)

 ̄綄美尐妖づ 提交于 2021-02-10 19:36:27
问题 I have installed laraadmin as for quick admin with using sqlite. But problem is when i am going to create something getting SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error (SQL: SHOW TABLES) Thanks 回答1: Unfortunately SQLite doesn't know SHOW TABLES , but instead it has: special command line commands, like .schema or .tables (with optional LIKE patterns) a master metadata table, called sqlite_master So let's say you have the following tables: sqlite> CREATE TABLE A(a INT, b, INT, c

How to add Array Object and Data to JSON in Laravel

混江龙づ霸主 提交于 2021-02-10 18:51:45
问题 How to add Array Object and Data to JSON in Laravel $json = {'id':5, 'name':'Hassan'}; I want to add new object role and value Admin to $json I want result like $json = {'id':5, 'name':'Hassan', 'role':'Admin'}; 回答1: Try this $object = json_decode($json); $object->role = 'Admin'; $json = json_encode($object) 回答2: You could decode the JSON, add the values you want and then encode it back to JSON: $data = json_decode($json, true); $data['role'] = 'Admin'; $json = json_encode($json); json_decode

Additional data in Laravel Resource

Deadly 提交于 2021-02-10 18:23:40
问题 I use Laravel resource from the controller: $data = Project::limit(100)->get(); return response()->json(ProjectResource::collection($data)); I like to pass additional information to the ProjectResource. How it's possible? And how can i access the additional data? I tried like this: $data = Project::limit(100)->get(); return response()->json(ProjectResource::collection($data)->additional(['some_id => 1']); But it's not working. What's the right way? I like to access the some_id in the resource

html Select multiple option with simple click without pressing CTRL button

雨燕双飞 提交于 2021-02-10 17:36:03
问题 In my Laravel app, I have a form to select multiple options. However, I don't want to select multiple options by pressing CTRL and then selecting them. I just want to be able simply click on the options and they should be selected. And, if I click on a selected option again, then it should be de-selected. How can I achieve this task? Here is an example of my select options list. <div class="form-group row"> <label class="col-form-label" for="selectednames[]">Select Name</label> </div> <div

html Select multiple option with simple click without pressing CTRL button

偶尔善良 提交于 2021-02-10 17:35:54
问题 In my Laravel app, I have a form to select multiple options. However, I don't want to select multiple options by pressing CTRL and then selecting them. I just want to be able simply click on the options and they should be selected. And, if I click on a selected option again, then it should be de-selected. How can I achieve this task? Here is an example of my select options list. <div class="form-group row"> <label class="col-form-label" for="selectednames[]">Select Name</label> </div> <div

html Select multiple option with simple click without pressing CTRL button

試著忘記壹切 提交于 2021-02-10 17:35:36
问题 In my Laravel app, I have a form to select multiple options. However, I don't want to select multiple options by pressing CTRL and then selecting them. I just want to be able simply click on the options and they should be selected. And, if I click on a selected option again, then it should be de-selected. How can I achieve this task? Here is an example of my select options list. <div class="form-group row"> <label class="col-form-label" for="selectednames[]">Select Name</label> </div> <div

Return validation error message as JSON - Laravel 6

懵懂的女人 提交于 2021-02-10 16:51:14
问题 I want to return a failed validation attempt message in JSON. I used something like this before, which was working on Laravel 5, I believe... if ($validator->fails()) { return response()->json($validator->messages(), 200); } However, for our new project we are using Laravel 6 and the above just returns a blank page. In Laravel 6 the following returns the error message successfully, albeit not in JSON... if ($validator->fails()) { $msg = $validator->messages(); dd($msg); } There must be a