POST http://127.0.0.1:8000/ 422 (Unprocessable Content) - laravel

I have an error on login form after upgrading version Vue JS, Axios, Laravel.
This project code working well with old version. Anyone can explain this serious errors.
Thanks you for your help!
And I stuck with it many days. I've search for similar post error, but only seen this(POST http://127.0.0.1:8000/ 422 (Unprocessable Entity)).
<template>
<div class="back-img" :style="`background-image: url('${appUrl}/images/background/default-background.jpg')`">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-6 offset-md-6 col-lg-4 offset-lg-8 col-xl-4 offset-xl-8 pl-0">
<div class="sign-in-sign-up-content">
<form class="sign-in-sign-up-form">
<div class="text-center mb-4 application-logo">
<img :src="publicPath+'/uploads/logo/'+appLogo" alt="" class="img-fluid logo">
</div>
<div class="form-row">
<div class="form-group col-12">
<h3 class="text-center mb-0">
{{ trans('lang.hi_there') }}
</h3><br>
<label class="text-center d-block">
{{ trans('lang.sign_in_to_your_dashboard') }}
</label>
</div>
</div>
<div v-if="alertMessage.length>0" class="alertBranch">
<div class="alert alert-warning alertBranch" role="alert">
{{alertMessage}}
</div>
</div><br>
<div class="form-row">
<div class="form-group col-12">
<label for="username" style="font-size: 20px;"> {{ trans('lang.login_username') }}</label>
<input id="username"
v-validate="'required'"
v-model="username"
type="text"
name="username"
class="form-control"
:placeholder="trans('lang.enter_username')"
:class="{ 'is-invalid': submitted && errors.has('username') }">
<div class="heightError" v-if="submitted && errors.has('username')">
<small class="text-danger" v-show="errors.has('username')">
{{ errors.first('username') }}
</small>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<label for="password" style="font-size: 20px !important;">{{ trans('lang.login_password') }}</label>
<input id="password"
v-validate="'required'"
ref="password"
v-model="password"
name="password"
type="password"
class="form-control"
:placeholder="trans('lang.enter_password')"
:class="{ 'is-invalid': submitted && errors.has('password') }">
<div class="heightError">
<small class="text-danger" v-show="errors.has('password')">
{{ errors.first('password') }}
</small>
</div>
</div>
</div>
<div class="form-row loginButton">
<div class="form-group col-12">
<common-submit-button class="btn-block text-center auth-button"
style="font-size: 20px !important;"
:buttonLoader="buttonLoader"
:isDisabled="isDisabled"
:isActiveText="isActiveText"
buttonText="login"
v-on:submit="loginPost"/>
</div>
</div>
<!-- <div class="form-row">
<div class="form-group col-12">
<a href="#"
#click="forgetPassword"
class="bluish-text">
<i class="fa fa-lock"/>
{{ trans('lang.forgot_password') }}
</a>
</div>
</div> -->
</form>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axiosGetPost from '../../helper/axiosGetPostCommon';
export default {
extends: axiosGetPost,
props: ['checkusername', 'checkpass'],
data() {
return {
username: this.checkusername,
name: '',
password: this.checkpass,
remember: true,
buttonLoader: false,
isActiveText: false,
isDisabled: false,
preLoaderType: 'load',
hidePreLoader: false,
isActive: 'active',
alertMessage: '',
submitted: false,
}
},
methods: {
loginPost() {
this.submitted = true,
this.$validator.validateAll().then((result) => {
if (result) {
this.inputFields = {
username: this.username,
password: this.password,
};
this.buttonLoader = true;
this.isDisabled = true;
this.isActiveText = true;
this.loginPostMethod('/', {
username: this.username,
password: this.password,
}
);
}
});
},
forgetPassword() {
let instance = this;
instance.redirect('/password/reset');
},
loginPostSucces(response) {
let instance = this;
instance.redirect("/sales");
},
loginPostError(response) {
let instance = this;
instance.buttonLoader = false;
instance.isDisabled = false;
instance.isActiveText = false;
instance.alertMessage = response.data.errors.username[0];
},
}
}
</script>
File: resources\assets\js\js\bootstrap.js
window._ = require('lodash');
window.Popper = require('popper.js').default;
import axios from "axios";
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
if (document.querySelector('meta[name="csrf-token"]')) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
}

