Laravel How to not require a required input - php

Hi I have a laravel Webapp (foxtrot invoice management system) in my website, there is required fields in a form that is used to store customer data to create invoice later. I don't want to have all the fields being required. Like, let's say, I want all the field to be optional. How can I do it?
<div class="card card-form">
<div class="row no-gutters">
<div class="col-lg-4 card-body">
<p><strong class="headings-color">{{ __('messages.customer_information') }}</strong></p>
<p class="text-muted">{{ __('messages.basic_customer_information') }}</p>
</div>
<div class="col-lg-8 card-form__body card-body">
<div class="row">
<div class="col">
<div class="form-group required">
<label for="display_name">{{ __('messages.display_name') }}</label>
<input name="display_name" type="text" class="form-control" placeholder="{{ __('messages.display_name') }}" value="{{ $customer->display_name }}" required>
</div>
</div>
<div class="col">
<div class="form-group required">
<label for="contact_name">{{ __('messages.contact_name') }}</label>
<input name="contact_name" type="text" class="form-control" placeholder="{{ __('messages.contact_name') }}" value="{{ $customer->contact_name }}" required>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group required">
<label for="email">{{ __('messages.email') }}</label>
<input name="email" type="email" class="form-control" placeholder="{{ __('messages.email') }}" value="{{ $customer->email }}" required>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="phone">{{ __('messages.phone') }}</label>
<input name="phone" type="text" class="form-control" placeholder="{{ __('messages.phone') }}" value="{{ $customer->phone }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group required">
<label for="currency_id">{{ __('messages.currency') }}</label>
<select name="currency_id" data-toggle="select" class="form-control select2-hidden-accessible" data-select2-id="currency_id" required>
<option disabled selected>{{ __('messages.select_currency') }}</option>
#foreach(get_currencies_select2_array() as $option)
<option value="{{ $option['id'] }}" {{ $customer->currency_id == $option['id'] ? 'selected=""' : '' }}>{{ $option['text'] }}</option>
#endforeach
</select>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="website">{{ __('messages.website') }}</label>
<input name="website" type="text" class="form-control" placeholder="{{ __('messages.website') }}" value="{{ $customer->website }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="vat_number">{{ __('messages.vat_number') }}</label>
<input name="vat_number" type="text" class="form-control" placeholder="{{ __('messages.vat_number') }}" value="{{ $customer->vat_number }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="kvk_number">{{ __('messages.kvk_number') }}</label>
<input name="kvk_number" type="text" class="form-control" placeholder="{{ __('messages.kvk_number') }}" value="{{ $customer->kvk_number }}">
</div>
</div>
</div>
</div>
</div>
<div class="row no-gutters">
<div class="col-lg-4 card-body">
<p><strong class="headings-color">{{ __('messages.billing_address') }}</strong></p>
<p class="text-muted">{{ __('messages.customer_billing_address') }}</p>
</div>
<div class="col-lg-8 card-form__body card-body">
<p class="row"><strong class=" col headings-color">{{ __('messages.billing_address') }}</strong></p>
<div class="row">
<div class="col">
<div class="form-group required">
<label for="billing[name]">{{ __('messages.name') }}</label>
<input name="billing[name]" type="text" class="form-control" placeholder="{{ __('messages.address_name') }}" value="{{ $customer->billing->name }}" required>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="billing[phone]">{{ __('messages.phone') }}</label>
<input name="billing[phone]" type="text" class="form-control" value="{{ $customer->billing->phone }}" placeholder="{{ __('messages.phone') }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group required">
<label for="billing[country_id]">{{ __('messages.country') }}</label>
<select id="billing[country_id]" name="billing[country_id]" data-toggle="select" class="form-control select2-hidden-accessible" data-select2-id="billing[country_id]" required>
<option disabled selected>{{ __('messages.select_country') }}</option>
#foreach(get_countries_select2_array() as $option)
<option value="{{ $option['id'] }}" {{ $customer->billing->country_id == $option['id'] ? 'selected=""' : '' }}>{{ $option['text'] }}</option>
#endforeach
</select>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="billing[state]">{{ __('messages.state') }}</label>
<input name="billing[state]" type="text" class="form-control" value="{{ $customer->billing->state }}" placeholder="{{ __('messages.state') }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="billing[city]">{{ __('messages.city') }}</label>
<input name="billing[city]" type="text" class="form-control" value="{{ $customer->billing->city }}" placeholder="{{ __('messages.city') }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="billing[zip]">{{ __('messages.postal_code') }}</label>
<input name="billing[zip]" type="text" class="form-control" value="{{ $customer->billing->zip }}" placeholder="{{ __('messages.postal_code') }}">
</div>
</div>
</div>
<div class="form-group required">
<label for="billing[address_1]">{{ __('messages.address') }}</label>
<textarea name="billing[address_1]" class="form-control" rows="2" placeholder="{{ __('messages.address') }}" required>{{ $customer->billing->address_1 }}</textarea>
</div>
</div>
</div>
{{-- <div class="row no-gutters">
<div class="col-lg-4 card-body">
<p><strong class="headings-color">{{ __('messages.shipping_address') }}</strong></p>
<p class="text-muted">{{ __('messages.customer_shipping_address') }}</p>
</div>
<div class="col-lg-8 card-form__body card-body">
<p class="row"><strong class=" col headings-color">{{ __('messages.shipping_address') }}</strong></p>
<div class="row">
<div class="col">
<div class="form-group">
<label for="shipping[name]">{{ __('messages.name') }}</label>
<input name="shipping[name]" type="text" class="form-control" value="{{ $customer->shipping->name }}" placeholder="{{ __('messages.address_name') }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="shipping[phone]">{{ __('messages.phone') }}</label>
<input name="shipping[phone]" type="text" class="form-control" value="{{ $customer->shipping->phone }}" placeholder="{{ __('messages.phone') }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="shipping[country_id]">{{ __('messages.country') }}</label>
<select id="shipping[country_id]" name="shipping[country_id]" data-toggle="select" class="form-control select2-hidden-accessible" data-select2-id="shipping[country_id]">
<option disabled selected>{{ __('messages.select_country') }}</option>
#foreach(get_countries_select2_array() as $option)
<option value="{{ $option['id'] }}" {{ $customer->shipping->country_id == $option['id'] ? 'selected=""' : '' }}>{{ $option['text'] }}</option>
#endforeach
</select>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="shipping[state]">{{ __('messages.state') }}</label>
<input name="shipping[state]" type="text" class="form-control" value="{{ $customer->shipping->state }}" placeholder="{{ __('messages.state') }}">
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="form-group">
<label for="shipping[city]">{{ __('messages.city') }}</label>
<input name="shipping[city]" type="text" class="form-control" value="{{ $customer->shipping->city }}" placeholder="{{ __('messages.city') }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="shipping[zip]">{{ __('messages.postal_code') }}</label>
<input name="shipping[zip]" type="text" class="form-control" value="{{ $customer->shipping->zip }}" placeholder="{{ __('messages.postal_code') }}">
</div>
</div>
</div>
<div class="form-group">
<label for="shipping[address_1]">{{ __('messages.address') }}</label>
<textarea name="shipping[address_1]" class="form-control" rows="2" placeholder="{{ __('messages.address') }}">{{ $customer->shipping->address_1 }}</textarea>
</div>
</div>
</div> --}}
#if($customer->getCustomFields()->count() > 0)
<div class="row no-gutters">
<div class="col-lg-4 card-body">
<p><strong class="headings-color">{{ __('messages.custom_fields') }}</strong></p>
</div>
<div class="col-lg-8 card-form__body card-body">
<div class="row">
#foreach ($customer->getCustomFields() as $custom_field)
#include('layouts._custom_field', ['model' => $customer, 'custom_field' => $custom_field])
#endforeach
</div>
</div>
</div>
#endif
{{ __('messages.save_customer') }}

