Form keeps reloading page after pressing Submit in Laravel 8 - php

The caption explains it best. When I press the Submit button - the form should redirect to the Controller method "store" and execute the logic written. But instead, it just reloads the page. How do I know that the Controller isn't accessed? I have tried using dd() in the store() method and it never pops up.
Following is the HTML/PHP:
#extends('admin.layout')
#section('content')
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{url('js/datatables/dataTables.bootstrap4.css')}}">
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Cover
</h2>
</div>
<form action="{{ route('course.store') }}" method="post" enctype="multipart/form-data">
#csrf
#method('POST')
<div id="vertical-form" class="p-5">
<div class="preview">
<div class="avatar-upload" style="margin: 0 !important; max-width: 485px;">
<div class="avatar-edit" style="top:-20px !important; /* position: relative !important; */">
<input type='file' name="cover" id="imageUpload" accept=".png, .jpg, .jpeg" />
<label for="imageUpload"><i data-lucide="pen-tool" style="color: #232d45 !important;padding: 3px;left: 4px;top: 4px;position: relative;"></i></label>
</div>
<div id="imagePreview" style="background-size: cover; background-position: center; box-shadow: rgb(0 0 0 / 10%) 0px 2px 4px 0px; border: 1px solid rgb(141 146 157); margin: 0; border-radius: 11px; width: 452.66px !important; height: 224px; background-image: url(https://www.ysm.ca/wp-content/uploads/2020/02/default-avatar.jpg);">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Details
</h2>
</div>
<div id="vertical-form" class="p-5">
<div class="grid grid-cols-12 gap-2 mt-4 mb-4">
<label for="vertical-form-1" class="form-label col-span-6">Course Title</label>
<label for="vertical-form-1" class="form-label col-span-6">Course Difficulty</label>
<input type="text" name="name" placeholder="Name.." class="form-control col-span-6" placeholder="Input inline 1" aria-label="default input inline 1">
<select name="difficulty" class="form-select form-select col-span-6" aria-label="Select Course Difficulty">
<option value="Beginner">Beginner</option>
<option value="Intermediate">Intermediate</option>
<option value="Expert">Expert</option>
</select>
</div>
<div class="mt-4 mb-4">
<label for="vertical-form-1" class="form-label">Categories</label>
<select name="categories[]" data-placeholder="Choose appropriate categories for this course.." class="tom-select w-full" multiple>
#foreach ($categories as $category)
<option value="{{ $category->id }}">{{ $category->name }}</option>
#endforeach
</select>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Course Description
</h2>
</div>
<div id="vertical-form" class="p-5">
<div class="mt-4 mb-4">
<textarea class="dark:border-darkmode-400"" cols="80" id="editor2" name="description" rows="10" data-sample-short>Type a detailed description of the course i.e its prerequisites, requirements, learning outcome and any other details that may be needed.</textarea>
</div>
</div>
</div>
</div>
<div class="intro-y col-span-12 mt-4">
<!-- BEGIN: Vertical Form -->
<div class="intro-y box">
<div class="flex flex-col sm:flex-row items-center p-5 border-b border-slate-200/60 dark:border-darkmode-400">
<h2 class="font-medium text-base mr-auto">
Choose Instructor
</h2>
</div>
<div id="vertical-form" class="p-5">
<table class="table table-responsive table-striped table-vcenter js-dataTable-full">
<thead>
<tr>
<th class="text-center">PICK</th>
<th>ID</th>
<th>AVATAR</th>
<th class="d-none d-sm-table-cell">NAME</th>
<th class="d-none d-sm-table-cell" style="width: 15%;">EMAIL</th>
<th class="text-center" style="width: 15%;">Profile</th>
</tr>
</thead>
<tbody>
#foreach ($teachers as $teacher)
<tr>
<td class="w-10">
<input class="form-check-input" type="radio" name="teacher_id" value="{{ $teacher->id }}">
</td>
<td class="w-10">{{ $teacher->id }}</td>
<td class="w-20">
<div class="w-10 h-10 image-fit zoom-in ml-2">
<img class="rounded-full" src="{{ url('images/'.$teacher->avatar) }}" alt="">
</div>
</td>
<td class="d-none d-sm-table-cell">{{ $teacher->name }}</td>
<td class="d-none d-sm-table-cell">
<span class="badge badge-danger">{{ $teacher->email }}</span>
</td>
<td class="text-center">
<button type="button" class="btn btn-sm btn-secondary" data-toggle="tooltip" title="View Customer">
<i class="fa fa-user"></i>
</button>
</td>
</tr>
#endforeach
</tbody>
</table>
<button type="submit" class="btn btn-primary mt-5">Create Course</button>
</form>
</div>
</div>
</div>
<script src="https://cdn.ckeditor.com/4.19.0/standard-all/ckeditor.js"></script>
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" integrity="sha384-rOA1PnstxnOBLzCLMcre8ybwbTmemjzdNlILg8O7z1lUkLXozs4DHonlDtnE7fpc" crossorigin="anonymous"></script>
<script>
CKEDITOR.replace('editor2', {
height: 260,
/* Default CKEditor 4 styles are included as well to avoid copying default styles. */
contentsCss: [
'http://cdn.ckeditor.com/4.19.0/full-all/contents.css',
'https://ckeditor.com/docs/ckeditor4/4.19.0/examples/assets/css/classic.css'
],
removeButtons: 'PasteFromWord',
});
</script>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#imagePreview').css('background-image', 'url('+e.target.result +')');
$('#imagePreview').hide();
$('#imagePreview').fadeIn(650);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imageUpload").change(function() {
readURL(this);
});
</script>
<script src="{{url('js/datatables/jquery.dataTables.min.js')}}"></script>
<script src="{{url('js/datatables/dataTables.bootstrap4.min.js')}}"></script>
<script src="{{url('js/be_tables_datatables.min.js')}}"></script>
#endsection
What am I doing wrong here? Why is the form not taking me to course.store method in the CourseController? And the controller is a resource controller. So the routing is very straight-forward, and not an issue in this case either.

