Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

GodziLaravel

GodziLaravel

Member Since 3 Years Ago

Experience Points
26,800
Total
Experience

3,200 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 6
26,800 XP
Nov
24
1 day ago
Activity icon

Started a new Conversation Vue.js How Detect If My Component Have Complete All Async Calls ?

Hello ,

Is it possible to know if the all async calls has been completed for my component,

I would like to create a "PLEASE WAIT!" message before everything is loaded and rendered (100% complete)

Thanks

Activity icon

Replied to Npm Run Prod , Returns Me ELIFECYCLE Error

@campo thanks for your answer ,

When I sudo npm install

I have this error

(...)
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm ERR! Linux 5.4.0-1029-aws
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /data/www/irptest.site.com/npm-debug.log

Activity icon

Started a new Conversation Npm Run Prod , Returns Me ELIFECYCLE Error

Hello,

When I try npm run prod from the sever I have this error message :


> npm run production


> @ production /data/www/irptest.icareweb.com
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found

npm ERR! Linux 5.4.0-1029-aws
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "production"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ production script 'cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /data/www/irptest.icareweb.com/npm-debug.log

npm ERR! Linux 5.4.0-1029-aws
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "prod"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script 'npm run production'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run production
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /data/www/irptest.icareweb.com/npm-debug.log

I don't have this problem when I run that command on my local env.

Should I modify some parameters?

webpack.mix.js

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */
mix.options({
    processCssUrls: true,
    purifyCss: false,
    terser: {
        terserOptions: {
            compress: {
                drop_console: true,
            }
        }
    }
});



mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .browserSync('irplocal.com');
Activity icon

Replied to Homestead: Impossible To Export The Postgresql DB

I found it :

pg_dump -U homestead -h homestead my_db_name -f the_output_file_name.sql
Activity icon

Started a new Conversation Homestead: Impossible To Export The Postgresql DB

Hello ,

I try to export my current DB, so I :

psql -U homestead -h localhost my_db_name  >> my_dump_24_11_2020

Then I enter the password, but after that nothing happens !

Nov
23
2 days ago
Activity icon

Replied to JAVASCRIPT: How To Extract A Specific Function From A Code And Put It In A Separated File ?

I did something like :

import fromFileLargeFucntion from "theLargeFunctionFile.js"

let mainLib = {


theLargeFunction: fromFileLargeFucntion.theLargefunction(),

}

export mainLib;

Then I created a file called theLargeFunctionFile.js with this content code :

let fromFileLargeFucntion = {
    theLargefunction() {
	

		// the content

	}
}
export default fromFileLargeFucntion ;

Now it seems working ,

Comments, suggestions are welcome

Activity icon

Started a new Conversation JAVASCRIPT: How To Extract A Specific Function From A Code And Put It In A Separated File ?

Hello ,

I have this JS file mainLib.js

let mainLib = {

theLargeFunction(){
	(...)
	// very large function
	(...)
},

}
export mainLib;

The function theLargeFunction is large, I want to put it in a separated file, How to manage this ?

Thanks

Nov
20
5 days ago
Activity icon

Started a new Conversation Vuejs: Is It Okay If I Git Ignore The App.js File ?

Hello ,

First, let me explain my situation :

I use Gitlab and I have and I work only on production environment

Local side :

When I finish working on a branch I execute : run npm prod then I commit, push and merge to the master branch.

Server Side:

I do pull origin master .

what I want to do is to git ignore the app.js and execute the run npm prod from the server side.

It is a good Idea ?

Thanks

Activity icon

Replied to How To Avoid This Warning Message ?

@tykus

Thnaks,

This is something related to the vue-table-2 package : https://www.npmjs.com/package/vue-tables-2

in my code I have :

<v-server-table :style="'overflow-x: scroll;'" :columns="columns" :options="options" ref="segmentTable" :url="'/api/eml?segmentId=' + segments.currentSegment.id + activatedUsersUrl" >

                <span slot="initialized" slot-scope="{row}">{{ row.initialized }}</span>

should I change <span slot="initialized" slot-scope="{row}">{{ row.initialized }}</span> ?

Activity icon

Started a new Conversation How To Avoid This Warning Message ?

hello ,

When I'm running npm run watch I always get this error message :