You have to pass the csrf token in Ajax request.
data: {
"_token": "{{ csrf_token() }}",
other form data
}
OR
You can create csrf token in header using meta element and access that value in while sending ajax request.
<meta name="csrf-token" content="{{ csrf_token() }}" />
// Access in ajax request like below
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
Laravel + Vue + Axios
Laravel has configurd the default token header in resources/js/bootstrap.js
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
So you have to just import axios like.
import axios from 'axios';

Related

Laravel 8 Dynamic Dependent Input

it's been a while since I stuck in this problem. So I want to make a dynamic selection, when I select a nis (student_id) then the column nama (name) is filled with the student name.
Input form
Output i want
method create
public function create()
{
return view('admin.counseling.create', [
'title' => 'Tambah Bimbingan dan Konseling',
'students' => Student::all()
]);
}
create_blade.php
<form action="/admin/counseling/store" method="post" enctype="multipart/form-data">
#csrf
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Nomor Induk Siswa</label>
<select name="nis" required class="form-control" id="nis">
<option value="0" disabled="true" selected="true">-Pilih-</option>
#foreach($students as $student)
<option value="{{$student->id}}">{{$student->nis}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label>Nama</label>
<input type="text" class="form-control" name="name" required />
</div>
</div>
</div>
<div class="row">
<div class="col text-right">
<button
type="submit"
class="btn btn-success px-5"
>
Simpan
</button>
</div>
</div>
</div>
</form>
I have watched and read some questions with similar problems, and yet I still didn't get it
UPDATE
My method in my controller
public function find_nis(Request $request)
{
$data = Student::find($request->id); //Counseling::with('student', 'student.student_class')->where('student_id', $request->id)->first();
return response()->json(['view' => view('admin.counseling.create', ['data' => $data])->render()]);
}
My Ajax in create.blade.php
<script type="text/javascript">
$(document).ready(function (){
$(document).on('change','.student_nis',function () {
var student_id = $(this).val();
var a = $(this).parent();
console.log(student_id);
var op="";
$.ajax({
type : 'GET',
url : '{!! URL::to('find_nis') !!}',
data : 'id=' + student_id,
success:function(data){
console.log(data);
a.find('.student_name').val(data.name);
},
error:function(){
}
});
});
});
</script>
My Route
Route::get('/admin/counseling/find_nis', [CounselingController::class, 'find_nis'])->name('find_nis');
this is output in my browser console when i select nis 1212
i think for getting response from DB without refresh page you should use ajax,
post student_id with ajax to Controller get username from DB and return your view like this:
in your blade:
first you must set this meta tag inside of :
<meta name="csrf-token" content="{{ csrf_token() }}">
then config and post your data with ajax like this:
<script type="text/javascript">
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var studentId = $("input[name=student]").val();
$.ajax({
xhrFields: {withCredentials: true},
type:'POST',
url:"{{ route('getStudentInfo') }}",
data:{studentId:studentId},
success:function(data){
$('html').html(data.view);
}
});
</script>
in your Controller inside of getStudentInfo():
$student = DB::table('user')->find($studen_id);
$username = $student->username;
return response()->json(['view' => view('admin.counseling.create', compact('username'))->render()]);
Here the working solutions
*Route
Route::get('/admin/counseling/find_student', [CounselingController::class, 'find_nis'])->name('find_student');
*Controller
public function create()
{
return view('admin.counseling.create', [
'title' => 'Tambah Bimbingan dan Konseling',
'students' => Student::all(),
'problems' => Problem::all()
]);
}
public function find_nis(Request $request)
{
$student = Student::with('student_class')->findOrFail($request->id);
return response()->json($student);
}
*blade
<div class="container-fluid mt--7">
<div class="mt-8">
<div class="dashboard-content">
<div class="row">
<div class="col-12">
#if ($errors->any())
<div class="alert alert-danger">
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form action="/admin/counseling/store" method="post" enctype="multipart/form-data">
#csrf
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Nomor Induk Siswa</label>
<select name="nis" required class="form-control" id="nis">
<option value="0" disabled="true" selected="true">-Pilih-</option>
#foreach($students as $student)
<option value="{{$student->id}}">{{$student->nis}}</option>
#endforeach
</select>
</div>
<div class="form-group">
<label>Nama</label>
<input type="text" class="form-control" name="student_name" id="student_name" disabled required/>
</div>
<div class="form-group">
<label>Kelas</label>
<input type="text" class="form-control" name="student_class_name" id="student_class" disabled required/>
</div>
<div class="form-group">
<label>Permasalahan</label>
<div class="row">
<div class="col">
#foreach ($problems as $problem)
<div class="form-check">
<input type="checkbox" id="" name="problem_name[]" value="{{ $problem->name }}">
<label class="fs-6 fw-light">{{ $problem->name }}</label>
</div>
#endforeach
</div>
</div>
</div>
<div class="form-group">
<label>Bobot Permasalahan</label>
<select name="priority" required class="form-control" id="nis">
<option value="null" disabled="true" selected="true">-Pilih-</option>
<option value="1">Normal</option>
<option value="3">Penting</option>
<option value="5">Sangat Penting</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col text-right">
<button
type="submit"
class="btn btn-success px-5"
>
Simpan
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
*ajax
<script type="text/javascript">
$(document).ready(function (){
$(document).on('change', '#nis', function() {
var student_id = $(this).val();
var a = $('#student_name').parent();
$.ajax({
type : 'GET',
url : '{{ route('find_student') }}',
data : 'id=' + student_id,
success:function(data){
a.find('#student_name').val(data.name);
},
error:function(){
}
});
});
$(document).on('change', '#nis', function() {
var student_id = $(this).val();
var a = $('#student_class').parent();
$.ajax({
type : 'GET',
url : '{{ route('find_student') }}',
data : 'id=' + student_id,
success:function(data){
a.find('#student_class').val(data.student_class.name);
},
error:function(){
}
});
});
});
</script>

Uncaught (in promise) Error: Request failed with status code 405 VUEJS

so i'm trying to consume an api form laravel via vue.js this is the login page were i did call axios.post :
<template>
<main>
<section class="login-content">
<div class="container h-100">
<div
class="row align-items-center justify-content-center h-100"
>
<div class="col-12">
<div class="row align-items-center">
<div class="col-lg-6">
<h2 class="mb-2">Sign In</h2>
<p>
To Keep connected with us please login with
your personal info.
</p>
<form>
<div class="row">
<div class="col-lg-12">
<div
class="floating-label form-group"
>
<input
class="floating-input form-control"
type="email"
v-model="data.email"
placeholder=" "
/>
<label>Email</label>
</div>
</div>
<div class="col-lg-12">
<div
class="floating-label form-group"
>
<input
class="floating-input form-control"
type="password"
v-model="data.password"
placeholder=" "
/>
<label>Password</label>
</div>
</div>
<div class="col-lg-6">
<div
class="custom-control custom-checkbox mb-3"
>
<input
type="checkbox"
class="custom-control-input"
id="customCheck1"
/>
<label
class="custom-control-label"
for="customCheck1"
>Remember Me</label
>
</div>
</div>
<div class="col-lg-6">
<a
href="auth-recoverpw.html"
class="text-primary float-right"
>Forgot Password?</a
>
</div>
</div>
<button
type="sumbit"
class="btn btn-primary"
#click="login" :disabled="isLogging" :loading="isLogging"
>
Sign In
</button>
<p class="mt-3">
Create an Account
<router-link to="/" exact
>Sign Up</router-link
>
</p>
</form>
</div>
<div class="col-lg-6 mb-lg-0 mb-4 mt-lg-0 mt-4">
<img
src=" asset (html/assets/images/login/01.png)"
class="img-fluid w-80"
alt=""
/>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
</template>
<script>
export default {
data() {
return {
data: {
email: "",
password: ""
},
isLogging: false
};
},
methods: {
async login() {
if (this.data.email == "") return alert("Email is required")
if (this.data.password == "") return alert("Password is required")
/* if(this.data.password.length<6) return this.e ('Incorrect') */
this.isLogging = true
const axios = require('axios')
const headers = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Method": "POST",
"Content-Type": "application/json",
}
axios.post('http://127.0.0.1:8000/?#/login/',{
email: this.email, password: this.password
}, headers)
.then((response)=>{
const data=response.data;
console.log(data);
})
this.isLogging = false
}
},
mounted() {
console.log("Component mounted.");
}
};
</script>
the step of confirmation : email and password are working well but i got the error when i press the button
and this is the login page as u can see : this is the login page as u can see
i was follwing this tuto but like always i had error unlike the man in the tuto this is the link of the tuto
and this is the route :
Route::post('login', 'App\Http\Controllers\Api\AuthController#login');

