[Vuejs]-Avoid deleting parent table data while it is being used in child table

0👍

finally after 3 days I found the solution

del(id) {
      swal
        .fire({
          title: "Are you sure?",
          text: "You won't be able to revert this!",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#3085d6",
          cancelButtonColor: "#d33",
          confirmButtonText: "Yes, delete it!"
        })
        .then(result => {
          //Send request to the server
          if (result.value) {
            this.form
              .delete("api/nationality/" + id)
              .then(() => {
                swal.fire("Deleted!", "Your file has been deleted.", "success");
                Fire.$emit("refreshPage");
              })
              .catch(e => {
                console.log(e);
              });
          }
        });
},
deleteNationality(id) {
      this.data.forEach(element => {
        this.employees2.push(element.nationality_id);
        if (this.employees2.includes(id)) {
          toast.fire({
            type: "warning",
            title:
              " You Couldn't delete this Nationality because it is being used by employee"
          });
        } else {
          this.del(id);
        }

      });
    },

Leave a comment