integrate image cropper for avatar upload/delete option/retouch

This commit is contained in:
2026-07-22 10:10:06 +07:00
parent 8afe7f9b38
commit 12f8d0bbda
5 changed files with 206 additions and 15 deletions
@@ -224,6 +224,13 @@ class PetaniController extends Controller
$validatedData = $this->validatePetani($request);
if ($request->input('hapus_foto') == '1') {
if ($petani->foto && Storage::exists($petani->foto)) {
Storage::delete($petani->foto);
}
$validatedData['foto'] = null;
}
if ($request->hasFile('file_ktp')) {
$file_ktp = $request->file('file_ktp');
$validatedData['path_ktp'] = $file_ktp->store('petani/ktp');
@@ -235,6 +242,10 @@ class PetaniController extends Controller
$validatedData['file_kk'] = $file_kk->getClientOriginalName();
}
if ($request->hasFile('foto')) {
if ($petani->foto && Storage::exists($petani->foto)) {
Storage::delete($petani->foto);
}
$file_foto = $request->file('foto');
$validatedData['foto'] = $file_foto->store('petani/foto');
}