Related

Select element dose not display selected value in it's input field - Laravel

I am making a crud application in Laravel. I make edit option, when I click on edit option it displays data from database according to corresponding id. It displays all values in input fields that I have entered while inserting data, but select element dose not display any data in its input field.
Page displaying all data from database
When I click on edit, it displays edit form as shown in the below picture
You can see all input fields displaying correct data from database but select element dose not displaying any value.
Code for this form is
#foreach($result as $list)
<div class="container">
<!------------ Row 1 ------------>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>NAME</label>
<input type="text" name="name" class="form-control" value="{{ $list->cust_name }}">
</div>
#error('name')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>PHONE</label>
<input type="number" name="phone" class="form-control" value="{{ $list->cust_phone }}">
</div>
#error('phone')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>CITY</label>
<input type="text" name="city" class="form-control" value="{{ $list->cust_city }}">
</div>
#error('city')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>INSTALLER NAME</label>
<input type="text" name="instaname" class="form-control" value="{{ $list->inst_name }}" >
</div>
</div>
</div>
<!------------ Row 2 ------------>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>STORE NAME</label>
<select type="text" name="storename" class="form-control" value="{{ $list->storename }}">
<option> ~ SELECT STORE NAME ~</option>
<option>PACKAGES</option>
<option>EMPORIUM</option>
<option>FORTRESS</option>
</select>
</div>
#error('storename')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>ORDER DATE</label>
<input type="date" name="odate" class="form-control" value="{{ $list->odate }}">
</div>
#error('odate')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>INSTALLATION DATE</label>
<input type="date" name="instadate" class="form-control" value="{{ $list->inst_date }}">
</div>
#error('instadate')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>BRAND NAME</label>
<input type="text" name="bname" class="form-control" value="{{ $list->brandname }}">
</div>
#error('bname')
<span id="field_error">{{$message}}</span>
#enderror
</div>
</div>
<!------------ Row 3 ------------>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>PRODUCT NAME</label>
<input type="text" id="add" name="pname" class="form-control" value="{{ $list->cust_order }}">
</div>
#error('pname')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>ORDER STATUS</label>
<select name="ostatus" class="form-control" value="{{ $list->cust_order_status }}">
<option> ~ SELECT STATUS ~ </option>
<option>PROCESSED</option>
<option>COMPLETED</option>
<option>FAILED</option>
<option>CANCELLED</option>
<option>PENDING</option>
</select>
</div>
#error('ostatus')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>INSTALLATION DONE BY</label>
<select name="doneby" class="form-control" value="{{ $list->inst_done_by }}">
<option> ~ DONE BY ~ </option>
<option>PCES</option>
<option>SELF</option>
</select>
</div>
#error('doneby')
<span id="field_error">{{$message}}</span>
#enderror
</div>
<div class="col-md-3">
<div class="form-group">
<label>ADDITIONAL COMMENTS</label>
<input type="text" name="comments" class="form-control" value="{{ $list->comments }}">
</div>
#error('comments')
<span id="field_error">{{$message}}</span>
#enderror
</div>
</div>
<!------------ Row 4 ------------>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>ADDRESS</label>
<input type="text" name="address" class="form-control" value="{{ $list->cust_address }}" >
</div>
#error('address')
<span id="field_error">{{$message}}</span>
#enderror
</div>
</div>
</div>
#endforeach
How can this problem be sorted out?
Just putting the value in select won't make the option selected. You have to add the selected attribute in an option to make it selected.
<select type="text" name="storename" class="form-control">
<option> ~ SELECT STORE NAME ~</option>
<option {{ $list->storename == 'PACKAGES' ? 'selected' : '' }}>PACKAGES</option>
<option {{ $list->storename == 'EMPORIUM' ? 'selected' : '' }}>EMPORIUM</option>
<option {{ $list->storename == 'FORTRESS' ? 'selected' : '' }}>FORTRESS</option>
</select>
Same applies for the ORDER STATUS selection. However I can see you are not using any value for options. It's good to use a value for each option. Consider using a unique value for each option.
Value is not getting displayed in select because you have used value in select tag instead of option tag and add keyword selected in option tag
<!-- The second value will be selected initially -->
<select name="choice">
<option value="first">First Value</option>
<option value="second" selected>Second Value</option>
<option value="third">Third Value</option>
</select>

