How do I display all the products attribute inside the user object - laravel

Pardon me, cause I was just using this StackOverflow account...
So for this one what I want is 2 list all the product brands for a specific user, so for this one I had it like
So the user object would look like {name:'Andy','last_name':'Lee' .... brands : {} }
<div class="w-full flex">
<label for="name" class="block uppercase tracking-wide text-black-v2 text-xs font-bold mb-2">List all the Attributes
</label>
<span>
<i class="fas fa-plus-circle h-4 w-4 text-grey-darker" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
<div class="w-full flex inline-block" v-for="(input,k) in inputs" :key="k">
<!-- if there's no products for this person -->
<div v-if="user.products.length === 0" class="flex inline-block w-full">
<select v-model="inputs.crime_id" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal">
<option v-for="products in products">{{ products.brand }} </option>
</select>
<div id="input-group" class="ml-4 w-3/5">
<input type="text" v-model="inputs.name" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal" id="pin" name="pin" autocomplete="name" placeholder="Attribute Details" required>
</div>
<span>
<i class="fas fa-minus-circle" #click="remove(k)" v-show="k || ( !k && inputs.length > 1)">
</i>
<i class="fas fa-plus-circle" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
<div class="w-full inline-block" v-else>
<div v-for="products in user.products">
<!-- <p>{{ products.brand }} </p> -->
<div class="flex inline-block">
<select class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal">
<option v-for="products in products">{{ products.brand }} </option>
</select>
<div class="flex inline-block">
<div id="input-group" class="ml-4 w-3/5">
<input type="text" :value="user.profile.weight_in_kilos" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal" id="pin" name="pin" autocomplete="name" placeholder="Crime Details" required>
</div>
<span class="mr-2">
<i class="fas fa-minus-circle" #click="remove(k)" v-show="k || ( !k && inputs.length > 1)">
</i>
<i class="fas fa-plus-circle" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
</div>
</div>
</div>
</div>
So looking at the code that I have, I want to display all the brands / attributes in case of this one into something that's working since it's not working on my end. You can send me a chat thru Skype or Discord, whatever you say I'll use it.. Cause I need some help

Related

Method not supporting error:405 in SpringBoot application