WARNING in ./resources/js/components/irp/purchases/requests/requests.vue?vue&type=template&id=54479762&scoped=true& (./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-load
er-options!./resources/js/components/irp/purchases/requests/requests.vue?vue&type=template&id=54479762&scoped=true&)
Module Warning (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):
(Emitted value instead of an instance of Error) the "scope" attribute for scoped slots have been deprecated and replaced by "slot-scope" since 2.5. The new "slot-scope" attribute can also be used on plain elements in addition to <te
mplate> to denote scoped slots.
 @ ./resources/js/components/irp/purchases/requests/requests.vue?vue&type=template&id=54479762&scoped=true& 1:0-242 1:0-242
 @ ./resources/js/components/irp/purchases/requests/requests.vue
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js ./resources/sass/app.scss

This warning has no bad effect on my app , but I'm wondering if it's possible to avoid it ?

Thanks

Activity icon

Started a new Conversation Eloquent , How To Check If The Row Was Updated ?

Hello,

I have an error with this code bellow :

case 'initialized':
                        $eml = ($rule == 'or')
                            ? $eml->orwhere(
                                'emls.created_at','=','emls.updated_at'
                            )
                            : $eml->where(
                                'emls.created_at','=','emls.updated_at'
                            );
                        break;

I want to compare id the updated date equals the created date, but the problem is :

SQLSTATE[22007]: Invalid datetime format: 7 ERROR: invalid input syntax for type timestamp

Is it not possible to compare two timestamp ?

Or is there another way to check if this row was updated or not ?

Thanks

Nov
19
6 days ago
Activity icon

Started a new Conversation How To Select From A Specific Table Without Using Any Relation Ship

Hello ,

I have a specific table called test_user not related to any other table (no relation ship)

| user\_id | test\_id |
|----------|----------|
| 7        | 2        |
| 4        | 1        |
| 4        | 3        |
| 4        | 2        |

How to select for example user_id where test_id =2 using the eloquent ?

Nov
18
1 week ago
Activity icon

Started a new Conversation Git & Laravel: How To Fix The Problem Of Merge Conflict (GitLab)?

Hello ,

I try to merge the branch add-more-segment-conditions in gitlab , but It's says : There are merge conflicts

and It suggests me to :

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b "add-more-segment-conditions" "origin/add-more-segment-conditions"

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout "master"
git merge --no-ff "add-more-segment-conditions"

Step 4. Push the result of the merge to GitLab

git push origin "master"

on my local git bash :

when I : git checkout -b "add-more-segment-conditions" "origin/add-more-segment-conditions"

It returns me :

 (master|MERGING)
$ git checkout -b "add-more-segment-conditions" "origin/add-more-segment-conditions"
error: you need to resolve your current index first
public/js/app.js: needs merge

How to solve this ?

Thnaks

Nov
17
1 week ago
Activity icon

Started a new Conversation Javascript : How To Filter Only One Nested Property In An Array Of Objects?

Hello ,

My current variable looks like :


columns:Object
	created_at:"2020-07-16 16:24:00"
	id:5
	name:"emls"
	searchable_columns:Array[40]
		0:Object
			created_at:null
			id:69
			label:"Birthday date"
			name:"birth_date"
			searchable_table_id:5
			type:"date"
			updated_at:null
		1:Object
			created_at:null
			id:52
			label:"Business Unit Director"
			name:"bu_director"
			searchable_table_id:5
			type:"string_list"
			updated_at:null
		2:Object
		3:Object

I need to filter ONLY the columns->searchable_columns by 'name' to return only searchable_columns where name NOT IN this array ['face_style','birth_date']

Nov
12
1 week ago
Activity icon

Replied to Simple Remark: Laracasts.com Returns A Json Results Instead Of A Web Page

Yes I use JSON viewer, but this problem is not always ,

Activity icon

Started a new Conversation Simple Remark: Laracasts.com Returns A Json Results Instead Of A Web Page

hello ,

In several times when I use laracasts.com I get a json response instead of a web page :

example : https://laracasts.com/discuss/channels/javascript/javascript-how-to-filter-array-of-objects-depending-to-a-specific-property

returns me :

// 20201112144351
// https://laracasts.com/discuss/channels/javascript/javascript-how-to-filter-array-of-objects-depending-to-a-specific-property

