laravel-oci8
laravel-oci8 copied to clipboard
Cannot delete and update
Summary of problem or feature request
Hi, i am using yajra laravel-oci8 package with Laravel 6.2. I am having problem with crud operation for update and delete function (i am using resource controller).
store function run successfully as usual. the data is inserted into the database. However, the update and delete didn't work as expected. save() command in update function return true, but the changes is not written to the database. i had check both $request and $work object with dd and both objects exist with right data.
I am suspecting it has something to do with oracle default autocommit off. I tried the same code with MySQL table and it works. How do i enable oracle autocommit using this laravel-oci8 or how do i call commit using Eloquent? I also had try to put the save() command in DB transaction but still no luck. Please help.
Code snippet of problem
public function store(Request $request)
{
$work = new Work();
$work->id = $request->workid;
$work->name = $request->workname;
$work->save();
return redirect('work');
}
public function update(Request $request, Work $work)
{
$work->name = $request->workname;
$work->save();
return redirect('work');
}
public function destroy(Work $work)
{
$work->delete();
return redirect('work');
}
<div class="card-body">
<form action="{{ route('work.update',$work->id) }}" method="POST">
@method('PUT')
@csrf
<div class="form-group row">
<label for="workid" class="col-md-2 col-form-label text-md-right">ID</label>
<div class="col-md-10">
<input id="workid" type="text" class="form-control @error('workid') is-invalid @enderror" name="workid" value="{{ $work->id }}" required autocomplete="workid" autofocus>
@error('workid')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="workname" class="col-md-2 col-form-label text-md-right">Name</label>
<div class="col-md-10">
<input id="workname" type="text" class="form-control @error('workname') is-invalid @enderror" name="workname" value="{{$work->name}}" required autocomplete="workname">
@error('workname')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-2">
<button type="submit" class="btn btn-primary">
Update
</button>
</div>
</div>
</form>
System details
- php artisan serve on Windows 10
- PHP Version 7.2
- Laravel Version 6.2
- Laravel-OCI8 Version 6.1
Can you write a route ?
I am suspecting it has something to do with oracle default autocommit off
Auto-commit is on by default when using the package unless you have some codes that opens a transaction.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.