Skip to content

Commit

Permalink
fix bug create family
Browse files Browse the repository at this point in the history
  • Loading branch information
sahrulprograming committed Oct 22, 2022
1 parent 290c15c commit 5e53cb0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
19 changes: 15 additions & 4 deletions resources/views/family/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 11,26 @@
<section class="flex flex-col items-center mt-24">
<x-fotoProfile image="{{ asset('images/profile/default.jpg') }}"></x-fotoProfile>
<input type="file" id="foto" name="image" hidden accept="image/jpg, image/png, image/jpeg">
<script>
$('#foto').on('change', function() {
const image = $('#foto');
const imgPreview = $('[alt="foto-profile"]');
const ofReader = new FileReader();
ofReader.readAsDataURL(image[0].files[0]);
ofReader.onload = function(ofREvent) {
imgPreview.attr('src', ofREvent.target.result)
}
})
</script>
</section>
{{-- End foto profile --}}

{{-- Form Edit --}}
<div class="px-4 mb-20">
@error("name")
<div class="px-3 py-3 bg-pink-600 text-center">
<span>{{ $message }}</span>
</div>
@error('name')
<div class="px-3 py-3 bg-pink-600 text-center">
<span>{{ $message }}</span>
</div>
@enderror
<x-input value="{{ old('name') }}" label="Nama Lengkap" name="name" />
<x-select name="gender" label="Jenis Kelamin">
Expand Down
20 changes: 17 additions & 3 deletions resources/views/family/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 4,10 @@

<x-topbarMobile title="{{ $title }}">
<form action="/families/{{ $family->name }}" class="d-inline" method="post" enctype="multipart/form-data">
@method("delete")
@method('delete')
@csrf
<button type="submit" class="material-icons text-red-500 hover:text-red-500 focus:text-red-500 cursor-pointer"
<button type="submit"
class="material-icons text-red-500 hover:text-red-500 focus:text-red-500 cursor-pointer"
style="font-size: 28px" onclick="return confirm('Are you sure ?')">
delete_forever
</button>
Expand All @@ -17,8 18,21 @@
@method('PUT')
@csrf
<section class="flex flex-col items-center mt-20">
<x-fotoProfile image="{{ asset('storage/' . $family->image) }}"></x-fotoProfile>
<x-fotoProfile
image="{{ str_contains($user->image, 'https://') ? $user->image : asset('storage/' . $user->image) }}">
</x-fotoProfile>
<input type="file" id="foto" name="image" hidden accept="image/jpg, image/png, image/jpeg">
<script>
$('#foto').on('change', function() {
const image = $('#foto');
const imgPreview = $('[alt="foto-profile"]');
const ofReader = new FileReader();
ofReader.readAsDataURL(image[0].files[0]);
ofReader.onload = function(ofREvent) {
imgPreview.attr('src', ofREvent.target.result)
}
})
</script>
</section>
{{-- End foto profile --}}
<div class="px-4 mb-4">
Expand Down

0 comments on commit 5e53cb0

Please sign in to comment.