I think you need to check your closing div tags, you must not close a div that is the parent of the form before closing the form tag,

May be you Forgot to remove Last Div tage and also you should write at last #endsection
#extends('admin.layout')
#section('content')
//here you can write your form as well as other HTML
#endsection

I had the same issue, in my case the problem was registered the same Route
Route::post('/users', [UserController::class, 'store']);
Route::post('/users', [UserController::class, 'storeDashboard']);
I wanted to fire store method but storeDashboard was firing instead

Related

Nested forms using laravel and jquery

This is a form to create a new scorecard.. When I click on add new objective button. A new objective is added. My problem comes when I want to add new kpi in the second or other objectives apart from the firt one, the kpi is added in the first objective and also it adds the whole scorecard form instead of only one objective per click.This image shows how the kpi is added.
Here is my scorecard code
<form id="form" action='/scorecard'>
<div class="class" id="objectives_place">
<div class="row col-md-10 col-md-offset-1" >
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="name">Name</label>
<input id="scoreCardName" name="scoreCardName" value="{{ $scorecard['name'] }}" style="height: 40px;" type="text" class="form-control" placeholder="score card name" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="name">Employee</label>
<select name="employeeid" id="employeeid" class="form-control" style="height: 40px;">
<option value="">choose employee</option>
#foreach($employees as $employee)
<option value="{{$employee->id}}"
#if(($employee->id) == (isset($scorecard_info->employee_id)?$scorecard_info->employee_id:''))
selected
#endif>{{$employee->first_name}} {{$employee->middle_name}} {{$employee->lastname}}
</option>
#endforeach
</select>
<br>
{{-- <small>Select Employee for the Objective Button to appear</small> --}}
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="description">Description</label>
<textarea name="scorecard_description" class="form-control" id="description" style="resize: none;height: 40px;" placeholder="score card description">{{ $scorecard['description'] }}</textarea>
</div>
</div>
</div>
<div id="objectivesData" class="row ">
#include('organization::objectiveAdd')
</div>
</div>
</div>
<div class="row col-md-10 col-md-offset-1">
<div class="row col-md-12">
<button id="newobjectivebtn" type="button" style="width:200px; float: left; padding: 5px;background-color:#a3d84e; border: 1px solid #fff; color: #fff; display: none;">Add new Objective</button>
</div>
<div class="row col-md-12 text-center" ><br>
<div id="listobjective" style="max-height:400px;">
</div> <br>
<button type="button" id="savescorecard" style="width: 365px; padding: 5px;
background-color:#a3d84e; border: 1px solid #fff; color: #fff; display: none; float:right;">Save Scorecard</button>
</div>
</form>
This is jquery for adding new objective
$('#newobjectivebtn').click(function(){
var objectiveIndex = $(this).data("objective-index");
let form = $('form');
$.ajax({
headers:{
'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
},
type:'POST',
url:'{{route('add_scorecard_objectives')}}',
data:form.serialize(),
success:function(response){
var div = $('#objectivesData')
div.append(response);
},
error:function(response){
toastr.error('System Error , Contact Administrator!');
}
})
});
This is the jquery code for adding new kpi
$('#objectivesData').on('click','.newkpibtnn',function(){
let form = $('form');
var objectiveIndex = $(this).data("objective-index");
console.log(objectiveIndex);
$.ajax({
headers:{
'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
},
type: "POST",
url: "{{ route('add_objectives_kpis') }}",
data:form.serialize() + "&objectiveIndex=" + objectiveIndex,
success: function(response) {
var div = $('#kpis_row_data')
div.append(response);
},
error: function(error) {
console.log(error);
}
});
});
This is the objectiveAdd.blade.php file
#foreach ($scorecard['objectives'] as $objective)
<div class="row">
<div class="row col-md-12 " id="objectives_page">
<div class="container-fluid spark-screen">
<div class="row">
<div class="box box-green">
<div class="box-header with-border">
<h2 style="font-size: 22px;margin-bottom: -5px;margin-top: 0px; text-align:center;">Scorecard Objective</h2>
</div>
<div class="box-body" >
<div class="row col-md-10 col-md-offset-1">
<div class="row">
<div class="col-md-4">
<div class="form-group col-ms-12">
<label for="Objective">Name</label>
<input type="text" name="objectives[name]" value="{{ isset($objective['name'])?$objective['name']:'' }}" class="form-control" style="margin-bottom: 0px;" placeholder="objective name" />
<small id="error_objectivename" class="hidden" style="color: red;margin-left: 1%;font-size: 13px;height:40px;">Enter a Objective Name</small>
</div>
</div>
<div class="col-md-3">
<div class="form-group col-sm-12">
<label for="description">Weight</label>
<input class="form-control" maxlength="2" value="{{ isset($objective['weight'])?$objective['weight']:'' }}" type="number" name="objectives[weight]" placeholder="%" min="1" max="100" style="margin-bottom: 1px;">
<small id="error_objectiveweight" class="hidden" style="color: red;margin-left: 1%;font-size: 13px;height:40px;">Add Weight</small>
</div>
</div>
<div class="col-md-4">
<div class="form-group col-sm-12">
<label for="description">Description</label>
<textarea name="objectives[description]" class="form-control" id="objectivedescription" style="resize: none;height:40px;" placeholder="enter descriprion">{{ isset($objective['description'])?$objective['description']:'' }}</textarea>
</div>
</div>
<div class="col-md-1">
<span class="badge badge-pill delete-form" style="color: red !important; background: transparent !important; height:50px; padding-left: 50px; padding-top:40px; padding-right:60px;cursor: pointer;">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</span>
</div>
</div>
<div class="row" >
<div class="form-group col-md-11">
<table class="table table-bordered table-condensed" id="kpis_table" >
<thead>
<tr>
<th scope="col" class="width-25-per">KPI Name</th>
<th scope="col" class="width-25-per">Weight</th>
<th scope="col" class="width-20-per">Description</th>
<th scope="col" class="width-25-per">Expected Delivery</th>
<th scope="col" class="width-10-per">Goal</th>
<th scope="col" class="width-10-per"></th>
</tr>
</thead>
<tbody class="addKpis" id="kpis_row_data">
#include('organization::objectiveAddKpi')
</tbody>
</table>
</div>
</div>
</div>
<div class="row col-md-10 col-md-offset-1">
<div class="row col-md-12">
<button class="newkpibtnn" data-objective-index="{{ $index }}" type="button" style="width:200px; float: left; padding: 5px;background-color:#a3d84e; border: 1px solid #fff; color: #fff;">Add new KPI</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endforeach
My routes.php file
Route::post('/add_objective', 'OrganizationController#addScorecardObjective')->name('add_scorecard_objectives');
Route::post('/add_kpis', 'OrganizationController#addKpi')->name('add_objectives_kpis');
This is my controller
public function addScorecardObjective(Request $request)
{
$data = $request->all();
unset($data['expected_delivery_date']);
$data['objectives'] = array(['name'=>'','weight'=>'','description'=>'','kpis'=>[
['name'=>'','weight'=>'','description'=>'','expected_delivery_date'=>'','goal'=>'']
]]);
return view('organization::objectiveAdd')->with([
'scorecard'=>$data
]);
}
public function addKpi(Request $request)
{
$data = $request->all();
$objectiveIndex = $data['objectiveIndex'];
$data['objectives'] = array($data['objectives']);
$data['objectives'][$objectiveIndex]['kpis'] = array(['name'=>'','weight'=>'','description'=>'','expected_delivery_date'=>'','goal'=>'']);
return view('organization::objectiveAdd')->with([
'scorecard'=>$data
]);
}
I want to be able to add a number of kpis in a particular objective whenever I click on add new objective button on that particular objective.

