<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joney Spark</title>
    <description>The latest articles on DEV Community by Joney Spark (@joneyspark).</description>
    <link>https://dev.to/joneyspark</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F429761%2F2bd97dac-7804-4197-9d37-a6e2e62b8819.jpeg</url>
      <title>DEV Community: Joney Spark</title>
      <link>https://dev.to/joneyspark</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joneyspark"/>
    <language>en</language>
    <item>
      <title>How to show Array of errors in Vue.js ? Backend Validation with Laravel Help plz ?</title>
      <dc:creator>Joney Spark</dc:creator>
      <pubDate>Fri, 26 Mar 2021 10:15:56 +0000</pubDate>
      <link>https://dev.to/joneyspark/how-to-show-array-of-errors-in-vue-js-backend-validation-with-laravel-help-plz-1jjc</link>
      <guid>https://dev.to/joneyspark/how-to-show-array-of-errors-in-vue-js-backend-validation-with-laravel-help-plz-1jjc</guid>
      <description>&lt;p&gt;Hi, I have some complex data and I want to show the validation error array data in vue file but I can not because I have got some data that has index please share your opinion &lt;/p&gt;

&lt;p&gt;vue file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;form enctype="multipart/form-data" @submit.prevent="handleSubmit"&amp;gt;
      &amp;lt;div v-for="(contact, index) in contacts" :key="index" class="row"&amp;gt;
        &amp;lt;div class="col col-md-3"&amp;gt;
          &amp;lt;div class="form-group mb-4"&amp;gt;
            &amp;lt;label for="personName"&amp;gt;Contact Person Name&amp;lt;/label&amp;gt;
            &amp;lt;input
              id="personName"
              v-model="contact.name"
              type="text"
              class="form-control"
            /&amp;gt;
            &amp;lt;small&amp;gt; Want to show here the error ? &amp;lt;/small
            &amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;!-- Add or Remove button --&amp;gt;

        &amp;lt;div class="col col-md-12 text-right"&amp;gt;
          &amp;lt;div class="row ml-4"&amp;gt;
            &amp;lt;div v-show="index == contacts.length - 1"&amp;gt;
              &amp;lt;button
                class="btn btn-warning mb-2 mr-2 btn-rounded"
                @click.prevent="add"
              &amp;gt;
                Add More
              &amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div v-show="index || (!index &amp;amp;&amp;amp; contacts.length &amp;gt; 1)"&amp;gt;
              &amp;lt;button
                class="btn btn-danger mb-2 mr-2 btn-rounded"
                @click.prevent="remove"
              &amp;gt;
                Remove
              &amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
export default {
  data() {
    return {
      contacts: [
        {
          name: "",
        },
      ],

      errors: [],
    };
  },
  methods: {
    handleSubmit() {
      let data = new FormData();
      data.append("contacts", JSON.stringify(this.contacts));

      Request.POST_REQ(data, "/add-institute")
        .then(() =&amp;gt; {
          alert("success");
        })
        .catch((err) =&amp;gt; {
          this.errors = err.response.data.errors;
        });
    },
    add() {
      this.contacts.push({
        name: "",
        email: "",
        phone: "",
        alternate_phone: "",
      });
    },
    remove(index) {
      this.contacts.splice(index, 1);
    },
  },
};
&amp;lt;/script&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;controller file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public function add_institute(Request $request) {
  $request['contacts'] = json_decode($request['contacts'], true);
  $request-&amp;gt;validate([
      'contacts.*.name'=&amp;gt; 'unique:institute_contact_people|distinct',
  ]);

  ...rest of code of insert 

  return response()-&amp;gt;json("Success...");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Getting Response data&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;errors: {
  contacts.0.name: ["The contacts.0.name has already been taken.", "The contacts.0.name field has a duplicate value."]
  0: "The contacts.0.name has already been taken."
  contacts.1.name: ["The contacts.1.name has already been taken.", "The contacts.1.name field has a duplicate value."]
  0: "The contacts.1.name has already been taken."
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How can I pass multiple data or props using the Router &lt;Link to = "..."&gt; parameter?</title>
      <dc:creator>Joney Spark</dc:creator>
      <pubDate>Fri, 11 Sep 2020 16:10:27 +0000</pubDate>
      <link>https://dev.to/joneyspark/how-can-i-pass-multiple-data-or-props-using-the-router-link-to-parameter-540e</link>
      <guid>https://dev.to/joneyspark/how-can-i-pass-multiple-data-or-props-using-the-router-link-to-parameter-540e</guid>
      <description>&lt;p&gt;How can I pass multiple data or props using the Router  parameter? Then how I can receive the data? Example plz ? in React.js&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>how to push a array element in a single array object in react.js ? Help Plz</title>
      <dc:creator>Joney Spark</dc:creator>
      <pubDate>Sun, 06 Sep 2020 09:45:44 +0000</pubDate>
      <link>https://dev.to/joneyspark/how-to-push-a-array-element-in-a-single-array-object-in-react-js-4and</link>
      <guid>https://dev.to/joneyspark/how-to-push-a-array-element-in-a-single-array-object-in-react-js-4and</guid>
      <description>&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let {postDetail} = useParams();
    const url = `https://jsonplaceholder.typicode.com/posts/${postDetail}`;
    const [details, setDetails] = useState([]);
    useEffect(()=&amp;gt;{
        fetch(url)
        .then(res =&amp;gt; res.json())
        .then(data =&amp;gt; {
            setDetails(data =&amp;gt; [...data, {"image":`${data.id}`}]);
        })

    },[]);

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>react</category>
    </item>
    <item>
      <title>After Pushing a Array Element in react.js it's looping infinitely in useEffect. Help plz</title>
      <dc:creator>Joney Spark</dc:creator>
      <pubDate>Sat, 05 Sep 2020 19:15:22 +0000</pubDate>
      <link>https://dev.to/joneyspark/after-pushing-a-array-element-in-react-js-it-s-looping-infinitely-in-useeffect-3k4l</link>
      <guid>https://dev.to/joneyspark/after-pushing-a-array-element-in-react-js-it-s-looping-infinitely-in-useeffect-3k4l</guid>
      <description>&lt;p&gt;I have pushed some image elements in object array it's working fine but how to update the state?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const url = "https://jsonplaceholder.typicode.com/posts";
        const [posts, setPosts] = useState([]);

        const postsMap = posts.map(post =&amp;gt; {
            return {...post, "image": `image-${post.id}.jpg`}
        })

        console.log("Added Post Image", postsMap);

        useEffect(()=&amp;gt;{
            fetch(url)
            .then(res =&amp;gt; res.json())
            .then(data =&amp;gt; {
                setPosts(data)
                console.log(data);
            })

        }, [postsMap]);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>react</category>
    </item>
  </channel>
</rss>