pass the value of a uploaded file photo in vuejs and Laravel

I want to upload my photo and pass the value to the laravel. I have this edit profile which my photo be uploaded. Now my problem is how will i able to pass the value of the photo to axios. Here is my code below
<template>
<div class="card">
<div class="card-header">Profile Form</div>
<div class="card-body">
<div class="container">
<div class="row">
<div class="col-sm">
<div v-show="updatePP" id="preview">
<img v-if="url" :src="url" />
</div>
<div v-show="pp" v-if="editProfile.profile_pic == NULL">
<img src="https://i.imgflip.com/4/d0tb7.jpg" />
</div>
<div v-else>
asasasas
</div>
</div>
<div class="col-sm">
<form #submit.prevent="formSubmit" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row" >
<div class="col-lg-12">
<label>First Name:</label>
<br>
<input type="text" id="name" name="name" class="form-control" v-model="editProfile.name" />
</div>
<div class="col-lg-12">
<label>Last Name:</label>
<br>
<input type="text" id="lastName" name="lastName" class="form-control" v-model="editProfile.last_name" />
</div>
<div class="col-lg-12">
<label>Address:</label>
<br>
<input type="text" id="address" name="address" class="form-control" v-model="editProfile.address" />
</div>
<div class="col-lg-12">
<label>Upload Profile:</label>
<br>
<input type="file" id="photo" name="photo" #change="onFileChange" />
</div>
<div class="col-lg-12">
<br>
<br>
<button type="submit" class="btn btn-success btn-lg">Update</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data(){
return{
editProfile:{
userId: this.$userId,
},
url: null,
pp: true,
updatePP: false,
userId:this.$userId,
}
},
mounted(){
const url = window.location.href;
const id = url.split("/").slice(4)[0];
this.getEditProfile(id);
},
methods:{
onFileChange(e){
const file = e.target.files[0];
this.url = URL.createObjectURL(file);
this.editProfile.photo = file;
this.updatePP = true;
this.pp = false;
},
formSubmit(){
const ids = this.userId;
let currentObj = this;
alert(this.editProfile.name);
alert(this.editProfile.last_name);
alert(this.editProfile.address);
alert(this.editProfile.photo.name);
let formData = new FormData();
formData.append('photo', this.editProfile.photo.name);
formData.append('name', this.editProfile.name);
formData.append('lastName', this.editProfile.last_name);
formData.append('address', this.editProfile.address);
console.log(formData.values);
axios.put(`/api/profile/${ids}/update`, this.editProfile).then(response=>{
console.log(response.data);
currentObj.success = response.data.success;
}).catch(error=>{
console.log(error);
currentObj.output = error;
});
},
updateProfile(id){
},
getEditProfile(id){
axios.get(`/api/profile/${id}/edit`).then(response=>{
this.editProfile = response.data;
console.log(response.data);
});
}
}
}
</script>
<style scoped>
#preview {
display: flex;
justify-content: center;
align-items: center;
}
#preview img {
max-width: 250px;
max-height: 250px;
}
</style>
i am using the FormData() and i want the data to be pass to axios.
Any help is muchly appreciated. TIA
You need to include the file's input field and submit the FormData object you are creating.
Change your submit() function to something like this and HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to sprrof it and add a hidden _method field to the form (https://laravel.com/docs/8.x/routing#form-method-spoofing):
formSubmit(){
const ids = this.userId;
let currentObj = this;
alert(this.editProfile.name);
alert(this.editProfile.last_name);
alert(this.editProfile.address);
alert(this.editProfile.photo.name);
let formData = new FormData();
formData.append('photo', this.editProfile.photo.name);
formData.append('name', this.editProfile.name);
formData.append('lastName', this.editProfile.last_name);
formData.append('address', this.editProfile.address);
formData.append('file', document.getElementById('fileInputId').files[0]);
console.log(formData.values);
axios.post(`/api/profile/${ids}/update`, formData).then(response=>{
console.log(response.data);
currentObj.success = response.data.success;
}).catch(error=>{
console.log(error);
currentObj.output = error;
});
},
Then to use put, add this to your form: <input type="hidden" name="_method" value="PUT">.
In your controller you can check to see if the file came through successfully with something like:
public function controllerMethod(Request $request)
{
if($request->hasFile('file')) {
dd('Success - there is a file.');
}
dd('Unsuccessful - there is no file');
}
This questions may help: How to send a file via Axios to Laravel

two select dynamics vue laravel

I want to load 2 select with vue, I have country, city state, but I don't want to call the js from resources / app.js since I don't need it in all the pages only in a particular sight. I am new to vue. when I load it from resources / app.js if it works but only for status but not for city and in the other pages it throws me an error since it cannot find the object.
I don't want to call him here
require('./bootstrap');
window.Vue = require('vue');
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
//require('./estado');
//require('./ciudad');
so how do i make the call and where do i put the js files
file get state resources/js/estado.js
const app = new Vue({
el: '#app',
data: {
selected_pais: '',
selected_estado: '',
selected_ciudad: '',
estados: [],
ciudades: [],
},
mounted(){
document.getElementById('estado').disabled = true;
this.selected_pais = document.getElementById('pais').getAttribute('data-old');
if(this.selected_pais !='')
{
this.loadEstados();
}
this.selected_estado = document.getElementById('estado').getAttribute('data-old');
document.getElementById('ciudad').disabled = true;
this.selected_estado = document.getElementById('estado').getAttribute('data-old');
if(this.selected_estado !='')
{
this.cargarCiudades();
}
this.selected_ciudad = document.getElementById('ciudad').getAttribute('data-old');
},
methods: {
loadEstados() {
this.selected_estado ='';
document.getElementById('estado').disabled =true;
if (this.selected_pais !="") {
axios.get(`http://127.0.0.1:80/estados/pais`, {params: {pais_id: this.selected_pais} }).then((response) => {
this.estados = response.data;
document.getElementById('estado').disabled =false;
});
}
},
cargarCiudades() {
this.selected_ciudad ='';
document.getElementById('ciudad').disabled =true;
if (this.selected_estado !="") {
axios.get(`http://127.0.0.1:80/ciudades/estado`, {params: {estado_id: this.selected_estado} }).then((response) => {
this.ciudades = response.data;
document.getElementById('ciudad').disabled =false;
});
}
},
}
});
file get city resources/js/ciudades.js
const app = new Vue({
el: '#app',
data: {
selected_estado: '',
selected_ciudad: '',
ciudades: [],
},
mounted(){
document.getElementById('ciudad').disabled = true;
this.selected_estado = document.getElementById('estado').getAttribute('data-old');
if(this.selected_estado !='')
{
this.cargarCiudades();
}
this.selected_ciudad2 = document.getElementById('ciudad').getAttribute('data-old');
},
method: {
cargarCiudades() {
this.selected_ciudad2 ='';
document.getElementById('ciudad').disabled =true;
if (this.selected_estado !="") {
axios.get(`http://127.0.0.1:80/ciudades/estado`, {params: {estado_id: this.selected_estado} }).then((response) => {
this.ciudades = response.data;
document.getElementById('ciudad').disabled =false;
});
}
}
}
});
files view
#extends('layouts.app')
#section('content')
#inject('paises','App\Services\Paises')
<div class="container">
<div class="row">
<div class="col-md-8">
#if ($errors->any())
<div class="alert alert-danger">
<h4>Por Favor corriga los siguientes errores </h4>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form action="/usuarios" method="POST">
#csrf
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Nombre</label>
<input type="text" class="form-control" name="nombre" id="inputEmail4" placeholder="Nombre" value="{{old('nombre')}}">
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Email</label>
<input type="text" class="form-control" name="email" id="inputPassword4" placeholder="Email" value="{{old('email')}}">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Direccion</label>
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St" name="direccion" value="{{old('direccion')}}">
</div>
<div class="form-row">
<div class="form-group col-md-4" id="div_pais">
<label for="inputCity">Pais</label>
<select v-model="selected_pais" id="pais" data-old="{{old('cbo_pais')}}"
v-on:change="loadEstados()" name="cbo_pais" class="form-control">
#foreach ($paises->get() as $index => $pais)
<option value="{{$index}}" >{{$pais}}</option>
#endforeach
</select>
</div>
<div class="form-group col-md-4">
<label for="inputCity">Estado</label>
<select v-model="selected_estado" id="estado" data-old="{{old('cbo_estado')}}"
v-on:change="cargarCiudades()" name="cbo_estado" class="form-control" >
<option value="">Selecione un Estado</option>
<option v-for="(estado, index) in estados" v-bind:value="index">#{{estado}}</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputState">Ciudad</label>
<select v-model="selected_ciudad" id="ciudad" data-old="{{old('cbo_ciudad')}}"
name="cbo_ciudad" class="form-control" >
<option value="">Selecione un Ciudad</option>
<option v-for="(ciudad, index) in ciudades" v-bind:value="index">#{{ciudad}}</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputZip">Zip</label>
<input type="text" class="form-control" id="inputZip" name="zip">
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck">
Check me out
</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Registrar</button>
<button type="reset" class="btn btn-danger">Cancelar</button>
</form>
</div>
</div>
</div>
#endsection
#section('scripts')
#endsection
how do I call the files in the view?

Vuejs components not getting displayed

I've a password_reset.vue script as below:
<template>
<form>
<div class="alert alert-danger" v-if="form.errors.has('photo')">
#{{ form.errors.get('photo') }}
</div>
<div class="row">
<div class="col-md-3">
<div class="label">Current Password</div>
</div>
<div class="col-md-9">
<div class="field--wrapper">
<label for="current_password">Current Password</label>
<input class="nom-fields" type="password"
v-model="form.current_password"
id="current_password" name="current_password"
placeholder="Current Password" value="">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="label">Repeat Password</div>
</div>
<div class="col-md-9">
<div class="field--wrapper">
<label for="password_repeat">Repeat Password</label>
<input class="nom-fields" type="password"
v-model="form.password_repeat"
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-9 text-right">
<button id="change_password"
class="blue-btn" v-on:click="update">
Change Password
</button>
</div>
</div>
</form>
</template>
<script>
export default{
data(){
return{
form: new MyForm({
current_password: '',
new_password: '',
password_repeat: '',
message: ''
})
};
},
methods: {
/**
* Update the user's password.
*/
update(e) {
e.preventDefault();
this.form.startProcessing();
this.$http.post('/account/change_password', this.form)
.then(function(response) {
this.form.finishProcessing();
})
.catch(function(response) {
this.form.setErrors(response.data);
});
},
}
}
</script>
and in my bootstrap.js file, I've:
import './interceptors.js';
import './forms/form.js';
import './forms/errors.js';
import PasswordReset from './settings/password_reset.vue'
new Vue({
el: 'body',
components: {
PasswordReset
},
ready() {
}
});
and in the app.js file I've:
import './bootstrap.js'
HTML:
<body>
<password-reset></password-reset>
</body>
But it seems the component is not getting displayed. I tried to alert a msg in the ready method and it's working fine. I'm loading Vue.js also.

Resources