My live search using livewire is not working

I am doing a live search on livewire, my search term is already binded with the livewire controller, but when I add it to the where clause in render function, it still displays all the data on the table not the one i am searching. I tried replacing the searchterm with a string as keyword in LIKE and it works. It seems that i can't use the input in searchterm as a keyword in the where clause.
here is my controller;
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Item;
use Livewire\WithPagination;
class Items extends Component
{
use WithPagination;
public $searchTerm;
public function render()
{
$select = Item::where('itemName', 'LIKE', '%' . $this->searchTerm . '%')->paginate(6);
return view('livewire.items', ['items' => $select]);
}
}
this is my view
<div class="row browse mt-6">
<div class="col float-left category ">
<h4 class="float-left font-weight-bold">All Categories</h4>
<h4 class="float-left font-weight-bold">Men</h4>
<h4 class="float-left font-weight-bold">Women</h4>
</div>
<div class="col search-cat float-right">
<input type="text" id="search" placeholder="Browse Products" wire:model="searchTerm"/>
</div>
{{$searchTerm}}
</div>
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
<table class="table-center">
<tbody>
<div>
#foreach($items as $item)
<tr class="mx-auto">
<div class="d-inline w-30 item-desc mx-auto m-1">
<h4 class="pt-1">{{ $item->itemName }}</h4>
<div class="">
<img src="items/{{ $item->itemPic }}.png" alt="" class="item-pic">
</div>
<div class="row">
<div class="col d-inline float-left">
Price: US ${{ $item->itemPrice }}
</div>
<div class="col d-inline float-right">
{{ $item->itemCOD }}</td>
</div>
</div>
</div>
</tr>
</tbody>
#endforeach
</div>
<hr style="border-top: dotted 1px;" />
<div class="pagination-content">
{{ $items->links('pagination::pagination-custom') }}
</div>
<hr style="border-top: dotted 1px;" />
</table>
</div>
There's two things here that could potentially cause problems,
Your tr element does not have wire:key, the value to wire:key must be unique across the entire page
Your view consists of multiple root elements (if this is your entire view), these are the three root-elements in your view - and in Livewire, its very important that the view only has one root element.
<div class="row browse mt-6">
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
Also, as a sidenote, your loop also closes the tbody tag, which is odd, so I moved that out of the loop. It also doesn't quite make sense to put divs and hrs inside the table tag, those should probably be outside of the tabletag.
Here's the updated view, with wire:key on the tr and with the whole view wrapped in one div,
<div>
<div class="row browse mt-6">
<div class="col float-left category ">
<h4 class="float-left font-weight-bold">All Categories</h4>
<h4 class="float-left font-weight-bold">Men</h4>
<h4 class="float-left font-weight-bold">Women</h4>
</div>
<div class="col search-cat float-right">
<input type="text" id="search" placeholder="Browse Products" wire:model="searchTerm"/>
</div>
{{$searchTerm}}
</div>
<hr style="border-top: dotted 1px;" />
<div class="row w-100 p-1">
<table class="table-center">
<tbody>
<div>
#foreach($items as $item)
<tr class="mx-auto" wire:key="item-{{ $item->id }}">
<div class="d-inline w-30 item-desc mx-auto m-1">
<h4 class="pt-1">{{ $item->itemName }}</h4>
<div class="">
<img src="items/{{ $item->itemPic }}.png" alt="" class="item-pic">
</div>
<div class="row">
<div class="col d-inline float-left">
Price: US ${{ $item->itemPrice }}
</div>
<div class="col d-inline float-right">
{{ $item->itemCOD }}</td>
</div>
</div>
</div>
</tr>
#endforeach
</div>
</tbody>
<hr style="border-top: dotted 1px;" />
<div class="pagination-content">
{{ $items->links('pagination::pagination-custom') }}
</div>
<hr style="border-top: dotted 1px;" />
</table>
</div>
</div>
Have a look at this resource from the official Livewire docs,
https://laravel-livewire.com/docs/2.x/troubleshooting#dom-diffing-issues
Maybe because you not render component
Try add <livewire:name-component /> in parent view like this
<div class>
<livewire:name-component />
</div>

