Here I am doing a laravel CRUD operation where insert and delete work perfectly but the update is not working. Can you explain this?.
You can see if I click the edit button it`s opening my edit.blade.php

after changing data if I click the update button it shows scoreupdate updates successfully but the value is not changing.
Thin is my index.blade.php
{{-- edit modal --}}
<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Edit Score Update</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div id="modal_body">
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript">
$('body').on('click', '.edit', function() {
let subcat_id = $(this).data('id');
$.get("scoreupdates/edit/" + subcat_id, function(data) {
$("#modal_body").html(data);
});
});
</script>
This is my ScoreupdateController.php
public function edit($id)
{
$data=Scoreupdate::find($id);
return view('admin.manage.scoreupdate.edit',compact('data'));
}
public function update(Request $request)
{
// Query Bulder
$data=array();
$data['out_type']=$request->out_type;
$data['out_by_type']=$request->out_by_type;
$data['one']=$request->one;
$data['two']=$request->two;
$data['three']=$request->three;
$data['four']=$request->four;
$data['six']=$request->six;
$data['wide']=$request->wide;
$data['no_ball']=$request->no_ball;
$data['bye']=$request->bye;
$data['leg_bye']=$request->leg_bye;
$data['penalty_runs']=$request->penalty_runs;
DB::table('scoreupdates')->where('id',$request->id)->update($data);
$notification = array('message'=>'Scoreupdates Updated!','alert-type'=>'success');
return redirect()->back()->with($notification);
}
This is my Scoreupdate.php model
class Scoreupdate extends Model
{
use HasFactory;
protected $fillable=['out_type','out_by_type','one','two','three','four','six',
'wide','no_ball','bye','leg_bye','penalty_runs'];
}
This is my route admin.php
// scoreupdates route
Route::group(['prefix'=>'scoreupdates'],function(){
Route::get('/','ScoreupdateController@index')->name('scoreupdates.index');
Route::post('/store','ScoreupdateController@store')->name('scoreupdates.store');
Route::get('/delete/{id}','ScoreupdateController@destroy')->name('scoreupdates.delete');
Route::get('/edit/{id}','ScoreupdateController@edit');
Route::post('/update','ScoreupdateController@update')->name('scoreupdates.update');
});
This is my edit.blade.php
<form action="{{ route('scoreupdates.update') }}" method="Post">
@csrf
<div class="modal-body">
<div class="from-group">
<label for="out_type">out_type</label>
<input type="text" class="form-control" name="out_type" value="{{ $data->out_type }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you out_type</small>
</div>
<div class="from-group">
<label for="out_by_type">out_by_type</label>
<input type="text" class="form-control" name="out_by_type" value="{{ $data->out_by_type }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="one">One</label>
<input type="text" class="form-control" name="one" value="{{ $data->one }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="two">Two</label>
<input type="text" class="form-control" name="two" value="{{ $data->two }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="three">Three</label>
<input type="text" class="form-control" name="three" value="{{ $data->three }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="four">Four</label>
<input type="text" class="form-control" name="four" value="{{ $data->four }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="six">Six</label>
<input type="text" class="form-control" name="six" value="{{ $data->six }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="wide">Wide</label>
<input type="text" class="form-control" name="wide" value="{{ $data->wide }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="no_ball">No ball</label>
<input type="text" class="form-control" name="no_ball" value="{{ $data->no_ball }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="bye">Bye</label>
<input type="text" class="form-control" name="bye" value="{{ $data->bye }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="leg_bye">Leg Bye</label>
<input type="text" class="form-control" name="leg_bye" value="{{ $data->leg_bye }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
<div class="from-group">
<label for="penalty_runs">Penalty runs</label>
<input type="text" class="form-control" name="penalty_runs" value="{{ $data->penalty_runs }}" required="">
<small id="emailHelp" class="from-text text-muted">This is you score name</small>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="Submit" class="btn btn-primary">Update</button>
</div>
</form>
