product is not deleting from cart - laravel

hi m trying to delete product from cart but its not deleting , any suggestion to fix it,when i click on submit button then it says 404|not found
controller:
public function deleteCartProduct(Product $product)
{
$oldCart = Session::has('cart') ? Session::get('cart') : null;
$cart = new Cart($oldCart);
$cart->delProduct($product);
Session::put('cart', $cart);
return redirect()->route('product.cart')->with('flash_message_success', 'Product product has been removed from Cart');
}
model
public function deleteProduct($product)
{
if ($this->contents) {
if (array_key_exists($product->product_slug, $this->contents)) {
$delProduct = $this->contents[$product->slug];
$this->totalQty -= $delProduct['qty'];
$this->totalPrice -= $delProduct['price'];
array_forget($this->contents, $product->slug);
}
}
}
blade file
#foreach($contents as $slug => $cartItem)
<form action="{{ route('deleteCartProduct', $product) }}" method="POST">
#csrf
<tr class="table-row">
<td class="column-1">
<div class="cart-img-product b-rad-4 o-f-hidden">
<img src="{{ URL::to('/') }}/images/backend_images/product_images/{{ $cartItem['product']->product_image }}" alt="IMG-PRODUCT">
</div>
</td>
<td class="column-2">{{ $cartItem['product']->product_name }}</td>
<td class="column-3">${{ $cartItem['product']->product_price }}</td>
<td class="column-4">
<div class="flex-w bo5 of-hidden w-size17">
<button class="btn-num-product-down color1 flex-c-m size7 bg8 eff2">
<i class="fs-12 fa fa-minus" aria-hidden="true"></i>
</button>
<input class="size8 m-text18 t-center num-product" type="number" name="num-product1" value="{{ $cartItem['qty'] }}">
<button class="btn-num-product-up color1 flex-c-m size7 bg8 eff2">
<i class="fs-12 fa fa-plus" aria-hidden="true"></i>
</button>
</div>
</td>
<td class="column-5">${{ $cartItem['price'] }}</td>
<td class="column-5">
<input type="submit" class="btn btn-danger value="Remove Product">
</td>
</tr>
</form>
#endforeach
route:
Route::get('/cart/delete-product/{id}','ProductController#deleteCartProduct')->name('deleteCartProduct');

Your route should be Route::delete instead of Route::get and then in the form add this as well:
#method('delete')
I saw your error on the button:
<input type="submit" class="btn btn-danger value="Remove Product">
Change it with this:
<input type="submit" class="btn btn-danger" value="Remove Product">
Missing quote..
EDIT
Your route should be this:
Route::delete('/cart/delete-product/{id}','Admin\ProductController#deleteCartProduct')->name('deleteCartProduct');

You need to change the code in a controller as below.
public function deleteCartProduct(Product $product)
{
$oldCart = Session::has('cart') ? Session::get('cart') : null;
$cart = new Cart($oldCart);
$cart->deleteProduct($product);
Session::put('cart', $cart);
return redirect()->route('product.cart')->with('flash_message_success', 'Product product has been removed from Cart');
}

You defined it as method="POST" in blade. and "get" in route. So you need to change verb to Route::post

Related

Laravel Livewire hide checked checkbox