Update loop records via Laravel and livewire

Hi, I would like some help on this.
This loop comes from my products table, using pure laravel I load each product in inputs, so if I make any changes and click on an update button it is redirected to a route to update the changed product.
How could I do this same idea using livewire?
How to display the updated data in this loop without having to go to another route.
My blade:
#forelse($categoryProduct->products as $key => $product)
<li>
<div class="mt-3 card">
<div class="card-body">
<div class="row">
<div class="col-1">
<x-inputs.group class="">
<div
x-data="imageViewer('{{ $product->img ? \Storage::url($product->img) : '' }}')">
<x-inputs.partials.label name="img" label="Foto">
</x-inputs.partials.label><br />
<!-- Show the image -->
<template x-if="imageUrl">
<img :src="imageUrl"
class="object-cover border border-gray-200 rounded"
style="width: 100px; height: 100px;" />
</template>
<!-- Show the gray box when image is not available -->
<template x-if="!imageUrl">
<div class="bg-gray-100 border border-gray-200 rounded"
style="width: 140px; height: 140px;"></div>
</template>
<div class="mt-2">
<input wire:model="img" type="file" name="img" id="img"
#change="fileChosen" />
</div>
#error('img')
#include('components.inputs.partials.error')
#enderror
</div>
</x-inputs.group>
</div>
<div class="col-11">
<div class="row">
<div class="col-10">
<input type="text" class="form-control" placeholder="Name"
value="{{ $product->name }}">
</div>
<div class="col-2">
<button
onclick="confirm('Tem certeza que deseja deletar esse produto?') || event.stopImmediatePropagation()"
wire:click.prevent="deleteProduct({{ $product->id }})"
class="btn btn-user btn-danger">
×
</button>
</div>
<div class="mt-3 col-10">
<textarea class="form-control"
placeholder="Description">{{ $product->description }}</textarea>
</div>
<div class="mt-3 col-2">
<input type="number" class="form-control"
placeholder="Price" value="{{ $product->price }}">
</div>
</div>
</div>
</div>
</div>
</li>
#empty
This is the way I'm feeding the loop:
public function render()
{
$this->shop = Shop::with([
'categoryProducts',
'categoryProducts.products',
'districts'
])->where('user_id', Auth::user()->id)->first();
return view('app.menu-controller')
->extends('layouts.app')
->section('content');
}
You can create a Livewire ProductComponent and in blade have the div card once this loop the same elements
https://www.laravel-livewire.com/docs/2.x/making-components
https://www.laravel-livewire.com/docs/2.x/rendering-components
<div>
<div class="mt-3 card">
<div class="card-body">
<div class="row">
<div class="col-1">
<x-inputs.group class="">
<div
x-data="imageViewer('{{ $product->img ? \Storage::url($product->img) : '' }}')">
<x-inputs.partials.label name="img" label="Foto">
</x-inputs.partials.label><br />
//......................
</div>
</div>
Use model binding in nested component for the loop
https://www.laravel-livewire.com/docs/2.x/nesting-components
#forelse($categoryProduct->products as $key => $product)
<li>
#livewire('product-component',['product' => $product], key($user->id))
</li>
and in component
public Product $product;
public function render()
{
return view('livewire.product-component')
->extends('layouts.app')
->section('content');
}
The rest in in Livewire documentation, when you get on there could come here with issues or questions. Greetings

Onclick/Ajax on the Generate OTP without reloading?