I am new to SpringBoot thymeleaf , I simple just make a registration
page ,but when I fill the registration details and hit the register
button in my registration page it throw below error
SignUpPage.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" th:href="#{/../css/SignUp.css}">
<title>SIGN UP</title>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script crossorigin="anonymous" src="https://kit.fontawesome.com/16e8cf656f.js"></script>
<script type="text/javascript" th:src="#{/js/SignUp.js}"></script>
</head>
<body>
<div class="container">
<div class="row py-5 mt-4 align-items-center">
<!-- For Demo Purpose -->
<div class="col-md-5 pr-lg-5 mb-5 mb-md-0">
<img src="https://bootstrapious.com/i/snippets/sn-registeration/illustration.svg" alt="" class="img-fluid mb-3 d-none d-md-block">
<h1>Create an Account</h1>
<p class="font-italic text-muted mb-0">Create an account to enjoy some services freely.</p>
</p>
</div>
<!-- Registeration Form -->
<div class="col-md-7 col-lg-6 ml-auto">
<form action="#" th:action="#{/saveUser}" th:object="${player}">
<div class="row">
<!-- First Name -->
<div class="input-group col-lg-6 mb-4">
<div class="input-group-prepend">
<span class="input-group-text bg-white px-4 border-md border-right-0">
<i class="fa fa-user text-muted"></i>
</span>
</div>
<label for="firstName"></label><input id="firstName" type="text" th:field="*{firstName}" name="firstname" placeholder="First Name" class="form-control bg-white border-left-0 border-md">
</div>
<!-- Last Name -->
<div class="input-group col-lg-6 mb-4">
<div class="input-group-prepend">
<span class="input-group-text bg-white px-4 border-md border-right-0">
<i class="fa fa-user text-muted"></i>
</span>
</div>
<label for="lastName"></label><input id="lastName" type="text" name="lastname" th:field="*{lastName}" placeholder="Last Name" class="form-control bg-white border-left-0 border-md">
</div>
<!-- Phone Number -->
<div class="input-group col-lg-12 mb-4">
<div class="input-group-prepend">
<span class="input-group-text bg-white px-4 border-md border-right-0">
<i class="fa fa-phone-square text-muted"></i>
</span>
</div>
<label for="countryCode"></label><select id="countryCode" name="countryCode" style="max-width: 80px" class="custom-select form-control bg-white border-left-0 border-md h-100 font-weight-bold text-muted">
<option value="">+91</option>
<option value="">+972</option>
<option value="">+353</option>
<option value="">+39</option>
<option value="">+254</option>
<option value="">+852</option>
<option value="">+49</option>
</select>
<label for="phoneNumber"></label><input id="phoneNumber" type="tel" name="phone" th:field="*{phoneNumber}" placeholder="Phone Number" class="form-control bg-white border-md border-left-0 pl-3">
</div>.
<!-- Email Address -->
<div class="input-group col-lg-12 mb-4">
<div class="input-group-prepend">
<span class="input-group-text bg-white px-4 border-md border-right-0">
<i class="fa fa-envelope text-muted"></i>
</span>
</div>
<label for="email"></label><input id="email" type="email" name="email" th:field="*{email}" placeholder="Email Address" class="form-control bg-white border-left-0 border-md">
</div>
<!-- Password -->
<div class="input-group col-lg-6 mb-4">
<div class="input-group-prepend">
<span class="input-group-text bg-white px-4 border-md border-right-0">
<i class="fa fa-lock text-muted"></i>
</span>
</div>
<label for="password"></label><input id="password" type="password" name="password" th:field="*{password}" placeholder="Password" class="form-control bg-white border-left-0 border-md">
</div>
<!-- Submit Button -->
<div class="d-flex justify-content-center mx-4 mb-3 mb-lg-4">
<input class="btn btn-primary btn-lg" type="submit" value="Create Account" />
</div>
<!-- Divider Text -->
<div class="form-group col-lg-12 mx-auto d-flex align-items-center my-4">
<div class="border-bottom w-100 ml-5"></div>
<span class="px-2 small text-muted font-weight-bold text-muted">OR</span>
<div class="border-bottom w-100 mr-5"></div>
</div>
<!-- Social Login -->
<div class="form-group col-lg-12 mx-auto">
<a href="#" class="btn btn-primary btn-block py-2 btn-facebook">
<i class="fa fa-facebook-f mr-2"></i>
<span class="font-weight-bold">Continue with Facebook</span>
</a>
<a href="#" class="btn btn-primary btn-block py-2 btn-twitter">
<i class="fa fa-twitter mr-2"></i>
<span class="font-weight-bold">Continue with Twitter</span>
</a>
</div>
<!-- Already Registered -->
<div class="text-center w-100">
<p class="text-muted font-weight-bold">Already Registered? <a th:href="#{/login}" href="#" class="text-primary ml-2">Login</a></p>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Controller class
package com.nilmani.herokudemoapplication.controller
import com.nilmani.herokudemoapplication.entity.Player
import com.nilmani.herokudemoapplication.repository.PlayerRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.*
#Controller
class PlayerController {
#Autowired
private lateinit var playerRepository: PlayerRepository
#GetMapping("/getSignUp")
fun getRegistrationPage(model: Model,player: Player):String{
model.addAttribute("player",Player())
return "SIgnUpPage"
}
/**end point to register the user*/
#PostMapping("/saveUser")
fun registerUser(#ModelAttribute("player")player: Player,model: Model):String{
model.addAttribute("player",Player())
playerRepository.save(player)
return "successPage"
}
}
what is the reason for getting this type of issue
I know error 405 means it not supporting the function,But I define
everything properly ,why my code is not working I do not understand. I
am not able to find my mistakes.
The "/saveUser" endpoint has method POST. The same needs to be reflected in the form element in SignUpPage.html.
<form action="#" th:action="#{/saveUser}" th:object="${player}" th:method="POST">
For more help refer to https://spring.io/guides/gs/handling-form-submission/
Use th:method="POST" while submitting the form to the controller

validation depends on radio button selection laravel