How do I limit registration in my Laravel application?

I have a Laravel application with a registration form, and anyone can register multiple accounts.
I want to limit the registration to one account per IP address. How do I achieve this? I also want to only accept Gmail.
Here is my registration form:
<h4> {{ $page_title }} </h4>
<span class="liner"></span>
<div class="row">
<div class="col-md-6 col-md-offset-2 col-sm-12">
<h4> Registration </h4>
<span class="liner"></span>
<div class="widget-content clearfix">
<form action="{{ route('post-member') }}" method="post" class="form-horizontal" enctype="multipart/form-data">
{!! csrf_field() !!}
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Member Plan</label>
<div class="col-sm-8">
<select name="price_id" id="" class="form-control" required>
#foreach($price as $p)
#if($p->id == $pr)
<option value="{{ $p->id }}" selected>{{ $p->title }} - {{ $general->currency }} {{ $p->price }}</option>
#else
<option value="{{ $p->id }}">{{ $p->title }} - {{ $general->currency }} {{ $p->price }}</option>
#endif
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Name</label>
<div class="col-sm-8">
<input type="text" name="name" class="form-control" id="inputEmail3" placeholder="Name" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Email</label>
<div class="col-sm-8">
<input type="email" name="email" class="form-control" id="inputEmail3" placeholder="Email" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Phone</label>
<div class="col-sm-8">
<input type="text" name="phone" required class="form-control" id="inputEmail3" placeholder="Phone">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Address</label>
<div class="col-sm-8">
<textarea name="address" id="" cols="30" rows="3"
class="form-control" required></textarea>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-3 control-label">Profile Picture</label>
<div class="col-sm-8">
<input type="file" name="image" id="" required class="form-control">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Password</label>
<div class="col-sm-8">
<input type="password" required name="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Confirm Password</label>
<div class="col-sm-8">
<input type="password" required name="password_confirmation" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-8">
<button type="submit" class="btn btn-default"><i class="fa fa-send"></i> Registration</button>
</div>
</div>
</form>

