I want to update column status in table transaction automatically but I got this error:
Too few arguments to function App\Http\Controllers\TransactionController::updateconfirmed(), 0 passed and exactly 1 expected
Here is the scenario: 1. User's status: hasn't payed 2. When I click button Confirmed, system send pusher notification to user that her/ his payment has been payed 3. Then my system return to confirmed.blade to give me a notif, then return to index, with status change to payed
This is my transaction blade:
@foreach($transactions as $transaction)
<tr>
<td>{{$transaction['id']}}</td>
<td>{{$transaction['user_id']}}</td>
<td>{{$transaction['cara']}}</td>
<td>{{$transaction['start']}}</td>
<td>{{$transaction['end']}}</td>
<td>{{$transaction['total']}}</td>
<td><img src="fetch_image{{$transaction->id}}" class="img-thumbnail" width="75"/> </td>
<td>{{$transaction['status']}}</td>
<td><a href="{{action('TransactionController@updateconfirmed', $transaction['id'])}}" class="btn btn-success">Konfirmasi</a></td>
This is my transaction controller:
public function updateconfirmed($id)
{
$transaction = Transaction::find($id);
DB::update('update transactions set status = Lunas where id = ?', ['$id']);
return view('confirmed');
}
This is my confirmed.blade:
<div class="col-md-6">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header" align="left">Confirmed</div>
<div class="card-body">
<p align="left">Event confirmed has been sent!</p>
<div class="col-md-6">
<a href="{{Action('TransactionController@index')}}" class="btn btn-primary">Back</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
This is my route:
Route::get('/confirmed', function () {
event(new App\Events\StatusConfirmed('Admin'));
return view('confirmed');
})->name('confirmed');
Route::get('/updateconfirmed', 'TransactionController@updateconfirmed');
Thanks
Try this: Route::get('/updateconfirmed/{id}', 'TransactionController@updateconfirmed');
The error because you are not passing the id(which one have to update) in your route
update: can try this also or Like other answer
$transaction = Transaction::find($id);
$transaction->update(['field_name' => value]);
return view('confirmed');
Try this instead of DB::....$transaction->status = 'Lunas';$transaction->save(); or just put Lunas between ""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.