Hello I was trying to use the Edit function from Laravel CRUD with resource. The problem that I got is that the form is not filling any of the old data that I already created using the value="{{ old('kodecust', $customer->kodecust ) }}"````` or `````value="{{ $customer->kodecust ) }}"
. The other function like Read,Delete, and Create are working except the Update/Edit.
Here is my Route:
Route::resource('/customer/mastercustomer', CustomerController::class)->except(['destroy'])->middleware("auth");
Route::delete('/customer/mastercustomer/{customer:perusahaancust}', [CustomerController::class, 'destroy'])->middleware('auth');
My Controller:
public function edit(Customer $customer)
{
return view('MasterCustomereditcustomer', [
"customer" => $customer,
"title" => "Edit Customer"
]);
}
And My View:
<tr>
<td><label for="kodecust">Kode</label></td>
<td>
<input type="text" name="kodecust" id="kodecust" value="{{ old('kodecust', $customer->kodecust ) }}" required style="width: 50px"
@error('kodecust') class="is-invalid" @enderror>
@error('kodecust')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</td>
<td><label for="perusahaancust">Perusahaan</label></td>
<td>
<input type="text" name="perusahaancust" id="perusahaancust" value="{{ old('perusahaancust', $customer->perusahaancust) }}" required
style="width: 200px" @error('perusahaancust') class="is-invalid" @enderror>
@error('perusahaancust')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</td>
</tr>
<tr>
<td><label for="kontakcust">Kontak</label></td>
<td>
<input type="text" name="kontakcust" id="kontakcust" value="{{ old('kontakcust', $customer->kontakcust) }}" required style="width: 100px"
@error('kontakcust') class="is-invalid" @enderror>
@error('kontakcust')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</td>
<td><label for="kotacust">Kota</label></td>
<td>
<input type="text" name="kotacust" id="kotacust" value="{{ old('kotacust', $customer->kotacust) }}" required style="width: 150px"
@error('kotacust') class="is-invalid" @enderror>
@error('kotacust')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</td>
</tr>
Let me know if you guys wanted to see more of my code. I will appreciate any help, thankyou!
I already created using the value="{{ old('kodecust', $customer->kodecust ) }}"````` or `````value="{{ $customer->kodecust ) }}"
.