{
  "id": 147097,
  "title": "JavaScript: how to filter array of objects depending to a specific property",
  "body": "<p>Hello ,</p>\n<p>I want add each element of this array to a related array variable depending to the <code>tags.id</code>.</p>\n<p>for example : if  <code>tags.id</code> == 92 I have to push the complete element to the variable <code>officer</code></p>\n<p>for example : if  <code>tags.id</code> == 95 I have to push the complete element to the variable <code>teamLeader</code></p>\n<pre><code>[\n  {\n    &quot;id&quot;: 4,\n    &quot;last_name&quot;: &quot;joe&quot;,\n    &quot;first_name&quot;: &quot;eric&quot;,\n    &quot;tags&quot;: [\n      {\n        &quot;id&quot;: 95,\n        &quot;name&quot;: &quot;Team Leader&quot;\n      }\n    ]\n  },\n  {\n    &quot;id&quot;: 3,\n    &quot;last_name&quot;: &quot;Micheal&quot;,\n    &quot;first_name&quot;: &quot;Fox&quot;,\n    &quot;tags&quot;: [\n      {\n        &quot;id&quot;: 94,\n        &quot;name&quot;: &quot;BU Director&quot;\n      },\n      {\n        &quot;id&quot;: 100,\n        &quot;name&quot;: &quot;CCM&quot;\n      },\n      {\n        &quot;id&quot;: 92,\n        &quot;name&quot;: &quot;Chief Officer&quot;\n      },\n      {\n        &quot;id&quot;: 93,\n        &quot;name&quot;: &quot;HR Responsible&quot;\n      },\n      {\n        &quot;id&quot;: 98,\n        &quot;name&quot;: &quot;IT Admin&quot;\n      },\n      {\n        &quot;id&quot;: 97,\n        &quot;name&quot;: &quot;Master Data&quot;\n      },\n      {\n        &quot;id&quot;: 96,\n        &quot;name&quot;: &quot;P&amp;S Responsible&quot;\n      },\n      {\n        &quot;id&quot;: 95,\n        &quot;name&quot;: &quot;Team Leader&quot;\n      }\n    ]\n  }\n]\n</code></pre>\n<p>Thanks</p>\n",
  "body_in_markdown": "Hello , \n\nI want add each element of this array to a related array variable depending to the `tags.id`.\n\nfor example : if  `tags.id` == 92 I have to push the complete element to the variable `officer`\n\nfor example : if  `tags.id` == 95 I have to push the complete element to the variable `teamLeader`\n\n\n\n````\n[\n  {\n    \"id\": 4,\n    \"last_name\": \"joe\",\n    \"first_name\": \"eric\",\n    \"tags\": [\n      {\n        \"id\": 95,\n        \"name\": \"Team Leader\"\n      }\n    ]\n  },\n  {\n    \"id\": 3,\n    \"last_name\": \"Micheal\",\n    \"first_name\": \"Fox\",\n    \"tags\": [\n      {\n        \"id\": 94,\n        \"name\": \"BU Director\"\n      },\n      {\n        \"id\": 100,\n        \"name\": \"CCM\"\n      },\n      {\n        \"id\": 92,\n        \"name\": \"Chief Officer\"\n      },\n      {\n        \"id\": 93,\n        \"name\": \"HR Responsible\"\n      },\n      {\n        \"id\": 98,\n        \"name\": \"IT Admin\"\n      },\n      {\n        \"id\": 97,\n        \"name\": \"Master Data\"\n      },\n      {\n        \"id\": 96,\n        \"name\": \"P&S Responsible\"\n      },\n      {\n        \"id\": 95,\n        \"name\": \"Team Leader\"\n      }\n    ]\n  }\n]\n````\n\nThanks",
  "slug": "javascript-how-to-filter-array-of-objects-depending-to-a-specific-property",
  "channel_id": 19,
  "owner_id": 64918,
  "answer_user_id": 6962,
  "answer_id": 664064,
  "locked": 0,
  "reply_count": 3,
  "last_reply_username": "GodziLaravel",
  "created_at": "2020-11-12T13:24:17.000000Z",
  "updated_at": "2020-11-12T13:43:43.000000Z",
  "replies": {
    "current_page": 1,
    "data": [
      {
        "id": 664064,
        "conversation_id": 147097,
        "parent_id": null,
        "user_id": 6962,
        "body": "<pre><code>let officer = arr.filter(item =&gt; item.tags.some(tag =&gt; tag['id'] === 92))\nlet teamleader = arr.filter(item =&gt; item.tags.some(tag =&gt; tag['id'] === 95))\n</code></pre>\n",
        "body_in_markdown": "```\nlet officer = arr.filter(item => item.tags.some(tag => tag['id'] === 92))\nlet teamleader = arr.filter(item => item.tags.some(tag => tag['id'] === 95))\n```",
        "likes_count": 0,
        "created_at": "2020-11-12T13:38:39.000000Z",
        "updated_at": "2020-11-12T13:38:39.000000Z",
        "path": "/discuss/channels/javascript/javascript-how-to-filter-array-of-objects-depending-to-a-specific-property?reply=664064",
        "relative_publish_date": "5 minutes ago",
        "conversation": {
          "id": 147097,
          "title": "JavaScript: how to filter array of objects depending to a specific property",
          "body": "<p>Hello ,</p>\n<p>I want add each element of this array to a related array variable depending to the <code>tags.id</code>.</p>\n<p>for example : if  <code>tags.id</code> == 92 I have to push the complete element to the variable <code>officer</code></p>\n<p>for example : if  <code>tags.id</code> == 95 I have to push the complete element to the variable <code>teamLeader</code></p>\n<pre><code>[\n  {\n    &quot;id&quot;: 4,\n    &quot;last_name&quot;: &quot;joe&quot;,\n    &quot;first_name&quot;: &quot;eric&quot;,\n    &quot;tags&quot;: [\n      {\n        &quot;id&quot;: 95,\n        &quot;name&quot;: &quot;Team Leader&quot;\n      }\n    ]\n  },\n  {\n    &quot;id&quot;: 3,\n    &quot;last_name&quot;: &quot;Micheal&quot;,\n    &quot;first_name&quot;: &quot;Fox&quot;,\n    &quot;tags&quot;: [\n      {\n        &quot;id&quot;: 94,\n        &quot;name&quot;: &quot;BU Director&quot;\n      },\n      {\n        &quot;id&quot;: 100,\n        &quot;name&quot;: &quot;CCM&quot;\n      },\n      {\n        &quot;id&quot;: 92,\n        &quot;name&quot;: &quot;Chief Officer&quot;\n      },\n      {\n        &quot;id&quot;: 93,\n        &quot;name&quot;: &quot;HR Responsible&quot;\n      },\n      {\n        &quot;id&quot;: 98,\n        &quot;name&quot;: &quot;IT Admin&quot;\n      },\n      {\n        &quot;id&quot;: 97,\n        &quot;name&quot;: &quot;Master Data&quot;\n      },\n      {\n        &quot;id&quot;: 96,\n        &quot;name&quot;: &quot;P&amp;S Responsible&quot;\n      },\n      {\n        &quot;id&quot;: 95,\n        &quot;name&quot;: &quot;Team Leader&quot;\n      }\n    ]\n  }\n]\n</code></pre>\n<p>Thanks</p>\n",
          "body_in_markdown": "Hello , \n\nI want add each element of this array to a related array variable depending to the `tags.id`.\n\nfor example : if  `tags.id` == 92 I have to push the complete element to the variable `officer`\n\nfor example : if  `tags.id` == 95 I have to push the complete element to the variable `teamLeader`\n\n\n\n````\n[\n  {\n    \"id\": 4,\n    \"last_name\": \"joe\",\n    \"first_name\": \"eric\",\n    \"tags\": [\n      {\n        \"id\": 95,\n        \"name\": \"Team Leader\"\n      }\n    ]\n  },\n  {\n    \"id\": 3,\n    \"last_name\": \"Micheal\",\n    \"first_name\": \"Fox\",\n    \"tags\": [\n      {\n        \"id\": 94,\n        \"name\": \"BU Director\"\n      },\n      {\n        \"id\": 100,\n        \"name\": \"CCM\"\n      },\n      {\n        \"id\": 92,\n        \"name\": \"Chief Officer\"\n      },\n      {\n        \"id\": 93,\n        \"name\": \"HR Responsible\"\n      },\n      {\n        \"id\": 98,\n        \"name\": \"IT Admin\"\n      },\n      {\n        \"id\": 97,\n        \"name\": \"Master Data\"\n      },\n      {\n        \"id\": 96,\n        \"name\": \"P&S Responsible\"\n      },\n      {\n        \"id\": 95,\n        \"name\": \"Team Leader\"\n      }\n    ]\n  }\n]\n````\n\nThanks",
          "slug": "javascript-how-to-filter-array-of-objects-depending-to-a-specific-property",
          "channel_id": 19,
          "owner_id": 64918,
          "answer_user_id": 6962,
          "answer_id": 664064,
          "locked": 0,
          "reply_count": 3,
          "last_reply_username": "GodziLaravel",
          "created_at": "2020-11-12T13:24:17.000000Z",
          "updated_at": "2020-11-12T13:43:43.000000Z",
          "path": "/discuss/channels/javascript/javascript-how-to-filter-array-of-objects-depending-to-a-specific-property",
          "relative_publish_date": "19 minutes ago",
          "channel": {
            "id": 19,
            "title": "JavaScript",
            "slug": "javascript",
            "description": "For all things JavaScript.",
            "body": "",
            "color": "#9AD4E0",
Activity icon

Started a new Conversation JavaScript: How To Filter Array Of Objects Depending To A Specific Property

Hello ,

I want add each element of this array to a related array variable depending to the tags.id.

for example : if tags.id == 92 I have to push the complete element to the variable officer

for example : if tags.id == 95 I have to push the complete element to the variable teamLeader

[
  {
    "id": 4,
    "last_name": "joe",
    "first_name": "eric",
    "tags": [
      {
        "id": 95,
        "name": "Team Leader"
      }
    ]
  },
  {
    "id": 3,
    "last_name": "Micheal",
    "first_name": "Fox",
    "tags": [
      {
        "id": 94,
        "name": "BU Director"
      },
      {
        "id": 100,
        "name": "CCM"
      },
      {
        "id": 92,
        "name": "Chief Officer"
      },
      {
        "id": 93,
        "name": "HR Responsible"
      },
      {
        "id": 98,
        "name": "IT Admin"
      },
      {
        "id": 97,
        "name": "Master Data"
      },
      {
        "id": 96,
        "name": "P&S Responsible"
      },
      {
        "id": 95,
        "name": "Team Leader"
      }
    ]
  }
]

Thanks

Nov
06
2 weeks ago
Activity icon

Started a new Conversation Javascript : How To Convert Checkbox Values From Boolean To String?

Hello ,

I'm looking for a way to convert boolean to string immediately in vuejs template :

<input class="form-control"
                               placeholder="Value"
                               type="checkbox"
                               v-else-if="segments[index].type === 'boolean'"
                               v-model="segments[index].value">

when I check/uncheck this checkbox segments[index].value takes true or false values ad boolean type

But what I'm looking for is to give segments[index].value true or false ad String type not Boolean

Thanks

Nov
05
2 weeks ago
Activity icon

Started a new Conversation How To Use 'whereIn' In A Many To Many Relationship

Hello , first my request is like:

        return $users = User::
        with([
            'groups.permissions' => function ($query) {
                $query->select(['name']);
            },
            'latestLog',
        ])
            ->get();

I want to filter the result bellow and get only results where groups.permissions.name in ['Team Leader', 'IT admin']

The current result of the above request is:

(...)
    "teamleader2_id": null,
    "HasEml": true,
    "should_activated": false,
    "employment_end_date": null,
    "groups": [
      {
        "id": 68,
        "name": "Chief Officers",
        "slug": "chief-officers",
        "created_at": "2020-09-04 17:25:04",
        "updated_at": "2020-09-04 17:25:04",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 68
        },
        "permissions": [
          {
            "name": "Chief Officer",
            "pivot": {
              "group_id": 68,
              "permission_id": 92
            }
          }
        ]
      },
      {
        "id": 71,
        "name": "Team Leaders",
        "slug": "team-leaders",
        "created_at": "2020-09-04 17:26:37",
        "updated_at": "2020-09-04 17:26:37",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 71
        },
        "permissions": [
          {
            "name": "Team Leader",
            "pivot": {
              "group_id": 71,
              "permission_id": 95
            }
          }
        ]
      },
      {
        "id": 76,
        "name": "CCMs",
        "slug": "ccms",
        "created_at": "2020-09-04 17:28:22",
        "updated_at": "2020-09-04 17:28:22",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 76
        },
        "permissions": [
          {
            "name": "CCM",
            "pivot": {
              "group_id": 76,
              "permission_id": 100
            }
          }
        ]
      },
      {
        "id": 70,
        "name": "BU Directors",
        "slug": "bu-directors",
        "created_at": "2020-09-04 17:26:16",
        "updated_at": "2020-09-04 17:26:16",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 70
        },
        "permissions": [
          {
            "name": "BU Director",
            "pivot": {
              "group_id": 70,
              "permission_id": 94
            }
          },
          {
            "name": "HR Responsible",
            "pivot": {
              "group_id": 70,
              "permission_id": 93
            }
          }
        ]
      },
      {
        "id": 69,
        "name": "HR Responsibles",
        "slug": "hr-responsibles",
        "created_at": "2020-09-04 17:25:43",
        "updated_at": "2020-09-04 17:25:43",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 69
        },
        "permissions": [
          {
            "name": "HR Responsible",
            "pivot": {
              "group_id": 69,
              "permission_id": 93
            }
          }
        ]
      },
      {
        "id": 74,
        "name": "IT Admins",
        "slug": "it-admins",
        "created_at": "2020-09-04 17:27:44",
        "updated_at": "2020-09-04 17:27:44",
        "deleted_at": null,
        "pivot": {
          "user_id": 3,
          "group_id": 74
        },
        "permissions": [
          {
            "name": "IT Admin",
            "pivot": {
              "group_id": 74,
              "permission_id": 98
            }
          }
        ]
      },

User model :


    public function groups()
    {
        return $this->belongsToMany(Group::class);
    }

Group model :

    public function users()
    {
        return $this->belongsToMany(User::class);
    }

    public function permissions()
    {
        return $this->belongsToMany(Permission::class);
    }

Permission group :


    public function groups()
    {
        return $this->belongsToMany(Group::class);
    }

````
Nov
04
3 weeks ago
Activity icon

Replied to Javascript : Better To Use Const Or Let In Promises?

@topvillas @bestmomo : one more question please , the result of values is an array like :

(4) [{…}, {…}, {…}, {…}]
0: {data: Array(243), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
1: {data: Array(10), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
2: {data: Array(29), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
3: {data: Array(33), status: 200, statusText: "OK", headers: {…}, config: {…}, …}

Is it possible to add a key to this array , just to know which element in this array is related to which promise ?

Activity icon

Started a new Conversation Javascript : Better To Use Const Or Let In Promises?

Hello :

let URL1 = "https://www.something.com"
let URL2 = "https://www.something1.com"
let URL3 = "https://www.something2.com"

const promise1 = axios.get(URL1);
const promise2 = axios.get(URL2);
const promise3 = axios.get(URL3);

Promise.all([promise1, promise2, promise3]).then(function(values) {
  console.log(values);
});

My question: is it better to make promise1 & promise2 & promise3 let or const?

Activity icon

Started a new Conversation Javascript : How To Keep Only Some Properties Of An Array Of Objects ?

Hello ,

I have this array of objects and I would like to to keep only : home_id and sqft :

[{
            "home_id": "1",
            "price": "925",
            "sqft": "1100",
            "num_of_beds": "2",
            "num_of_baths": "2.0",
        }, {
            "home_id": "2",
            "price": "1425",
            "sqft": "1900",
            "num_of_beds": "4",
            "num_of_baths": "2.5",
        },
        // ... (more homes) ...     
    ]

What I need is :

[{
            "home_id": "1",
            "sqft": "1100",

        }, {
            "home_id": "2",
            "sqft": "1900",

        },
        // ... (more homes) ...     
    ]

I don't know if I need to use Reduce or filter

Thanks

Activity icon

Started a new Conversation Javascript, What's The Best Way To Request Multiple URLs Using Axios?

Hello ,

I have multiple URLS (APIs)

https://my-services.com/api/serv1
https://my-services.com/api/serv2
https://my-services.com/api/serv3
https://my-services.com/api/serv4

I want to call them one by one and once everything is done I want to change the value of ´isLoading´ to false , to activate the Edit button .

I'm thinking about something like :

        axios.get(`https://my-services.com/api/serv1`)
            .then(response => {
		do something ...
            })
            .then(response => {
		axios.get(`https://my-services.com/api/serv2`)
           	.then(response => {
			do something ...
            })
            .then(response => {
		axios.get(`https://my-services.com/api/serv3`)
           	.then(response => {
			do something ...
            })
            .then(response => {
		axios.get(`https://my-services.com/api/serv4`)
           	.then(response => {
			do something ...
            })
            .then(response => {
		this.isLoading = false;
            })
            })
;

but it seems not a clean way to do it ,

Is there another simple and clean way to do it ?

thanks

Nov
03
3 weeks ago
Activity icon

Started a new Conversation JavaScript: How To Convert Today Date Format To Native Date Format ?

Hello ,

I'm wondering how to convert the current date to this format (possible also in moment.js) :

native Date Fri Nov 13 2020 11:28:00 GMT+0100 (Central European Standard Time)

Thanks

Oct
31
3 weeks ago
Activity icon

Replied to Why My Function Doesn't Work When I Pass Event.target.value As A Parameter ?

@godzilaravel Thanks ,

The problem was on the parameter type I convert it to Int() and it works !

Activity icon

Started a new Conversation Why My Function Doesn't Work When I Pass Event.target.value As A Parameter ?

Hello ,

I have a select list , when I change a value I call the function columnChanged(index, $event)

<select @change="columnChanged(index,$event)"

Here the functions I use to filter an array of objects


        columnChanged(index,e) {
          
            console.log(this.searchableProperty(e.target.value));
        },


        searchableProperty(id) {
            return this.columns.searchable_columns.filter(obj => {
                return obj.id === id
            })[0];
        },

The problem is : this.searchableProperty(e.target.value) returns always undefined

BUT: when I put a real value as a parameter it returns me the object I need (it works)

example : console.log(this.searchableProperty(73));

Oct
30
3 weeks ago
Activity icon

Replied to How To Order By Nested Relationship ?

@rodrigo.pedra Thanks

Is it possible to do it without join (Laravel 5.8)?

Activity icon

Started a new Conversation How To Order By Nested Relationship ?

hello ,

the current code is :

return \App\Eml::orderBy('id')->get();

it works :

    "id": 1,
    "user_id": 3,
    "user": {
    "RestrictedView": false,
    "RestrictedEdit": false,
    "user": {
      "id": 3,
      "name": "Tester Test",
      "email": "[email protected]",
(...)
}

eml model

    public function user()
    {
        return $this->belongsTo(User::class);
    }

user model

    public function eml()
    {
        return $this->hasOne(Eml::class);
    }

How to order this result by user name ?

Thanks

Oct
27
4 weeks ago
Activity icon

Replied to VueJS: Data Not Updated After Axios Call.

@wingly

I updated the question ,

The axios is inside one function called getListValue(column,index)

if for example index == 1 this will fill the array listValue [1]

Activity icon

Replied to VueJS: Data Not Updated After Axios Call.

@wingly index is just the index of listValue array example : console.log(this.listValue)

0: (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
1: []
2: (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]

0,1,2 are the index

Activity icon

Started a new Conversation VueJS: Data Not Updated After Axios Call.

Hello,

I set the data of listValue variable with :

(...)
                    <select
                        class="form-control"
                    >
                        <option
                            v-for="value in listValue[index]"
                            value="null">{{ value.name }}</option>

                    </select>
(...)

data() {
        return {
listValue: [],
(...)


 getListValue(column,index) {

axios.get(apiUrl)
                        .then(response => {
                            this.listValue[index] =  libEml.getNamesFromDepartmentApi(response.data);
				console.log(this.listValue);
                        })
(...)

The problem:

When the axios.get is called the list (Template) is not updated ! but the console.log(this.listValue); shows me the new values !!!

But once I change something on this component like input text or other checkbox it works

It's like it is frozen if I don't change anything !

Pleas help

Activity icon

Started a new Conversation Javascript : What's The Difference Between Multiple Instruction In The Same Then() And In Multiple Then()

Hello ,

In Axios i'm wondering what's the difference between putting multiple instructions on one then() :

     
                       (..) }
			).then (response => {
                     	  	makeA();
 				makeB();
				makeC();
                    })

And put each instruction in one specific then() like:

     
                       (..) }
			).then (response => {
                     	  	makeA();
                    })
			.then (response => {
                     	  	makeB();
                    })
			.then (response => {
                     	  	makeC();
                    })

Thanks

Oct
23
1 month ago
Activity icon

Started a new Conversation Javascript: How To Add Property To The Last Array Element ?

Hello ,

I have this array of objects bellow :

let myArary = [
  {
    "id": 1,
    "created_at": null,
    "updated_at": null,
    "code": "Compliance",
    "name": "Compliance",
    "order": 1,
    "deleted_at": null
  },
  {
    "id": 2,
    "created_at": null,
    "updated_at": null,
    "code": "Customer Care",
    "name": "Customer Care",
    "order": 2,
    "deleted_at": null
  },
(...)
]

How to add country property to the last element only ? to have something like :

[
  {
    "id": 1,
    "created_at": null,
    "updated_at": null,
    "code": "Compliance",
    "name": "Compliance",
    "order": 1,
    "deleted_at": null
  },
  {
    "id": 2,
    "created_at": null,
    "updated_at": null,
    "code": "Customer Care",
    "name": "Customer Care",
    "order": 2,
    "deleted_at": null,
    "country": "Ireland"
  },
(...)
]

Thanks

Activity icon

Started a new Conversation JAVASCRIPT: How To Keep Only A Specific Property From An Array Of Object

Hello ,

I would like to keep only name property from the array of object bellow :

[
  {
    "id": 1,
    "created_at": null,
    "updated_at": null,
    "code": "Compliance",
    "name": "Compliance",
    "order": 1,
    "deleted_at": null
  },
  {
    "id": 2,
    "created_at": null,
    "updated_at": null,
    "code": "Customer Care",
    "name": "Customer Care",
    "order": 2,
    "deleted_at": null
  },
(...)
]

to become like :

[
  {
    "name": "Compliance",
  },
  {
    "name": "Customer Care",
  },
(...)
]

Thanks

Oct
22
1 month ago
Activity icon

Started a new Conversation Select List Is Not Updated With The Variable Values

My list does not update its values after ajax call.

<select
                        @change="setValueFromList($event,index)"
                        v-if="newSegment[index].sourceValue && listValue[index]"
                        class="form-control"
                    >
                        <option value="null">Select condition</option>
                        <option
                            v-for="value in listValue[index]"
                            v-bind:value="value.name"
                        > {{ value.name }}</option>
                    </select>

As you can see above I fetch data from a variable listValue[index] v-for="value in listValue[index]"

this variable value is coming from the axios get

axios.get(`api/segment/segment-list/` + selectedColumn.id)
                    .then(response => {
                        this.listValue[index] = response.data;
                    });

the problem is the variable this.listValue[index] is updated with the new values but the Select list is not updated!

But when I change any other value in the for (text or list or checkbox ...) it works and the list shows the values !

Oct
21
1 month ago
Activity icon

Started a new Conversation How To Concatenate Two Two Values From The Same Eloquent Result ?

Hello

here the result of my request :

$searchableColumn =  SearchableColumn::where('id','=',$id)
             ->with('searchableTable')
             ->first();

result is :

{
  "id": 57,
  "name": "gender",
  "type": "string_list",
  "searchable_table_id": 5,
  "created_at": "2020-10-20 10:08:46",
  "updated_at": "2020-10-20 10:08:45",
  "label": "Gender",
  "is_protected": false,
  "searchable_table": {
    "id": 5,
    "name": "emls",
    "created_at": "2020-07-16 16:24:00",
    "updated_at": "2020-07-16 16:24:00"
  }
}

I'm wondering if it's possible return the concat of name with searchable_table->name directly from the Eloquent

something like I did with this line :

return $searchableColumn->name.'-'.$searchableColumn->searchableTable->name;

Thanks

Oct
20
1 month ago
Activity icon

Started a new Conversation How To Use Collections-> Forget() Without Adding Extra Key ?

Hello

My actual result of return $search->columns;

is like :

[
  {
    "id": 52,
    "name": "one"
  },
  {
    "id": 54,
    "name": "two"
  },
  {
    "id": 9,
    "name": "tree"
  },
  {
    "id": 25,
    "name": "four"
  },

when I use forget() return $search->Columns->forget(2); it returns an object like:

{
  "0": {
    "id": 52,
    "name": "one"
  },
  "1": {
    "id": 54,
    "name": "two"
  },
  "3": {
    "id": 25,
    "name": "four"
  }

How to use forget() (or alternative of forget()) to avoid the keys : "0", "1", "3" and have an array result like :

[
  {
    "id": 52,
    "name": "one"
  },
  {
    "id": 54,
    "name": "two"
  },
  {
    "id": 25,
    "name": "four"
  },
]

Thanks

Activity icon

Replied to How To Reset The IDs In An Object ?

@sinnbeck it's from a collection

Activity icon

Replied to How To Reset The IDs In An Object ?

@tykus I changed the content of my question please take a look

It's not generated from a specific request (eloquent) I just want to reformat this variable .

Activity icon

Started a new Conversation How To Reset The IDs In An Object ?

Hello ,

I want to reset the IDs in one object :

    "95981": {
      "id": 52,
      "city": "NY",
    },
    "6583": {
      "id": 54,
      "city": "FL",
    },
    "56665": {
      "id": 47,
      "city": "IL",
    },
(...)

To become like output :

    "0": {
      "id": 52,
      "city": "NY",
    },
    "1": {
      "id": 54,
      "city": "FL",
    },
    "2": {
      "id": 47,
      "city": "IL",
    },
(...)

Thanks