I have different inputs depends on radio buttons. How to validate them according to selection?
<div class="sm:col-span-2">
<div class="mt-4">
<nav class=" " aria-label="Tabs">
<div class="border-gray-300 border-2 rounded-lg pl-3 py-2 w-40" :class="tab == 'tab1' ? ' bg-green-200 border-green-500 ' : ''">
<input type="radio" #click="tab = 'tab1'" checked="tab == 'tab1' ? true: false" name="person_company"> <span class="text-gray-600 font-medium text-sm pl-2">person</span> </input>
</div>
<br>
<div class="border-gray-300 border-2 rounded-lg pl-3 py-2 w-40" :class="tab == 'tab2' ? ' bg-green-200 border-green-500 ' : ' '">
<input type="radio" #click="tab = 'tab2'" name="person_company"> <span class="text-gray-600 font-medium text-sm pl-2">company</span> </input>
</div>
</nav>
</div>
</div>
<div class="sm:col-span-2 " x-show="tab == 'tab1'">
<label for="identity_no" class="block text-sm font-medium text-gray-700">Identity</label>
<div class="mt-1">
<input type="text" name="identity_no" id="identity_no" class="block w-full py-4 border-gray-300 rounded-md shadow-sm focus:ring-green-500 focus:border-green-500 sm:text-sm">
</div>
</div>
<div class="sm:col-span-2" x-show="tab == 'tab2'">
<label for="company" class="block text-sm font-medium text-gray-700">Company name</label>
<div class="mt-1">
<input type="text" name="company" id="company" class="block w-full py-4 border-gray-300 rounded-md shadow-sm focus:ring-green-500 focus:border-green-500 sm:text-sm">
</div>
</div>
this code needs both of them that's not what I want
$this->validate($request,[
'identity' => 'required',
'company' => 'required',
]);
You should use jquery to manage it. First of all, you will have to take values to radio inputs. And then apply the required property through jquery condition.
<input type="radio" #click="tab = 'tab1'" checked="tab == 'tab1' ? true: false" name="person_company" value = "tab1"> <span class="text-gray-600 font-medium text-sm pl-2">person</span> </input>
<input type="radio" #click="tab = 'tab2'" name="person_company"> <span class="text-gray-600 font-medium text-sm pl-2" value = "tab2">company</span> </input>
$('input[type=radio][name= person_company]').change(function() {
if (this.value == 'tab1') {
$("#identity_no").prop('required',true);
$("#company").prop('required',false);
}
else if (this.value == 'tab2') {
$("#company").prop('required',true);
$("#identity_no").prop('required',false);
}
});

Getting my toggle to show correctly in laravel livewire

I have a pivot table that links my products and categories together. What I'm trying to do is in my edit page for a product I
have a list of all the categories and each category has a toggle button that will enable or disable that category for that product.
The problem I'm having is that all my categories is set to enabled, but I only have one enabled and the rest is supposed to be disabled
I'm using laravel 8 and livewire
Here is my code
namespace App\Http\Livewire\Products;
use App\Models\Product;
use Livewire\Component;
use App\Models\Category;
class Edit extends Component
{
public Product $product;
public bool $enabled;
public $name;
public $description;
public function mount()
{
$pcPivot = $this->product->categories()->where('product_id', $this->product->id)->exists();
if($pcPivot === true)
{
$this->enabled = true;
}else{
$this->enabled = false;
}
$this->name = $this->product->name;
$this->description = $this->product->description;
}
public function render()
{
$categories = Category::all();
return view('livewire.products.edit', [
'categories' => $categories,
]);
}
}
and here is my edit.blade.php
<div>
<div class="md:grid md:grid-cols-3 md:gap-6">
<div class="md:col-span-1">
<div class="px-4 sm:px-0">
<h3 class="text-lg font-medium leading-6 text-gray-900">Edit Product</h3>
</div>
</div>
<div class="mt-5 md:mt-0 md:col-span-2">
<div class="shadow sm:rounded-md sm:overflow-hidden">
<form wire:submit.prevent="submit">
<div class="px-4 py-5 bg-white sm:p-6">
<div class="grid grid-cols-3 gap-6">
<div class="col-span-3 sm:col-span-2">
<label for="title" class="block text-sm font-medium leading-5 text-gray-700">
Name
</label>
<div class="rounded-md shadow-sm">
<input id="name" wire:model="product.name" class="flex-1 form-input block w-full min-w-0 transition duration-150 ease-in-out sm:text-sm sm:leading-5">
</div>
</div>
</div>
</div>
<div class="px-4 py-5 bg-white sm:p-6">
<div class="grid grid-cols-3 gap-6">
<div class="col-span-3 sm:col-span-2">
<label for="description" class="block text-sm font-medium leading-5 text-gray-700">
Description
</label>
<div class="rounded-md shadow-sm">
<textarea id="description" wire:model="product.description" rows="3" class="form-textarea mt-1 block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5"></textarea>
</div>
</div>
</div>
</div>
<div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
<span class="inline-flex rounded-md shadow-sm">
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent text-sm leading-5 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo active:bg-indigo-700 transition duration-150 ease-in-out">
Update
</button>
</span>
</div>
</form>
</div>
</div>
</div>
#include('spacer')
<div class="md:grid md:grid-cols-3 md:gap-6">
<div class="md:col-span-1">
<div class="px-4 sm:px-0">
<h3 class="text-lg font-medium leading-6 text-gray-900">Categories</h3>
</div>
</div>
<div class="mt-5 md:mt-0 md:col-span-2">
<div class="shadow sm:rounded-md sm:overflow-hidden">
<table class="min-w-full divide-y divide-gray-200">
<thead>
<tr>
<x-th>Title</x-th>
<x-th>Enable/Disable</x-th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
#foreach($categories as $category)
<tr>
<td class="px-6 py-4 whitespace-no-wrap">
<div class="flex items-center">
<div class="text-sm font-medium text-gray-900">
{{ $category->title }}
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-no-wrap">
<div class="mt-1 flex rounded-md">
<span role="checkbox" tabindex="0" aria-checked="false" class="#if($enabled) bg-indigo-600 #else bg-gray-200 #endif relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:shadow-outline">
<span aria-hidden="true" class="#if($enabled) translate-x-5 #else translate-x-0 #endif inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200">
<input id="enabled" type="checkbox" wire:model="enabled" class="invisible">
</span>
</span>
</div>
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
If you check the documentation for Livewire, at lifecycle hooks... you will see that:
mount : Runs once, immediately after the component is instantiated, but before render() is called
So basically you are getting an "enabled" value once, before rendering the component,then you start rendering it, with that foreach, using the same "enabled" from mount for each item of your dataset.
Consider building your cursor with the enabled value inside for each record.