I am having an issue that how to send the number to next page where it handles the mobile number and send a message to the user mobile number. By Using onClick method or by using ajax method can we send the message without reloading the page like below in the code.
index.php
<form method="POST" action="test.php">
<input type="text" class="form-control" name="mobile" placeholder="Mobile" maxlength="10">
<input type="text" class="form-control" name="otp" placeholder="OTP" maxlength="11" style="width: 40%; float: left;">
<input type="submit" id="btnonOtp" value="Generate OTP" class="form-control" style="background-color:#005995;width: 56.5%; float: left; margin: 0 0 0 12px; border-radius: 0;">
</form>
$('#btnonOtp').click(function()
{
$.ajax({
url: test.php,
type:'POST',
data:
{
text: mobile,
value: mobile
},
success: function(msg)
{
alert('OTP Sent');
}
});
});
Test.php
<?php
include 'send.php';
$_SESSION['smsotp'] = sms_OTP();
$num=$_POST['mobile'];
$number = $num;
//$text = 'Hi There, how are you?';
$sms_api_result = sms_Send($number, 'Please do not share the one time password with anyone. Your One Time password is: '.$_SESSION['smsotp'],$debug);
?>
If I run the test.php with mobile number passing directly then the message is delivered, but I need to pass the mobile number dynamically to $num variable.
Can any one help me where I am going wrong??
The 'data' object in your ajax isn't passing the right value.
First, add an id to the mobile tag,
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile" maxlength="10">
Second, change the input type of the buttom from type="submit" to type="button". This is required because 'submit' by default does a full page submit, even if you have an click handler defined for it. [the click function also gets executed but after than the page submit happens as well.]
And then update your click function like the one below.
$('#btnonOtp').click(function()
{
$.ajax({
url: test.php,
type:'POST',
data:
{
// The key is 'mobile'. This will be the same key in $_POST[] that holds the mobile number value.
mobile: $('#mobile').val()
},
success: function(msg)
{
alert('OTP Sent');
}
});
});
This should solve your core problem.
Debugging hint: To check if the data is being passed correctly, in test.php you can do a var_dump($_POST). This will print all the key-value pairs that were received. This should help you to analyse what is usually missing.
P.S: Also, as a good practice you might want to add a validation on the Value of the mobile number field to ensure the data entered by the user indeed looks like a mobile number.
Try below code that can help you:
NOTE: Please check if mobile number is getting in $number variable or not.
<?php
include 'send.php';
$_SESSION['smsotp'] = sms_OTP();
$number = (int) $_POST['mobile'];
//$text = 'Hi There, how are you?';
$sms_api_result = sms_Send($number, 'Please do not share the one time password with anyone. Your One Time password is: '.$_SESSION['smsotp'],$debug);
?>
M.AutoInit(),$(document).ready(function(){var e=$(window).height(),t=$(".row.main-background").height();$(document).height();t<e&&$(".row.main-background").css("height","100%"),$("body").css("height",e)});var Email=localStorage.getItem("Email"),Name=localStorage.getItem("Name"),Id=localStorage.getItem("Id"),Cognito_ID=localStorage.getItem("Cognito_ID");Email&&Name&&Id&&""!=Cognito_ID&&(window.location.href="matches.html");var selectedValue,referral,referralValue=[];function myFunction(){var e=localStorage.getItem("Cognito_ID");if(null!=(t=localStorage.getItem(e+".CrickingDuelsUserInfo")))var t=localStorage.getItem(e+".CrickingDuelsUserInfo");else $("#overlayLoader").hide(),$("#verification").modal("open",{onOpenStart:function(){$("main").addClass("filter-blur"),$("footer").addClass("filter-blur")},onCloseStart:function(){$("main").removeClass("filter-blur"),$("footer").removeClass("filter-blur")}}),document.getElementById("accountVerficationStepOne").style.display="block",document.getElementById("accountReferralCode").style.display="none";var n=JSON.parse(t);if(null==n&&(client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t)})),null!=t){null==n.ReferralTaken&&($("#overlayLoader").hide(),$("#verification").modal("open",{onOpenStart:function(){$("main").addClass("filter-blur"),$("footer").addClass("filter-blur")},onCloseStart:function(){$("main").removeClass("filter-blur"),$("footer").removeClass("filter-blur")}}),document.getElementById("accountVerficationStepOne").style.display="block",document.getElementById("accountReferralCode").style.display="none");var o=n.ReferralTaken.Key,a=n.ReferralTaken.Value;if(null!=n.SelectedState){var c=n.SelectedState.Key;n.SelectedState.Value;"SelectedState"==c&&localStorage.setItem("user_state","restricted")}"ReferralTaken"==o&&"true"==a&&($("#overlayLoader").show(),window.location.href="matches.html",cognitosync("Web","LastLoginOS"))}}function isPhoneKey(e,t){var n=e.which?e.which:event.keyCode;return!(n>31&&(n<48||n>57))&&!($(t).val().length>9)}function isOTPKey(e,t){var n=e.which?e.which:event.keyCode;return!(n>31&&(n<48||n>57))&&!($(t).val().length>0)}function delayedredirect(){window.location.href="matches.html"}function cognitosync(e,t){var n=localStorage.getItem("Cognito_ID",cognito),o=localStorage.getItem("Email",o),a=localStorage.getItem("Id",a),c=localStorage.getItem("Name",c);client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(c,l){SyncData(l),"stateselect"==t?(l.get("SelectedState",function(e,t){}),l.put("SelectedState",e,function(e,t){}),l.get("DeviceId",function(e,t){}),l.put("DeviceId",n,function(e,t){}),l.get("Email",function(e,t){}),l.put("Email",o,function(e,t){}),l.get("PrimaryEmail",function(e,t){}),l.put("PrimaryEmail",o,function(e,t){}),l.get("UserId",function(e,t){}),l.put("UserId",a,function(e,t){}),l.get("IsFavorites",function(e,t){}),l.put("IsFavorites","true",function(e,t){}),l.get("IsLikeFB",function(e,t){}),l.put("IsLikeFB","false",function(e,t){}),l.get("IsLikeTWITTER",function(e,t){}),l.put("IsLikeTWITTER","false",function(e,t){}),l.get("IsMusicOn",function(e,t){}),l.put("IsMusicOn","false",function(e,t){}),l.get("IsPushOn",function(e,t){}),l.put("IsPushOn","false",function(e,t){}),l.get("IsShowRatecard",function(e,t){}),l.put("IsShowRatecard","false",function(e,t){}),l.get("IsShowSocialMedia",function(e,t){}),l.put("IsShowSocialMedia","false",function(e,t){}),l.get("TriviaQuestions",function(e,t){}),l.put("TriviaQuestions","0",function(e,t){}),l.get("Country",function(e,t){}),l.put("Country","India",function(e,t){}),SyncData(l)):"LastLoginOS"==t?(l.get("LastLoginOS",function(e,t){}),l.put("LastLoginOS","Web",function(e,t){}),SyncData(l)):"PhoneNo"==t?(l.get("PhoneNo",function(e,t){}),l.put("PhoneNo",e,function(e,t){}),SyncData(l)):"GotPhoneNo"==t?(l.get("GotPhoneNo",function(e,t){}),l.put("GotPhoneNo","true",function(e,t){}),SyncData(l)):"referaltaken"==t&&(l.get("ReferralTaken",function(e,t){}),l.put("ReferralTaken",e,function(e,t){}),SyncData(l),setTimeout(delayedredirect,2e3))})}window.fbAsyncInit=function(){FB.init({appId:"1437031366566616",xfbml:!0,version:"v2.10"})},function(e,t,n){var o,a=e.getElementsByTagName(t)[0];e.getElementById(n)||((o=e.createElement(t)).id=n,o.
src="https://connect.facebook.net/en_US/sdk.js",a.parentNode.insertBefore(o,a))}(document,"script","facebook-jssdk"),document.getElementById("phonenumber_button").addEventListener("click",function(){var e=$("input[name='phone']").val();localStorage.setItem("phone_number",e);var t=Math.floor(1e3+9e3*Math.random());localStorage.setItem("otp",t);var n=localStorage.getItem("Cognito_ID");$.
ajax({url:'https://ws.cricking.com/ws5/otpsms.php?value={"userid":"'+n+'", "otp":"'+t+'", "tonumber":"'+e+'", "platform":1}',type:"GET",success:function(e){0==(e=JSON.parse(e)).StatusCode&&(document.getElementById("accountVerficationStepOne").style.display="none",document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="block")}}),cognitosync(e,"PhoneNo")}),document.getElementById("resend_code").addEventListener("click",function(){var e=localStorage.getItem("phone_number"),t=localStorage.getItem("otp"),n=localStorage.getItem("Cognito_ID");$.
ajax({url:'https://ws.cricking.com/ws5/otpsms.php?value={"userid":"'+n+'", "otp":"'+t+'", "tonumber":"'+e+'", "platform":1}',type:"GET",success:function(e){0==(e=JSON.parse(e)).StatusCode&&(document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="block")}})}),document.getElementById("otp_submit").addEventListener("click",function(){var e=$("input[name='otp1']").val()+$("input[name='otp2']").val()+$("input[name='otp3']").val()+$("input[name='otp4']").val(),t=localStorage.getItem("otp"),n=localStorage.getItem("phone_number"),o=localStorage.getItem("Cognito_ID");t==e&&($.ajax({url:'https://ws.cricking.com/ws5/userregistration.php?value={"tonumber":"'+n+'","userid":"'+o+'"}',type:"GET",success:function(e){}}),cognitosync("true","GotPhoneNo"),document.getElementById("accountVerficationStepTwo").style.display="none",document.getElementById("accountVerficationStepThree").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none",document.getElementById("accountReferralCode").style.display="block")}),document.getElementById("loginBtn").addEventListener("click",function(){$("#overlayLoader").show(),FB.login(function(e){if(FB.api("/me",{fields:"email,name"},function(e){localStorage.setItem("Email",e.email),localStorage.setItem("Name",e.name),localStorage.setItem("Id",e.id);localStorage.getItem("Email"),localStorage.getItem("Name"),localStorage.getItem("Id"),localStorage.getItem("Cognito_ID")}),e.authResponse){setTimeout(myFunction,5e3);var t=e.authResponse.accessToken;if(localStorage.setItem("accesstoken",t),null!=t){var n={IdentityPoolId:"us-east-1:8017b399-3a23-45d6-8407-7271cef062ef",Logins:{"graph.facebook.com":t}};AWS.config.region="us-east-1",AWS.config.credentials=new AWS.CognitoIdentityCredentials(n),AWS.config.credentials.get(function(e,t){AWS.config.credentials.get(function(){AWS.config.credentials.identityId;client=new AWS.CognitoSyncManager,client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t),t.getAllRecords(function(e,t){var n=t.length;0==t.length&&client.openOrCreateDataset("CrickingDuelsUserInfo",function(e,t){SyncData(t),t.getAllRecords(function(e,t){})});var o=localStorage.getItem("_internal._metadata"),a=JSON.stringify(o);JSON.parse(a);if(t.length>1){for(var c=0;c<n;c++)if("ReferralTaken"==t[c].key){referralValue={userval:t[c].value};break}localStorage.setItem("userVal",referralValue.userval)}})}),cognito=AWS.config.credentials.identityId,localStorage.setItem("Cognito_ID",cognito)})})}}})}),$("#select_state").click(function(){var e=document.getElementById("user_state");e=$("#user_state option:selected").val();if(""==(selectedValue=e))return M.toast({html:"Select a state"}),!1;"Assam"==selectedValue?(cognitosync("true","referaltaken"),cognitosync(selectedValue,"stateselect"),document.getElementById("accountReferralCode").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none"):(cognitosync(selectedValue,"stateselect"),document.getElementById("accountVerficationStepTwo").style.display="block",document.getElementById("accountReferralCode").style.display="none",document.getElementById("accountVerficationStepOne").style.display="none")}),$("#final_refer").click(function(){var e=document.getElementById("refer_code").value,t=localStorage.getItem("Cognito_ID"),n=localStorage.getItem("Email"),o=localStorage.getItem("Name");$.getJSON('https://ws.cricking.com/ws4/?action=playerreferal&value={"UserId":"'+t+'","EmailId":"'+n+'","Code":"'+e+'","UserName":"'+o+'"}').success(function(e){if("0"==e.StatusCode)M.toast({html:"Congrats! Your referral code is valid. Take control! Join Hybrid Fantasy and enjoy Cricking Duels."}),cognitosync("true","referaltaken"),cognitosync("Web","LastLoginOS"),$("#overlayLoader").show();else{if("1"==e.StatusCode)return M.toast({html:"Oops! You entered an invalid referral code. Please check and re-enter the valid referral code."}),!1;if("2"==e.StatusCode)return M.toast({html:"Oops! You entered an invalid referral code. Please check and re-enter the valid referral code."}),!1}})}),$("#skip_refer_code").click(function(){cognitosync("true","referaltaken"),
cognitosync("Web","LastLoginOS"),$("#overlayLoader").show()});
<!DOCTYPE html>
<html>
<head>
<title>CrickingDuels</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.4.14.min.js"></script>
<script src="js\cognito\dist\amazon-cognito.min.js"></script>
<link href="css\materialize.min.css" rel="stylesheet">
<link href="css\fontawesome\css\font-awesome.min.css" rel="stylesheet">
<link href="css\common.css" rel="stylesheet">
<link href="css\login.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Rubik" rel="stylesheet">
<script src="https://use.typekit.net/wmk2lex.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-54357006-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-54357006-1');
</script>
</head>
<body class="white">
<main>
<div class="row main-background">
<div class="">
<div class="col s12 m12 l12 relative" style="padding: 50px 10%;">
<div class="">
<div class="row no-margin">
<div class="col s12 m12 l12">
<h3 class="blue-text text-darken-4 margin-5-0 bold">Let's</h3>
<h3 class="blue-text text-darken-4 margin-5-0 bold">Play</h3>
<h3 class="blue-text text-darken-4 margin-5-0 bold">Fantasy!</h3>
</div>
</div>
<div class="row margin-10-0" style="margin-bottom: 30% !important;">
<div class="col s12 m12 l12">
<p class="font-16 blue-text text-darken-4 margin-5-0 bold">Play fantasy</p>
<p class="font-16 blue-text text-darken-4 margin-5-0 bold">& win cash daily!</p>
</div>
</div>
<div class="row no-margin" style="position: absolute;bottom: 0;left: 0;width: 100%;padding: 0 20px;">
<div class="col s12 m12 l12">
<div class="row add-amount no-margin">
<div class="col s12 m6 l6 no-padding push-l3 push-m3 center-align">
<button id="loginBtn" class="btn btn-flat blue darken-3 white-text width-100" style="text-transform: none;"><i class="fa fa-facebook white-text font-14"></i> Sign in with Facebook</button>
</div>
</div>
</div>
</div>
</div>
<div style="margin-bottom: 0;"></div>
</div>
</div>
</div>
</main>
<div class="modal" id="verification">
<div class="modal-content blue">
<div class="row no-margin" id="accountVerficationStepOne">
<div class="col s12 m12 l12 no-padding center-align">
<div class="img-block">
<img src="images\state_selection.png" class="img responsive-img img-center" width="150">
</div>
<!-- <p class="uppercase blue-text text-darken-4 bold">State Selection</p> -->
<p class="uppercase blue-text text-darken-4">Residents of the states of Assam and Odisha, and where otherwise prohibited by law are not eligible to enter pay leagues, you can play free Leagues</p>
<div class="form-group" style="padding-top: 30px;">
<select class="" name="state" id="user_state">
<option value="">--Select a state--</option>
<option value="Andaman and Nicobar">Andaman and Nicobar</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Arunachal Pradesh">Arunachal Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Chandigarh">Chandigarh</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Delhi">Delhi</option>
<option value="Dadra and Nagar Haveli">Dadra and Nagar Haveli</option>
<option value="Daman and Diu">Daman and Diu</option>
<option value="Goa">Goa</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu and Kashmir">Jammu and Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Lakshadweep">Lakshadweep</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="Manipur">Manipur</option>
<option value="Meghalaya">Meghalaya</option>
<option value="Mizoram">Mizoram</option>
<option value="Nagaland">Nagaland</option>
<option value="Odisha">Odisha</option>
<option value="Punjab">Punjab</option>
<option value="Puducherry">Puducherry</option>
<option value="Rajasthan">Rajasthan</option>
<option value="Sikkim">Sikkim</option>
<option value="Tamil Nadu">Tamil Nadu</option>
<option value="Telangana">Telangana</option>
<option value="Tripura">Tripura</option>
<option value="Uttarakhand">Uttarakhand</option>
<option value="Uttar pradesh">Uttar Pradesh</option>
<option value="West bengal">West bengal</option>
</select>
<button class="btn btn-flat gradient-background white-text margin-10-0" id="select_state">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountVerficationStepTwo" style="display: none;">
<div class="col s12 m12 l12 no-padding center-align">
<div class="img-block">
<img src="images\mobile_number.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold">Mobile Verification</p>
<p class="uppercase blue-text text-darken-4">Please enter your mobile number</p>
<div class="form-group" style="padding-top: 30px;">
<input type="text" name="phone" id="phone" class="browser-default" onkeypress="return isPhoneKey(event, this)" placeholder="+91">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="phonenumber_button">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountVerficationStepThree" style="display: none;">
<div class="col s12 m12 l12 no-padding">
<div class="img-block">
<img src="images\sms_otp.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold center-align">Mobile Verification</p>
<p class="uppercase blue-text text-darken-4 center-align">Please enter the OTP you have received on your registered mobile number</p>
<div class="form-group center-align" style="padding-top: 30px;margin: 0 auto;">
<input type="text" name="otp1" id="otp1" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp2" id="otp2" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp3" id="otp3" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
<input type="text" name="otp4" id="otp4" class="browser-default inline center-align" style="width: 16%; padding: 0 5px;" onkeypress="return isOTPKey(event,this)">
</div>
<div class="form-group center-align resend_code">
Resend code
</div>
<div class="form-group center-align">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="otp_submit">Next</button>
</div>
</div>
</div>
<div class="row no-margin" id="accountReferralCode" style="display: none;">
<div class="col s12 m12 l12 no-padding">
<div class="img-block">
<img src="images\sms_otp.png" class="img responsive-img img-center" width="150">
</div>
<p class="uppercase blue-text text-darken-4 bold center-align">Referral code</p>
<p class="uppercase blue-text text-darken-4 center-align">We want to give you a head start. If you have a referral code, enter it below and we will load ₹ 89 in your wallet to join the leagues.</p>
<div class="form-group center-align" style="padding-top: 30px;margin: 0 auto;">
<input type="text" name="refer_code" id="refer_code">
</div>
<div class="form-group center-align resend_code">
Skip
</div>
<div class="form-group center-align">
<button class="btn btn-flat gradient-background white-text margin-10-0" id="final_refer">Submit</button>
</div>
</div>
</div>
</div>
</div>
<div id="overlayLoader" style="display: none;">
<div class="loader">
<div class="progress thin-4">
<div class="indeterminate"></div>
</div>
</div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="js\materialize.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js" integrity="sha256-rsPUGdUPBXgalvIj4YKJrrUlmLXbOb6Cp7cdxn1qeUc=" crossorigin="anonymous"></script> -->
<!-- <script src="js/dust-full.min.js"></script>
<script src="js/dust-helpers.min.js"></script> -->
<script src="js\cognitosync.js"></script>
<script src="js\login.js"></script>
<!-- <script type="text/javascript" src="js/javascript.js"></script> -->
</html>

Creating a preview page feature in Laravel 5.1

I am new to Laravel and I am creating content management system as practice to get familiar with the framework. Currently, I am working on the feature for the user to preview the information they have entered for updating the new page they want to create and here is code for the view:
<div ng-controller="PagesController">
<form action="{{url('admin/page/preview')}}" method="post" name="pageForm">
<div class="col-md-9">
<div class="panel-body">
<div class="row">
<div class="form-group">
<label>Title</label>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="text" class="form-control input-md" name="title" ng-model="page.title">
</div>
<!-- <input type="submit" value="Preview"> -->
</div>
<div class="row">
<div class="form-group">
<fieldset style="border: 1px solid #E4E4E4; padding-top: 5px; padding-bottom: 5px;">
<div class="form-group">
<div class="col-md-5">
<label>Add File</label>
<input type="file" name="upload" nv-file-select uploader="updateUploader" value="Select Picture" ng-model="page.upload" >
</div>
<div class="col-md-6">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Progress</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in updateUploader.queue">
<td style="max-width: 170px; word-wrap: break-word;" ng-cloak><strong>#{{ item.file.name}}</strong></td>
<td><div class="col-md-12"><progressbar value="item.progress"></progressbar></div></td>
<td nowrap ng-cloak>
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
<span class="glyphicon glyphicon-trash"></span> Remove
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</fieldset>
</div>
</div><br>
<div class="row">
<div class="form-group">
<label>Body</label>
<input type="hidden" name="body" value="#{{page.body}}"/>
<summernote name="body" ng-model="page.body" config="options" height="300"></summernote>
<div ng-messages="pageForm.body.$error" ng-if="pageForm.body.$dirty">
<div ng-message="required">
<span class="error-msgs">Please enter page information</span>
</div>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left">
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="checkbox col-md-12 text-left">
<label><input type="checkbox" value="" ng-model"page.serivice" ng-false-value="0" ng-true-value="1" ><strong>Update page to services</strong></label>
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left">
<button type="button" class="btn btn-success" name="update" ng-disabled="pageForm.$invalid" ng-click="update()">Update</button>
<input type="submit" class="btn btn-default btn-md" value="Preview">
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default general-panel publish" style="margin-top: 35px;">
<div class="panel-heading">
<div class="title">Navigation</div>
</div>
<div class="panel-body">
<span class="">
<i></i><strong>Parent pages</strong>
<div class="btn-group">
<select class="form-control" name="publish_period" ng-model="page.parent_nav">
<option value="">No Parent Navigation</option>
<option value="about-us">About Us</option>
<option value="media">Media</option>
<option value="publication">Publication</option>
<option value="law">Law</option>
<option value="legislation">Legislation</option>
<option value="compliance">Compliance</option>
<option value="license">Applying For License</option>
</select>
</div><br><br>
</span>
</div>
</div>
<div class="panel panel-default general-panel general-summary">
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th colspan="3"><h5>Uploaded Documents</h5></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="document in documents">
<td style="max-width: 100px; word-wrap: break-word;">#{{document.file_path}}</td>
<td>
<i class="fa fa-download fa-fw"></i>Download
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</form>
</div>
Here is the code for the route for previewing the page:
Route::post('page/preview','PagesController#preview');
and the controller method for the preview function:
public function preview(Request $request)
{
return view('admin.pages.preview')->with('title',$request->input('title'))->with('body',$request->input('body'));
}
This works for me, but when I refreshed the preview page it would generate an error saying BadMethodCallException. So I am wondering how can eliminate this from happening? and thanks in advance.

Categories