fix(barbershop): memperbaiki logika update gambar
This commit is contained in:
parent
7a47675a37
commit
f3422aad06
@ -58,7 +58,9 @@ public function update(Barbershop $barbershop, BarbershopRequest $request): Redi
|
|||||||
|
|
||||||
DB::transaction(function () use ($barbershop, $validatedData) {
|
DB::transaction(function () use ($barbershop, $validatedData) {
|
||||||
$barbershop->update($validatedData);
|
$barbershop->update($validatedData);
|
||||||
$this->uploadAttachment($validatedData['image'], 'barbershop', Barbershop::class, $barbershop->id);
|
if (isset($validatedData['image'])) {
|
||||||
|
$this->uploadAttachment($validatedData['image'], 'barbershop', Barbershop::class, $barbershop->id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
notify()->success('Data berhasil ditambahkan', 'Berhasil');
|
notify()->success('Data berhasil ditambahkan', 'Berhasil');
|
||||||
@ -77,7 +79,7 @@ public function delete(Barbershop $barbershop): RedirectResponse
|
|||||||
|
|
||||||
notify()->success('Data berhasil dihapus', 'Berhasil');
|
notify()->success('Data berhasil dihapus', 'Berhasil');
|
||||||
|
|
||||||
return redirect('dashboard/master/barbershop');
|
return back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateActionButtons(Barbershop $barbershop): string
|
public function generateActionButtons(Barbershop $barbershop): string
|
||||||
|
|||||||
@ -25,6 +25,8 @@ protected function prepareForValidation(): void
|
|||||||
|
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
$isEdit = $this->isMethod('put');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => ['required', 'string', 'max:50'],
|
'name' => ['required', 'string', 'max:50'],
|
||||||
'contact_number' => ['required', 'string', 'regex:/^\+?\d{10,15}$/'],
|
'contact_number' => ['required', 'string', 'regex:/^\+?\d{10,15}$/'],
|
||||||
@ -33,7 +35,9 @@ public function rules(): array
|
|||||||
'opened' => ['required', 'date'],
|
'opened' => ['required', 'date'],
|
||||||
'closed' => ['nullable', 'date'],
|
'closed' => ['nullable', 'date'],
|
||||||
'cash' => ['required', 'numeric', 'min:0', 'max:99999999.99'],
|
'cash' => ['required', 'numeric', 'min:0', 'max:99999999.99'],
|
||||||
'image' => ['required', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
|
'image' => $isEdit
|
||||||
|
? ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048']
|
||||||
|
: ['required', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user