How do I accept passed props and display them in a dropdown and store them in data

I need some guidance and your tips would be greatly appreciated..
I have passed props like this
so I accepted them in my EditCriminal.vue
props : ['crimes','criminal','admins','countries'],
So what I want is to put those crimes or type of crimes there in the dropdown array and while selecting the specific crime_id and display the criminal description on the side too.
<div class="w-full flex">
<label for="name" class="block uppercase tracking-wide text-black-v2 text-xs font-bold mb-2">List all the Crimes
</label>
<span>
<i class="fas fa-plus-circle h-4 w-4 text-grey-darker" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
<div class="w-full flex inline-block" v-for="(input,k) in inputs" :key="k">
<!-- if there's no crimes for this person -->
<div v-if="criminal.crimes.length === 0" class="flex inline-block w-full">
<select v-model="inputs.crime_id" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal">
<option v-for="crimes in crimes">{{ crimes.criminal_offense }} </option>
</select>
<div id="input-group" class="ml-4 w-3/5">
<input type="text" v-model="inputs.name" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal" id="pin" name="pin" autocomplete="name" placeholder="Attribute Details" required>
</div>
<span>
<i class="fas fa-minus-circle" #click="remove(k)" v-show="k || ( !k && inputs.length > 1)">
</i>
<i class="fas fa-plus-circle" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
<div class="w-full inline-block" v-else>
<div v-for="crimes in criminal.crimes">
<!-- <p>{{ crimes.criminal_offense }} </p> -->
<div class="flex inline-block">
<select class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal">
<option v-for="crimes in crimes">{{ crimes.criminal_offense }} </option>
</select>
<div class="flex inline-block">
<div id="input-group" class="ml-4 w-3/5">
<input type="text" class="hover:bg-grey-lightest bg-grey-lighter w-full mb-2 p-2 leading-normal" id="pin" name="pin" autocomplete="name" placeholder="Crime Details" required>
</div>
<span>
<i class="fas fa-minus-circle" #click="remove(k)" v-show="k || ( !k && inputs.length > 1)">
</i>
<i class="fas fa-plus-circle" #click="add(k)" v-show="k == inputs.length-1">
</i>
</span>
</div>
</div>
</div>
</div>
</div>
so this is the UI
this is in my data object..
data(){
return {
inputs: [
{
crime_id : 0,
name: ''
}
],
country : this.criminal.country_id,
form : {
birthplace : "",
status : 0,
maxFiles: 1,
complete_description : this.criminal.profile.complete_description,
currency : 1,
placeholder: "Well..",
alias : "",
bounty : "",
last_seen : "",
contact_person : api.user.id ,
criminals_name : "",
// contact_number : api.user.phone_number ,
contact_number : "",
attachments : [],
country_id : 4 ,
uploadUrl: urls.urlSaveCriminal,
},
posted_by : this.criminal.posted_by,
max_files: { // total # of files allowed to be uploaded
type: Number,
required: false,
default: 10
}

How to update v-model data in laravel blade file in edit form

I have a single file for creating and updating the category data.
while creating category, i am using v-model in title to also create slug in the same form.
works well when creating but i am facing issue with update / edit form part.
below is my code :
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug" placeholder="Category Title" value="{{ $category->name ?? '' }}">
adding whole blade file code for reference:
#extends('layouts.backend.app')
#php
if(isset($record) && $record != null){
$edit = 1;
} else {
$edit = 0;
}
#endphp
#section('content')
<section id="app" class="container mx-auto">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold">
#if($edit) Edit #else Create #endif Category Form
</h1>
Back
</div>
<div class="border rounded mt-8 p-8">
<form action="#if($edit) {{route('category.update', $record->id)}} #else {{route('category.store')}} #endif" method="POST">
#csrf
<label class="block mb-4">
<span class="text-gray-700 font-bold">Name</span>
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug" placeholder="Category Title" value="{{ $category->name ?? '' }}">
#error('name')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-4">
<span class="text-gray-700 font-bold">Slug</span>
<input
class="form-input mt-1 block w-full"
name="slug"
id="slug"
v-model="slug"
placeholder="Slug / Pretty URL">
#error('slug')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-8">
<span class="text-gray-700 font-bold">Banner</span>
<input
class="form-input mt-1 block w-full"
name="banner"
value="#if($edit) {{$record->banner}} #else https://source.unsplash.com/random #endif"
placeholder="Banner / URL">
</label>
<div class="flex justify-between">
<button class="px-4 py-2 border bg-gray-200 text-gray-900 rounded" type="submit">Submit</button>
<button class="px-4 py-2 border bg-red-400 text-white rounded" type="rest">Reset</button>
</div>
</form>
</div>
</section>
#endsection
as you can see the title input is use to create the slug on keyup event. now the given code don't use the data from database for pre populating the edit form title input field. because i am using v-model="title" which is in my app.js and is null at the moment.
How to either assign v-model="title" my current value from database.
This is not a vue component. its a laravel blade file. Kindly guide me for this.
Thanks
You can move the app.js code to the Blade view and populate title with the Blade expression
#extends('layouts.backend.app')
#php
if(isset($record) && $record != null){
$edit = 1;
} else {
$edit = 0;
}
#endphp
#section('content')
<section id="app" class="container mx-auto">
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold">
#if($edit) Edit #else Create #endif Category Form
</h1>
Back
</div>
<div class="border rounded mt-8 p-8">
<form action="#if($edit) {{route('category.update', $record->id)}} #else {{route('category.store')}} #endif"
method="POST">
#csrf
<label class="block mb-4">
<span class="text-gray-700 font-bold">Name</span>
<input class="form-input mt-1 block w-full" name="name" v-model="title" v-on:keyup="getSlug"
placeholder="Category Title" value="{{ $category->name ?? '' }}">
#error('name')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-4">
<span class="text-gray-700 font-bold">Slug</span>
<input class="form-input mt-1 block w-full" name="slug" id="slug" v-model="slug"
placeholder="Slug / Pretty URL">
#error('slug')
<span class=" text-red-400 invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</label>
<label class="block mb-8">
<span class="text-gray-700 font-bold">Banner</span>
<input class="form-input mt-1 block w-full" name="banner"
value="#if($edit) {{$record->banner}} #else https://source.unsplash.com/random #endif"
placeholder="Banner / URL">
</label>
<div class="flex justify-between">
<button class="px-4 py-2 border bg-gray-200 text-gray-900 rounded" type="submit">Submit</button>
<button class="px-4 py-2 border bg-red-400 text-white rounded" type="rest">Reset</button>
</div>
</form>
</div>
</section>
{{-- Place the script here, after closing the section with id of app --}}
<script>
const app = new Vue({
el: '#app',
data() {
return {
title: '{{ $category->name }}'
}
},
methods: {
getSlug() {
this.title = this.title.toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'');
}
}
});
</script>
#endsection
Hope this helps
In The End, I went back to the old style of doing things.
code as below:
getSlug() {
var title = document.getElementById('title').value;
document.getElementById('slug').value = title.replace(/\s+/g, '-').toLowerCase().trim();
},
and replaced v-model with id tag on the input field.

Resources