Using .includes on more than one aspect of a prop in Vue to build a search

  laravel, search, vue.js

I’m trying to create a very basic fuzzy search that uses the values of an object in props. The below search works fine, but only checks for speciality.name

How would I modify this to allow for it to check not only candidate.speciality.name but other values from inside candidate? i.e. how would I go about letting check for example candiate.firstname and candidate.speciality ?
Script

    export default {
    props: ['profiles'],

    data() {
        return {
            search: ''
        }
        
    },

    computed: {
        filteredList() {
        return this.profiles.filter(candidate => {
            return candidate.speciality.name.toLowerCase().includes(this.search.toLowerCase())
        })
        }
    }

}

Template

<template>

<div>

    <input type="text" v-model="search">

    <div v-for="candidate in filteredList" :key="candidate.id">

        <admin-profile-entry :candidate="candidate" :speciality="candidate.speciality.name"></admin-profile-entry>

    </div>

</div>

Thanks in advance.

Source: Laravel

Leave a Reply