 
<?php $__env->startSection('title', 'Tambah Portofolio'); ?> 
<?php $__env->startSection('content'); ?>

<div class="container">
    <form method="POST" action="<?php echo e(route('portofolios.store')); ?>" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>

        <div class="d-flex justify-content-between align-items-start flex-lg-row flex-column">

            <div class="text-center p-4 pt-0 d-flex flex-column">
                
                <label for="image" class="upload-box d-flex flex-column align-items-center justify-content-center">
                    <div id="image-preview">
                        <div id="image-instruction">Upload Foto</div>
                    </div>

                    <img id="preview-img" src="#" alt="Preview">

                    <div id="file-name"></div>
                </label>

                <input 
                    type="file" 
                    name="image" 
                    id="image" 
                    class="d-none" 
                    accept="image/*"
                    onchange="previewImage(event)"
                >

                <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="text-danger mt-1"><?php echo e($message); ?></div>
                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>

                <button type="button" id="remove-image-btn"
                    class="btn btn-outline-danger remove-btn"
                    style="display:none;"
                    onclick="removeImage()"
                >
                    Hapus File
                </button>
            </div>

            <div class="w-100">

                <?php if (isset($component)) { $__componentOriginal262894a2c291df91ae9f7b925bf8a923 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal262894a2c291df91ae9f7b925bf8a923 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text','data' => ['inRowLabel' => 'Judul','name' => 'title','required' => true,'placeholder' => 'MAsukkan judul portofolio','value' => old('title'),'errorMessage' => $errors->first('title')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Judul','name' => 'title','required' => true,'placeholder' => 'MAsukkan judul portofolio','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('title')),'errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('title'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $attributes = $__attributesOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $component = $__componentOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__componentOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal112ecadca39af188988f468fd61b41b6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal112ecadca39af188988f468fd61b41b6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text-area','data' => ['inRowLabel' => 'Deskripsi','name' => 'description','rows' => '3','required' => true,'placeholder' => 'Masukkan deskripsi portofolio','errorMessage' => $errors->first('description')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text-area'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Deskripsi','name' => 'description','rows' => '3','required' => true,'placeholder' => 'Masukkan deskripsi portofolio','errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('description'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal112ecadca39af188988f468fd61b41b6)): ?>
<?php $attributes = $__attributesOriginal112ecadca39af188988f468fd61b41b6; ?>
<?php unset($__attributesOriginal112ecadca39af188988f468fd61b41b6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal112ecadca39af188988f468fd61b41b6)): ?>
<?php $component = $__componentOriginal112ecadca39af188988f468fd61b41b6; ?>
<?php unset($__componentOriginal112ecadca39af188988f468fd61b41b6); ?>
<?php endif; ?>

                <div class="d-flex justify-content-between pe-2 mt-4">
                    <?php if (isset($component)) { $__componentOriginalb04da7a8feb93a7268b6e0eef6b32739 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.gold-button','data' => ['type' => 'button','onclick' => 'window.location.href=\''.e(route('portofolios.index')).'\'']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('gold-button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','onclick' => 'window.location.href=\''.e(route('portofolios.index')).'\'']); ?>
                        <i class="bi bi-arrow-left"></i> Kembali
                     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739)): ?>
<?php $attributes = $__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739; ?>
<?php unset($__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb04da7a8feb93a7268b6e0eef6b32739)): ?>
<?php $component = $__componentOriginalb04da7a8feb93a7268b6e0eef6b32739; ?>
<?php unset($__componentOriginalb04da7a8feb93a7268b6e0eef6b32739); ?>
<?php endif; ?>

                    <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit']); ?>
                        Tambah Portofolio
                     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
                </div>

            </div>

        </div>
    </form>
</div>

<script>
function previewImage(event) {
    const input = event.target;
    const preview = document.getElementById('preview-img');
    const fileName = document.getElementById('file-name');
    const instruction = document.getElementById('image-instruction');
    const note = document.getElementById('image-note');
    const removeBtn = document.getElementById('remove-image-btn');

    if (input.files && input.files[0]) {
        const reader = new FileReader();
        reader.onload = e => {
            preview.src = e.target.result;
            preview.style.display = 'block';
        };
        reader.readAsDataURL(input.files[0]);

        fileName.textContent =
            input.files[0].name.length > 30
                ? input.files[0].name.substring(0, 27) + "..."
                : input.files[0].name;

        instruction.style.display = 'none';
        note.style.display = 'none';
        removeBtn.style.display = 'inline-block';
    } else {
        preview.src = '#';
        preview.style.display = 'none';
        fileName.textContent = '';
        instruction.style.display = 'block';
        note.style.display = 'block';
        removeBtn.style.display = 'none';
    }
}

function removeImage() {
    const input = document.getElementById('image');
    input.value = "";
    previewImage({ target: input });
}
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.main', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\PAW\PiaZhang\resources\views/portofolios/create.blade.php ENDPATH**/ ?>