how to insert multi select drop down data into the database in laravel 5.2

In my form i created multiselect drop down list. i need to store the data which i selected from my multi select drop down to database, table name devicelist along with some value that is taken from my form.
my view page is
#extends('app')
#section('content')
<br><br><br><br><br>
<div class="templatemo-content-wrapper">
<div class="container">
<ol class="breadcrumb">
<li><font color="green">Home</font></li>
<li class="active">View/Edit Vehicle</li>
</ol>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-success">
<div class="panel-heading">View/Edit Vehicle Information</div>
<div class="panel-body">
#if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form class="form-horizontal" role="form" method="POST" action="{{ url('vehicle/update/') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
#foreach($devices as $device)
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="deviceID" value="{{ ($device->deviceID)}}">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Creation date</label>
<div class="col-md-6">
<input type="text" class="form-control" name="creationTime" value="{{ date('Y/m/d H:i:s',($device->creationTime))}}">
</div>
</div>
<!--<div class="form-group">
<label class="col-md-4 control-label">Server ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="userID" value="" placeholder="Enter User ID">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Unique ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="uniqueID" value="{{ ($device->uniqueID)}}" placeholder="Enter Unique ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Active</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->isActive) }}" name="isActive" >
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle Description</label>
<div class="col-md-6">
<input type="text" class="form-control" name="description" value="{{ ($device->description) }}" placeholder="Enter the description">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Short Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="displayName" value="{{ ($device->displayName) }}" placeholder="Enter Display Name">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="vehicleID" value="{{ ($device->vehicleID) }}" placeholder="Enter Vehicle ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Plate</label>
<div class="col-md-6">
<input type="text" class="form-control" name="licensePlate" value="{{ ($device->licensePlate) }}" placeholder="Enter license Plate">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Expiration</label>
<div class="col-md-6">
<input type="date" class="form-control" name="licenseExpire" value="{{ ($device->licenseExpire) }}" placeholder="Enter license Expire Date">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Type</label>
<div class="col-md-6">
<input type="email" class="form-control" name="equipmentType" value="{{ ($device->equipmentType) }}" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Status</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->equipmentStatus) }}" name="equipmentStatus" >
<option>Unspecified</option>
<option value="inservice">In Service</option>
<option value="rented">Rented</option>
<option value="pending">Pending</option>
<option value="completed">Completed</option>
<option value="available">Available</option>
<option value="unavailable">Unavailable</option>
<option value="repair">Repair</option>
<option value="retired">Retired</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">IMEI/EDN Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="imeiNumber" value="{{ ($device->imeiNumber) }}" placeholder="Enter IMEI/EDN Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Serial Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="serialNumber" value="{{ ($device->serialNumber) }}" placeholder="Enter Serial Number">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Data Key</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">SIM Phone</label>
<div class="col-md-6">
<input type="email" class="form-control" name="simPhoneNumber" value="{{ ($device->simPhoneNumber) }}" placeholder="Enter SIM Phone Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">SMS Email Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="smsEmail" value="{{ ($device->smsEmail) }}" placeholder="Enter SMS E-Mail Address">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Group Pushpin ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Map Route Color</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->displayColor) }}" name="displayColor" >
<option>Default</option>
<option value="#000000">Black</option>
<option value="#a52a2a">Brown</option>
<option value="#dd0000">Red</option>
<option value="#b37400">Orange</option>
<option value="#008f00">Green</option>
<option value="#0000ee">Blue</option>
<option value="#9400d3">Purple</option>
<option value="#505050">Grey</option>
<option value="#00b3b3">Cyan</option>
<option value="#ff1493">Pink</option>
<option value="none">None</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Fuel Capacity</label>
<div class="col-md-6">
<input type="text" class="form-control" name="fuelCapacity" value="{{ ($device->fuelCapacity) }}" >
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Driver ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="driverID" value="{{ ($device->driverID) }}">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Reported Odometer</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Reported Engine Hours</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Group Membership</label>
<div class="col-md-6">
{{--<select class="form-control" value="{{ old('groupID') }}" name="groupID" multiple >--}}
{{--#foreach( $grouplist as $group)--}}
{{--#if ($group->groupID == old('description'))--}}
{{--<option value="{{ $group->groupID }}" >{{ $group->groupID." ".'['.$group->description.']' }}</option>--}}
{{--#else--}}
{{--<option value="{{ $group->groupID }}" >{{ $group->groupID." ".'['.$group->description.']' }}</option>--}}
{{--#endif--}}
{{--#endforeach--}}
{{--</select>--}}
<script type="text/javascript">
$(".js-example-basic-multiple").select2();
</script>
<select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" value="{{ old('groupID[]') }}" name="groupID" multiple="multiple" >
#foreach( $grouplist as $group)
#if ($group->groupID == old('description'))
<option value="{{ $group->groupID }}" >{{ $group->groupID." ".'['.$group->description.']' }}</option>
#else
<option value="{{ $group->groupID }}" >{{ $group->groupID." ".'['.$group->description.']' }}</option>
#endif
#endforeach
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-warning">
Update
</button>
</div>
</div>
#endforeach
</form>
</div>
</div>
</div>
</div>
</div>
</div>
#endsection
and my controller page is
public function update(Request $request)
{
try {
$postUser = Input::all();
//insert data into mysql table
$account = Account::select('accountID')->where('accountID', '=', 'gts')->get();
foreach ($account as $acc) {
$abc = $acc->accountID;
}
$data=DB::table('device')
->where("deviceID",$request['deviceID'])
->update(array(
"uniqueID"=>$request['uniqueID'],
"isActive"=>$request['isActive'],
"description"=>$request['description'],
"displayName"=>$request['displayName'],
"vehicleID"=>$request['vehicleID'],
"licensePlate"=>$request['licensePlate'],
"licenseExpire"=>$request['licenseExpire'],
"equipmentType"=>$request['equipmentType'],
"equipmentStatus"=>$request['equipmentStatus'],
"imeiNumber"=>$request['imeiNumber'],
"serialNumber"=>$request['serialNumber'],
"simPhoneNumber"=>$request['simPhoneNumber'],
"smsEmail"=>$request['smsEmail'],
"displayColor"=>$request['displayColor'],
"fuelCapacity"=>$request['fuelCapacity'],
"driverID"=>$request['driverID'],
"lastUpdateTime"=>time()));
$data = array("accountID" => $abc,
"deviceID"=> $request['deviceID'],
"groupID"=>$request['groupID[]'],
"lastUpdateTime"=>time(),
"creationTime"=>time());
$ck = 0;
$ck = DB::table('devicelist')->Insert($data);
$devices = DB::table('device')->simplePaginate(10);
return view('vehicle.vehicleAdmin')->with('devices', $devices);
} catch (ModelNotFoundException $err) {
//Show error page
}
}
}
how can i write the function to store the data from multiselect drop down to my table each value in each row along with other value. Can anyone tell me what should i do? and how to write "string to array" conversion and "for loop" for the insertion
If you are getting array from multi select and want to insert it in one row. You should implode array into comma separated string then insert it in table
Implode function
$val = implode(",",$request['groupID[]']);
Then put $val into your $data array like
$data = array("accountID" => $abc,
"deviceID"=> $request['deviceID'],
"groupID"=>$val,
"lastUpdateTime"=>time(),
"creationTime"=>time());
If you are getting string then explode it
Explode function
$val = explode(",",$request['groupID[]']);
$count = count($val);
for($a=0; $a<$count; $a++){
$data = array("accountID" => $abc,
"deviceID"=> $request['deviceID'],
"groupID"=>$val[$a],
"lastUpdateTime"=>time(),
"creationTime"=>time());
}

how to pass two array variable to view page and the value from there in laravel 5.2

i am creating edit page. So in the form fields i want fetch data ffrom two tables.. so in controller am fetching data from each table to different array variable. and trying to pass those variable to the same view page.. and there tryingf to get one table data for fields and other to make dropdown list. but its showing error
Undefined property: Illuminate\Database\Eloquent\Collection::$groupID
(View: C:\xampp\htdocs\opennGTS\resources\views\vehicle\add.blade.php)
my controller page is giving below
public function edit($id)
{
try {
//Find the vehicle object from model if it exists
$grouplist = Map::select('groupID','description')->get();
$devices = DB::table('device')->where('deviceID', '=', $id)->get();
//Redirect to edit vehicle form with the user info found above.
return view('vehicle.add')->with('devices', $devices)->with('grouplist',$grouplist);
} catch (ModelNotFoundException $err) {
//redirect to your error page
}
}
and view page is
#extends('app')
#section('content')
<br><br><br><br><br>
<div class="templatemo-content-wrapper">
<div class="container">
<ol class="breadcrumb">
<li><font color="green">Home</font></li>
<li class="active">View/Edit Vehicle</li>
</ol>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-success">
<div class="panel-heading">View/Edit Vehicle Information</div>
<div class="panel-body">
#if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form class="form-horizontal" role="form" method="POST" action="{{ url('vehicle/update/') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
#foreach($devices as $device)
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="deviceID" value="{{ ($device->deviceID)}}">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Creation date</label>
<div class="col-md-6">
<input type="text" class="form-control" name="creationTime" value="{{ date('Y/m/d H:i:s',($device->creationTime))}}">
</div>
</div>
<!--<div class="form-group">
<label class="col-md-4 control-label">Server ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="userID" value="" placeholder="Enter User ID">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Unique ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="uniqueID" value="{{ ($device->uniqueID)}}" placeholder="Enter Unique ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Active</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->isActive) }}" name="isActive" >
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle Description</label>
<div class="col-md-6">
<input type="text" class="form-control" name="description" value="{{ ($device->description) }}" placeholder="Enter the description">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Short Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="displayName" value="{{ ($device->displayName) }}" placeholder="Enter Display Name">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="vehicleID" value="{{ ($device->vehicleID) }}" placeholder="Enter Vehicle ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Plate</label>
<div class="col-md-6">
<input type="text" class="form-control" name="licensePlate" value="{{ ($device->licensePlate) }}" placeholder="Enter license Plate">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Expiration</label>
<div class="col-md-6">
<input type="date" class="form-control" name="licenseExpire" value="{{ ($device->licenseExpire) }}" placeholder="Enter license Expire Date">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Type</label>
<div class="col-md-6">
<input type="email" class="form-control" name="equipmentType" value="{{ ($device->equipmentType) }}" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Status</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->equipmentStatus) }}" name="equipmentStatus" >
<option>Unspecified</option>
<option value="inservice">In Service</option>
<option value="rented">Rented</option>
<option value="pending">Pending</option>
<option value="completed">Completed</option>
<option value="available">Available</option>
<option value="unavailable">Unavailable</option>
<option value="repair">Repair</option>
<option value="retired">Retired</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">IMEI/EDN Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="imeiNumber" value="{{ ($device->imeiNumber) }}" placeholder="Enter IMEI/EDN Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Serial Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="serialNumber" value="{{ ($device->serialNumber) }}" placeholder="Enter Serial Number">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Data Key</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">SIM Phone</label>
<div class="col-md-6">
<input type="email" class="form-control" name="simPhoneNumber" value="{{ ($device->simPhoneNumber) }}" placeholder="Enter SIM Phone Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">SMS Email Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="smsEmail" value="{{ ($device->smsEmail) }}" placeholder="Enter SMS E-Mail Address">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Group Pushpin ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Map Route Color</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->displayColor) }}" name="displayColor" >
<option>Default</option>
<option value="#000000">Black</option>
<option value="#a52a2a">Brown</option>
<option value="#dd0000">Red</option>
<option value="#b37400">Orange</option>
<option value="#008f00">Green</option>
<option value="#0000ee">Blue</option>
<option value="#9400d3">Purple</option>
<option value="#505050">Grey</option>
<option value="#00b3b3">Cyan</option>
<option value="#ff1493">Pink</option>
<option value="none">None</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Fuel Capacity</label>
<div class="col-md-6">
<input type="text" class="form-control" name="fuelCapacity" value="{{ ($device->fuelCapacity) }}" >
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Driver ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="driverID" value="{{ ($device->driverID) }}">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Reported Odometer</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Reported Engine Hours</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="row">
<div class="col-md-3 margin-bottom-15">
<label class="control-label">Group Membership</label>
<select class="form-control" value="{{ old('groupID') }}" name="groupID" >
#foreach( $grouplist as $group)
#if ($grouplist->groupID == old('description'))
<option value="{{ $group->groupID }}" selected>{{ $group->groupID.'['.$group->description.']' }}</option>
#else
<option value="{{ $group->groupID }}" >{{ $group->groupID.'['.$group->description.']' }}</option>
#endif
#endforeach
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-warning">
Update
</button>
</div>
</div>
#endforeach
</form>
</div>
</div>
</div>
</div>
</div>
</div>
any one please tell me how to do this and what wrong i had done in my code. Responses are appreciable.
Inside this foreach
#foreach( $grouplist as $group)
you are doing $grouplist->groupID
instead of $group->groupID
The exception you get is telling that groupID does not exist in the Collection class. In your loop, $grouplist is your Collection and $group is your item
I prefer this way:
return view('vehicle.add',[
'devices'=>$devices,
'groupList'=>$groupList
]);
But, you can use this:
return view('vehicle.add')->with(['devices'=>$devices,'groupList'=>$groupList]);

NotFoundHttpException in RouteCollection.php line 161: laravel 5.2

I created one table in one page, to that table fetching data from database. Then give dynamic buttons for delete and Edit/View. When i click on Delete , it will delete corresponding row from database. Previously it was working properly. But now it showing error "NotFoundHttpException in RouteCollection.php line 161:". Can anyone tell what wrong i did in my code?
My vehicleController.php
<?php
namespace App\Http\Controllers;
use Mail;
use Illuminate\Support\Facades\DB;
use App\Device;
use App\Account;
use App\Http\Requests\createUserRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use Illuminate\Pagination\Paginator;
class VehicleController extends Controller
{
public $type = 'Device';
public function getIndex()
{
$devices = DB::table('device')->simplePaginate(15);
return view('vehicle.vehicleAdmin')->with('devices', $devices);
}
public function vehicleInsert()
{
$postUser = Input::all();
//insert data into mysql table
$account = Account::select('accountID')->get();
foreach ($account as $acc) {
$abc = $acc->accountID;
}
$data = array("accountID" => $abc,
"vehicleID"=> $postUser['vehicleID']
);
// echo print_r($data);
$ck = 0;
$ck = DB::table('device')->Insert($data);
//echo "Record Added Successfully!";
$devices = DB::table('device')->simplePaginate(50);
return view('vehicle.vehicleAdmin')->with('devices', $devices);
}
public function delete($id)
{
DB::table('device')->where('vehicleID', '=', $id)->delete();
return redirect('vehicleAdmin');
}
public function edit($id)
{
try {
//Find the user object from model if it exists
$devices = DB::table('device')->where('vehicleID', '=', $id)->get();
//$user = User::findOrFail($id);
//Redirect to edit user form with the user info found above.
return view('vehicle.add')->with('devices', $devices);
} catch (ModelNotFoundException $err) {
//redirect to your error page
}
}
}
my vehicleAdmin.blade,php
#extends('app')
#section('content')
<div class="templatemo-content-wrapper">
<div class="templatemo-content">
<ol class="breadcrumb">
<li><font color="green">Home</font></li>
<li class="active">Vehicle information</li>
</ol>
<h1>View/Edit Vehicle information</h1>
<p></p>
<div class="row">
<div class="col-md-12">
<div class="table-responsive" style="overflow-x:auto;">
<table id="example" class="table table-striped table-hover table-bordered" bgcolor="#fff8dc">
<h3>Select a Vehicle :</h3>
<thead>
<tr>
<th>Vehicle ID</th>
<th>Unique ID</th>
<th>Description</th>
<th>Equipment Type</th>
<th>SIM Phone</th>
<th>Server ID</th>
<th>Ignition State</th>
<th>Expecting ACK</th>
<th>Active</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
#foreach($devices as $device)
<tr>
<td>{{ $device->vehicleID }}</td>
<td>{{ $device->uniqueID }}</td>
<td>{{ $device->description }}</td>
<td>{{ $device->equipmentType }}</td>
<td>{{ $device->simPhoneNumber }}</td>
<td></td>
<td>
#if(#$device->ignitionIndex == '0')
OFF
#else
ON
#endif
</td>
<td>{{ $device->expectAck }}</td>
<td>
#if($device->isActive == '1')
Yes
#else
No
#endif
</td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-info">Action</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
View/ Edit
</li>
<li>Delete</li>
</ul>
</div>
</td>
</tr>
#endforeach
</tbody>
</table>
{{--{!! $results->appends(['sort' => $sort])->render() !!}--}}
{{$devices->links()}}
</div>
</div>
</div>
</div>
</div>
{{--{!! $device->links()!!}--}}
</br>
<h4>Create a new Vehicle</h4>
<form role="form" method="POST" action="{{ url('vehicleAdmin') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row">
<div class="col-md-6 margin-bottom-15">
<input type="text" class="form-control" name="vehicleID" value="{{ old('vehicleID') }}" placeholder="Enter vehicle ID">
</div>
<div class="row templatemo-form-buttons">
<div class="submit-button">
<button type="submit" class="btn btn-primary">New</button>
</div>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable();
} );
</script>
#endsection
Edit page add.blade.php
#extends('app')
#section('content')
<div class="templatemo-content-wrapper">
<div class="container">
<ol class="breadcrumb">
<li><font color="green">Home</font></li>
<li class="active">View/Edit Vehicle</li>
</ol>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-success">
<div class="panel-heading">View/Edit Vehicle Information</div>
<div class="panel-body">
#if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<form class="form-horizontal" role="form" method="POST" action="{{ url('vehicle/update/') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
#foreach($devices as $device)
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="vehicleID" value="{{ ($device->vehicleID)}}" placeholder="Enter User ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Creation date</label>
<div class="col-md-6">
<input type="text" class="form-control" name="creationTime" value="{{ ($device->creationTime)}}">
</div>
</div>
<!--<div class="form-group">
<label class="col-md-4 control-label">Server ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="userID" value="{{ ($device->userID)}}" placeholder="Enter User ID">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Unique ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="uniqueID" value="{{ ($device->uniqueID)}}" placeholder="Enter Unique ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Active</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->isActive) }}" name="isActive" >
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle Description</label>
<div class="col-md-6">
<input type="text" class="form-control" name="description" value="{{ ($device->description) }}" placeholder="Enter the description">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Short Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="displayName" value="{{ ($device->displayName) }}" placeholder="Enter Contact Name">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Vehicle ID</label>
<div class="col-md-6">
<input type="text" class="form-control" name="vehicleID" value="{{ ($device->vehicleID) }}" placeholder="Enter Vehicle ID">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Plate</label>
<div class="col-md-6">
<input type="text" class="form-control" name="licensePlate" value="{{ ($device->licensePlate) }}" placeholder="Enter license Plate">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">License Expiration</label>
<div class="col-md-6">
<input type="text" class="form-control" name="licenseExpire" value="{{ ($device->licenseExpire) }}" placeholder="Enter license Expire Date">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Type</label>
<div class="col-md-6">
<input type="email" class="form-control" name="equipmentType" value="{{ ($device->equipmentType) }}" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Equipment Status</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->equipmentStatus) }}" name="equipmentStatus" >
<option value="0">In Service</option>
<option value="#">Rented</option>
<option value="#">Pending</option>
<option value="#">Completed</option>
<option value="#">Available</option>
<option value="#">Unavailable</option>
<option value="#">Repair</option>
<option value="#">Retired</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">IMEI/EDN Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->imeiNumber) }}" placeholder="Enter IMEI/EDN Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Serial Number</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->serialNumber) }}" placeholder="Enter Serial Number">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Data Key</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->notifyEmail) }}" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">SIM Phone</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->simPhoneNumber) }}" placeholder="Enter SIM Phone Number">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">SMS Email Address</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->smsEmail) }}" placeholder="Enter SMS E-Mail Address">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Group Pushpin ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ ($device->notifyEmail) }}" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<label class="col-md-4 control-label">Map Route Color</label>
<div class="col-md-6">
<select class="form-control" value="{{ ($device->timeZone) }}" name="timeZone" >
<option value="0">Black</option>
<option value="#">Brown</option>
<option value="#">Red</option>
<option value="#">Orange</option>
<option value="#">Green</option>
<option value="#">Blue</option>
<option value="#">Purple</option>
<option value="#">Grey</option>
<option value="#">Cyan</option>
<option value="#">Pink</option>
<option value="#">None</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Fuel Capacity</label>
<div class="col-md-6">
<input type="email" class="form-control" name="fuelCapacity" value="{{ ($device->fuelCapacity) }}" >
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Driver ID</label>
<div class="col-md-6">
<input type="email" class="form-control" name="driverID" value="{{ ($device->driverID) }}">
</div>
</div>
<!-- <div class="form-group">
<label class="col-md-4 control-label">Reported Odometer</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ old('notifyEmail') }}" placeholder="Enter E-Mail Address">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Reported Engine Hours</label>
<div class="col-md-6">
<input type="email" class="form-control" name="notifyEmail" value="{{ old('notifyEmail') }}" placeholder="Enter E-Mail Address">
</div>
</div> -->
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-warning">
Save
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
#endsection
Routes.php
Route::any('vehicleAdmin', 'VehicleController#getIndex');
Route::post('vehicleAdmin', 'VehicleController#vehicleInsert');
Route::get('vehicle/edit/{id}', 'VehicleController#edit');
Route::delete('vehicle/delete/{id}', 'VehicleController#delete');
I think when you click the link, it is probably sending a GET request to that end point unless you set the method to delete in ajax call,. CRUD in Laravel works according to REST. This means it is expecting a DELETE request instead of GET.
So I would suggest you to make your route as follow
Route::get('/vehicle/delete/{id}', 'VehicleController#delete');

Categories