in my laravel project in livewire component i need to hide/set display none or something a checked checkbox and later i need to show again if its needed . Any solutions? I could simply delete it but i wanna store it in DB
I tried do this:
https://larainfo.com/blogs/laravel-livewire-show-and-hide-div-example
but its hidding my all input checkboxes
here is my Livewire component code:
<?php
namespace App\Http\Livewire\Tasks\Types;
use App\Http\Livewire\Forms\BaseForm;
use App\Models\Task\Task;
use App\Models\Task\TaskStatus;
use App\Models\Task\TaskType;
use App\Models\Task\TaskTypeStatus;
use Livewire\Component;
use App\Traits\HasPosition;
use Mpdf\Tag\Input;
class TaskTypeStatusModal extends BaseForm
{
public $task_type_id = 0;
public $availableStatuses = [];
public $selectedStatuses = [];
public $selectedStatusesList = [];
public function mount($params = [])
{
$this->task_type_id = $params['task_type_id'];
$this->title = 'Edytuj statusy';
$this->availableStatuses = TaskStatus::orderBy('position')->get();
$this->selectedStatuses = TaskTypeStatus::where('task_type_id', $this->task_type_id)->pluck('task_status_id');
$this->selectedStatusesList = TaskTypeStatus::where('task_type_id', $this->task_type_id)->orderBy('position')->get();
}
public function submit()
{
foreach ($this->selectedStatuses as $status) {
TaskTypeStatus::create([
'task_type_id' => $this->task_type_id,
'task_status_id' => $status,
]);
}
$this->closeFromModal();
$this->emit( 'Zapisano');
$this->emit('list:refresh');
}
public function render()
{
return view('livewire.tasks.types.task-type-status-modal',[
$this->selectedStatusesList = TaskTypeStatus::where('task_type_id', $this->task_type_id)->orderBy('position')->get()
]);
}
public function reorder($list)
{
foreach ($list as $item) {
TaskTypeStatus::find($item['value'])->update(['position' => $item['order']]);
}
}
public function deleteStatus($id)
{
TaskTypeStatus::find($id)->delete();
}
and here is my blade code:
<div>
<form wire:submit.prevent="submit">
<div class="modal-header">
<h5 class="modal-title">{{ $title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" wire:click.prevent="closeFromModal">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h6>Wybierz statusy</h6>
#forelse($availableStatuses as $availableStatus)
<div class="form-check checkbox">
<input class="form-check-input" name="status-{{ $availableStatus->id }}" id="status-{{ $availableStatus->id }}" wire:key="status-{{ $availableStatus->id }}"
wire:model.defer="selectedStatuses" type="checkbox" value="{{ $availableStatus->id }}"
wire:click="$toggle">
<label class="form-check-label" for="status-{{ $availableStatus->id }}">{{ $availableStatus->name }}</label>
</div>
#empty
<tr>
<td colspan="3">{{ __('Brak dostępnych statusów') }}</td>
</tr>
#endforelse
<hr>
<h6>Dodane statusy</h6>
<tr><span style="color:#3c4b64;font-size: 9pt"><b>{{ __('Przeciągnij za nazwę, aby zmienić kolejność.') }}</b></span></tr>
<ul class="list-group" wire:sortable="reorder">
#forelse ($selectedStatusesList as $selectedStatus)
<li class="list-group-item" value="{{ $selectedStatus->id }}" wire:sortable.item="{{ $selectedStatus->id }}" wire:key="selectedStatus-{{ $selectedStatus->id }}">
<td wire:sortable.handle>{{ __($selectedStatus->taskStatus->name) }}
<div class="float-right">
<button wire:click.prevent="deleteStatus({{ $selectedStatus->id }})" class="btn btn-sm btn-danger">{{ __('Usuń') }}</button>
</div>
</td>
</li>
#empty
<tr>
<td colspan="3">{{ __('Brak dodanych statusów') }}</td>
</tr>
#endforelse
</ul>
</div>
<div class="modal-footer">
<button wire:click.prevent="closeFromModal" class="btn btn-secondary" data-dismiss="modal">Anuluj</button>
<button type="submit" class="btn btn-primary">Zapisz</button>
</div>
</form>
</div>

Problem with Laravel CRUD (Edit Function)

Good day everyone. I'm quite new to new to Laravel and was doing some basic CRUD coding, I was able to code the add and view function, but I'm having a hard time with the edit and delete function.
I have 4 files, the master blade file, the web.php (routing), the blade file and the Form Controller.
This is the promo.blade.php file:
<table class="table table-striped" id="table1" >
<thead>
<tr>
<th class="text-center">ACTION</th>
<th class="text-center">Offer ID</th>
<th class="text-center">Promo Name</th>
<th class="text-center">Promo Price</th>
<th class="text-center">Status</th>
</tr>
</thead>
<tbody>
#foreach ($data as $key => $item)
<tr>
<td class="text-center">
<a href="#" data-bs-toggle="modal" data-bs-target="#show" data-myofferid="{{$item->offerId}}" data-mytitle="{{$item->promoName}}" data-myprice="{{$item->promoPrice}}">
<span class="badge bg-success"><i class="bi bi-eye-fill"></i></span>
</a>
<a href="#" data-bs-toggle="modal" data-bs-target="#edit" data-mainid="{{$item->id}}" data-myofferid="{{$item->offerId}}" data-mytitle="{{$item->promoName}}" data-myprice="{{$item->promoPrice}}">
<span class="badge bg-primary"><i class="bi bi-pencil-square"></i></span>
</a>
<a href="#" data-bs-toggle="modal" data-bs-target="#delete" data-myofferid="{{$item->offerId}}" data-mytitle="{{$item->promoName}}" data-myprice="{{$item->promoPrice}}">
<span class="badge bg-danger"><i class="bi bi-trash"></i></span>
</a>
</td>
<td class="date text-center">{{ $item->offerId }}</td>
<td class="date text-center">{{ $item->promoName }}</td>
<td class="number text-center">{{ $item->promoPrice}}</td>
<td class="number text-center">{{ $item->isActive }}</td>
</tr>
#endforeach
</tbody>
</table>
<!--Start Modal Edit -->
<div class="modal fade text-left" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel160" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header bg-primary">
<h5 class="modal-title white" id="add">
Edit Promo
</h5>
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
<i data-feather="x"></i>
</button>
</div>
<div class="modal-body">
<form action="{{ route('promo.edit') }}" method="POST">
#csrf
<div class="form-group">
<label for="">ID</label>
<input type="text" class="form-control" name="id" id="id" value="">
<span style="color:red">#error('id'){{$message}} #enderror</span>
</div>
<div class="form-group">
<label for="">Offer ID</label>
<input type="text" class="form-control" name="offerId" id="offerId" value="">
<span style="color:red">#error('offerId'){{$message}} #enderror</span>
</div>
<div class="form-group">
<label for="">Promo Name</label>
<input type="text" class="form-control" name="promoName" id="promoName" value="">
<span style="color:red">#error('promoName'){{$message}} #enderror</span>
</div>
<div class="form-group">
<label for="">Promo Price</label>
<input type="number" class="form-control" name="promoPrice" id="promoPrice" value="">
<span style="color:red">#error('promoPrice'){{$message}} #enderror</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light-secondary" data-bs-dismiss="modal">
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">CANCEL</span>
</button>
<button type="submit" class="btn btn-primary ml-1">
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">SAVE</span>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- End Modal Edit-->
Then this is the web.php file, for the routing:
Route::get('promo.promo', [App\Http\Controllers\FormControllerPromo::class, 'viewRecord'])->middleware('auth')->name('promo.promo');
Route::post('promo.add', [App\Http\Controllers\FormControllerPromo::class, 'addPromo'])->name('promo.add');
Route::post('promo.delete/{id}', [App\Http\Controllers\FormControllerPromo::class, 'viewDelete'])->middleware('auth');
Route::get('promo.edit', [App\Http\Controllers\FormControllerPromo::class, 'viewRecord'])->middleware('auth')->name('promo.edit');
Route::get('promo.edit/{id}', [App\Http\Controllers\FormControllerPromo::class, 'viewDetail'])->middleware('auth');
Route::post('promo.edit', [App\Http\Controllers\FormControllerPromo::class, 'edit'])->name('promo.edit');
This is the master.blade.php file:
<!--Start Modal edit for Promo-->
<script type="text/javascript">
$('#edit').on('show.bs.modal', function (event){
var button = $(event.relatedTarget)
var mainid = button.data('mainid')
var id = button.data('myofferid')
var title = button.data('mytitle')
var price = button.data('myprice')
var modal = $(this)
modal.find('.modal-body #id').val(mainid);
modal.find('.modal-body #offerId').val(id);
modal.find('.modal-body #promoName').val(title);
modal.find('.modal-body #promoPrice').val(price);
})
</script>
<!--End Modal edit for Promo-->
I think this is the part where the code wont execute properly.
This is the FormControllerPromo.php file:
// view form
public function index()
{
return view('promo.promo');
}
// view record
public function viewRecord()
{
$data = DB::table('promo')->get();
return view('promo.promo',compact('data'));
}
// view detail
public function viewDetail($id)
{
$data = DB::table('promo')->where('id',$id)->get();
return view('promo.promo',compact('data'));
}
// edit promo
public function edit(Request $request){
$id = $request->input('id');
$offerId = $request->input('offerId');
$promoName = $request->input('promoName');
$promoPrice = $request->input('promoPrice');
DB::table('promo')
->where('id', $id) // find your user by their email
->limit(1) // optional - to ensure only one record is updated.
->update(array('offerId' => $offerId, 'promoName' => $promoName, 'promoPrice' => $promoPrice)); // update the record in the DB.
$data = DB::table('promo');
return view('promo.promo',compact('data'));
}
I've been trying to code this for almost a week now with no success, any help is highly appreciated. :)
the update seems right, should work. but when you pass the $data variable to your view, you should call ->get(), because otherwise you return a query builder instance, that later raises the Undefined property error when trying to access {{$item->offerId}}.
change second last line in your example
//from this:
$data = DB::table('promo');
//to this:
$data = DB::table('promo')->get();
//or to this if you want to show only one record:
$data = DB::table('promo')->where('id', $id)->get();

problem in datatable when use in livewire component

i use livewire defer loading for load data after rendering page.
After opening the page, the information is successfully received and displayed in the table
But the problem is that I use datatable and when the received information is displayed, datatable becomes a simple table. As if I did not use datatable at all.
This is the livewire component code
class Cryptolist extends Component
{
public bool $loadData = false;
public function init()
{
$this->loadData = true;
}
public function render()
{
try {
if ($this->loadData) {
$api = new \Binance\API('api','secret');
$prices = $api->coins();
$one = json_encode($prices, true);
$coins = json_decode($one , true);
} else {
$coins = [];
}
return view('livewire.backend.crypto.cryptolist')->with('coins' , $coins);
}catch(\Exception $e)
{
return view('wrong')->with('e' , $e);
}
}
}
And this is the component view where the table is located and displays the received information
<div wire:init="init">
#if ($loadData)
<div id="loadesh1" wire:ignore>
<table class="datatable-init nk-tb-list nk-tb-ulist" data-auto-responsive="false">
<thead>
<tr class="nk-tb-item nk-tb-head">
<th class="nk-tb-col"><span class="sub-text">name</span></th>
<th class="nk-tb-col tb-col-mb"><span class="sub-text">balance</span></th>
</tr>
</thead>
<tbody>
#foreach ($coins as $item => $value)
<tr class="nk-tb-item">
<td class="nk-tb-col">
<div class="user-card">
<div class="user-avatar d-none d-sm-flex">
#if(file_exists(public_path() . '/img/crypto/'.strtolower($value['coin'].".svg")))
<img style="border-radius: 0"
src="{{asset('/img/crypto/'.strtolower($value['coin']))}}.svg" class="img-fluid"
alt="">
#else
<img style="border-radius: 0"
src="https://demo.rayanscript.ir/-/vendor/cryptocurrency-icons/32/color/noimage.png"
class="img-fluid" alt="">
#endif
</div>
<div class="user-info">
<span class="tb-lead english" style="font-weight: bolder">{{$value['name']}}</span>
<span class="english">{{$value['coin']}}</span>
</div>
</div>
</td>
<td class="nk-tb-col tb-col-mb" data-order="{{$value['coin']}}">
<div class="btn-group" aria-label="Basic example">
<button type="button" class="btn btn-sm btn-dim btn-light"
wire:click="getBalance('{{$value['coin']}}')">
<div wire:loading wire:target="getBalance('{{$value['coin']}}')">
<span class="spinner-border spinner-border-sm" role="status"
aria-hidden="true"></span>
</div>
<span class="w-120px" id="coin-{{$value['coin']}}">get balance</span>
</button>
<button type="button" class="btn btn-sm btn-dim btn-primary">add coin</button>
</div>
</td>
</tr><!-- .nk-tb-item -->
#endforeach
</tbody>
</table>
</div>
#else
Loading data...
#endif
</div>
What do you think is the problem, what code is written incorrectly?

Invalid argument supplied for foreach() (View: xxx\resources\views\admin\info-admin.blade.php) http://127.0.0.1:8000/tambah-info

Invalid argument supplied foreach()when try to add data
here's the form for submitting the data
info-admin.blade.php
<tbody class="text-center align-middle">
#foreach ( $info as $infos )
<tr>
<th scope="row" class="align-middle">{{ $loop->iteration }}</th>
<td class="align-middle">{{ $infos->judul }}</td>
<td class="align-middle">{{ $infos->konten }}</td>
<td class="align-middle">{{ $infos->image }}</td>
<td class="align-middle">{{ $infos->created_at }}</td>
<td class="align-middle">{{ $infos->Updated_at }}</td>
<td class="align-middle form">
<button type="submit" class="btn btn-info mb-3">Edit</button>
<form method="POST" action="{{ route('infos.destroy', [$infos->id]) }}">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-danger">Hapus</button>
</form>
</td>
</tr>
#endforeach
</tbody>
Store logic
InfosController
public function store(Request $request)
{
$info = new Info();
$info->judul = $request->input('judul');
$info->konten = $request->input('konten');
$info->image = $request->input('image');
if($request->hasFile('image')){
$file = $request->file('image');
$extension = $file->getClientOriginalExtension();
$filename = time() . '.' . $extension;
$file->move('upload/info_penting' , $filename);
$info->image = $filename;
} else{
return $request;
$info->image = '';
}
$info->save();
return view('admin.info-admin')->with('info','$info');
}
my routes, in case if you want to see it
web.php
route::post('/tambah-info','InfosController#store')->middleware('auth','admin');
EDITED
undefined variable when trying to update
the controller for the logic for updating the data
InfosController
public function update(Request $request, Info $info)
{
//
Info::where('id', $info->id)
->update([
'judul' => $request->judul,
'konten' => $request->konten,
'image' => $request->image,
]);
return redirect('/info-admin')->with('success', 'Berhasil Diedit');
}
here's the form for for the updating the data
edit-info.blade.php
<form action="{{ route('infos.update', [$info->id]) }}" method="patch" enctype="multipart/form-data>
#csrf
<input type="hidden" name="_method" value="PATCH">
<div class="mb-3">
<label for="judul">Judul</label>
<input type="string" class="form-control" value="{{$info->judul}}" id="judul" name="judul" required>
<div class="invalid-feedback">
Kolom Wajib Diisi
</div>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Konten</label>
<textarea class="form-control" value="{{$info->konten}} id="exampleFormControlTextarea1" rows="3" name="konten" required></textarea>
<div class="invalid-feedback">
Kolom Wajib Diisi
</div>
</div>
<input class="mb-3" type="file"value="{{$info->image}} name="image">
<button type="submit" class="btn btn-success btn-lg btn-block mt-auto">Kirim</button>
</form>
</div>
After saving your post, you should redirect to another route, probably the route for displaying all the posts
return redirect()->route('info-admin');
You should have another controller method for displaying all your data, you will have something similar to this
public function index()
{
$infos = Info::all();
return view('admin.info-admin', ['infos' => $infos]);
}
Then for sending a collection to the view. You should use your foreach this way and not the other way
#foreach($infos as $info)
// your code here
#endforeach
UPDATES
Your admin view should be like this
<tbody class="text-center align-middle">
#foreach ( $infos as $info )
<tr>
<th scope="row" class="align-middle">{{ $loop->iteration }}</th>
<td class="align-middle">{{ $info->judul }}</td>
<td class="align-middle">{{ $info->konten }}</td>
<td class="align-middle">{{ $info->image }}</td>
<td class="align-middle">{{ $info->created_at }}</td>
<td class="align-middle">{{ $info->updated_at }}</td>
<td class="align-middle form">
<button type="button" class="btn btn-info mb-3">Edit</button>
<form method="POST" action="{{ route('infos.destroy', $info->id) }}">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-danger">Hapus</button>
</form>
</td>
</tr>
#endforeach
</tbody>
Add data
define two routes, one route to access the form and another route to store form data
Route::get('/add-info', 'InfosController#create)->name('infos.add');
Route::post('/store-info', 'InfosController#store)->name('infos.store');
Access your add form as
<button type="button" class="btn btn-Success mb-3">Add</button>
Your create method
public function create()
{
return view('infos.add');
}
Your store method
public function store(Request $request)
{
$info = new Info();
$info->judul = $request->input('judul');
$info->konten = $request->input('konten');
$info->image = $request->input('image');
if($request->hasFile('image')){
$file = $request->file('image');
$extension = $file->getClientOriginalExtension();
$filename = time() . '.' . $extension;
$file->move('upload/info_penting' , $filename);
$info->image = $filename;
} else{
return $request;
$info->image = '';
}
$info->save();
return redirect()->route('admin.info-admin');
Edit data
define two routes, one route to access the form and another route to update form data
Route::get('/edit-info/{infos}/edit', 'InfosController#edit')->name('infos.edit');
Route::post('/update-info/{infos}/update', 'InfosController#update)->name('infos.update');
Access your edit form as
<button type="button" class="btn btn-Success mb-3">Edit</button>
Your edit method
public function edit($id)
{
$info = Info::findOrFail($id)
return view('infos.edit', ['infos' => $info]);
}
Your update method
public function update(Request $request, $id)
{
Info::where('id', $id)
->update([
'judul' => $request->judul,
'konten' => $request->konten,
'image' => $request->image,
]);
return redirect()->route('admin.info-admin')->with('success', 'Berhasil Diedit');
}
Add form action
<form action="{{ route('infos.store') }}" method="POST" enctype="multipart/form-data">
Edit form action
<form action="{{ route('infos.update', ['infos' => $info->id]) }}" method="POST" enctype="multipart/form-data">

Getting error while clicking on edit function button in laravel

I need to edit by data from database via my admin panel. So i created table with clickable button for edit function.
Now when I click on edit button, I am seeing ID number at bottom but getting sorry page couldn't found error ! I have double checked all controller, route and everything. It seems all good, but I don't know what's the error!
Route Code:
Route::get('/admin/baseFare',[
'uses' => 'ExtraBaseFareController#basefare',
'as' => 'base.fare'
]);
Route::get('/admin/baseFare/edit/{$id}',[
'uses' => 'ExtraBaseFareController#editBaseFare',
'as' => 'editbase.fare'
]);
Route::post('/admin/baseFare/update/{id}', [
'uses' => 'ExtraBaseFareController#baseFareUpdate',
'as' => 'base.fareupdate'
]);`
Controller Code:
public function basefare()
{
$base = BaseFare::all();
return view('Admin.BaseFare.index')->With('base', $base);
}
public function editBaseFare($id)
{
$base = BaseFare::find($id);
return view('Admin.BaseFare.editBaseFare')->with('base', $base);
}
public function baseFareUpdate(Request $request, $id)
{
$base = BaseFare::find($id);
$base->fareinpercentage = $request->fareinpercentage;
$base->fareinrupees = $request->fareinrupees;
$base->save();
Session::flash('success','Base fare successfully updated');
return redirect()->route('base.fare');
}
Index Page code:
<table class="table display nowrap table-striped table-bordered bootstrap-3 scroll-horizontal">
<thead>
<tr>
<th>S.No</th>
<th>Fare in Percentage (%)</th>
<th>Fare in Rupees (Rs)</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
#php $number = 1; #endphp
#foreach($base as $base)
<tr>
<td>
{{ $number.'.' }}
#php $number++; #endphp
</td>
<td>{{ $base->fareinpercentage }}</td>
<td>{{ $base->fareinrupees }}</td>
<td>
<a href="{{ route('editbase.fare',['id' => $base->basefareid ]) }}" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill" title="Edit ">
<i class="la la-edit"></i>
</a>
</td>
</tr>
#endforeach
</tbody>
</table>`
Edit Page Code:
<form class="form" method="post" action="{{ route('base.fareupdate',['id' => $base->basefareid ]) }}">
<div class="form-body">
<h4 class="form-section"><i class="la la-eye"></i>Base Fare Controller</h4>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="userinput2">Fare in Percentage (%)</label>
<input type="text" id="fareinpercentage" value="{{ $base->fareinpercentage }}" class="form-control border-primary" name="fareinpercentage">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="userinput3">Fare in Rupee (Rs)</label>
<input type="text" id="fareinrupees" value="{{ $base->fareinrupees }}" class="form-control border-primary" name="fareinrupees">
</div>
</div>
</div>
</div>
<div class="form-actions right">
<button type="button" class="btn btn-warning mr-1">
<i class="ft-x"></i> Cancel
</button>
<button type="submit" name="submit" class="btn btn-primary">
<i class="la la-check-square-o"></i> Save
</button>
</div>
</form>`
These are the codes, the kindly help me to find our the error, The main function is to edit the field from database!
If I understand the question correctly you can't go to the edit page.
Run 'php artisan route:list' and compare the routes.
And I can't figure out why you have dollar sign before the id in the route.

Resources