@extends('admin.layouts.app')
@section('page_title', __('Storage Driver'))

@section('css')
    <link rel="stylesheet" href="{{ asset('Modules/CMS/Resources/assets/css/style.min.css') }}">
    <link rel="stylesheet" href="{{ asset('public/dist/css/product.min.css') }}">
@endsection

@section('content')
@php
    $isDriverActive = function($name) {
        try {
            return Illuminate\Support\Facades\Storage::disk($name)->url('public/uploads') != '/public/uploads';
        } catch (\Throwable $th) {
            return false;
        }
    };
@endphp
<meta name="csrf-token" content="{{ csrf_token() }}">
  <!-- Main content -->
<div class="col-sm-12">
    <div class="card">
        <div class="card-body row">
            <div class="col-lg-3 col-12 z-index-10 pe-0 ps-0 ps-md-3">
                @include('storagedriver::layouts.includes.storage_driver_menu')
            </div>
            <div class="col-lg-9 col-12 ps-0">
                <div class="card card-info shadow-none mb-0">
                    <div class="card-header p-t-20 border-bottom">
                        <h5>{{ __('Storage Driver') }}</h5>
                    </div>
                    <div class="card-block table-border-style">
                        <form action="{{ route('storagedriver') }}" method="post" class="form-horizontal">
                            @csrf
                            <div class="card-body p-0">
                                <div class="form-group row">
                                    <label class="col-sm-3 control-label text-left" for="inputEmail3">{{ __('Storage Driver') }}</label>
                                    <div class="col-sm-6">
                                        <select name="name" class="form-control select2-hide-search">
                                            @foreach (['local' => __('Local'), 'amazon-s3' => __('Amazon s3'), 'digital-ocean' => __('Digital Ocean'), 'wasabi' => __('Wasabi')] as $key => $value)
                                                <option @disabled(!$isDriverActive($key)) @selected($storageDriver_name == $key) value="{{ $key }}">{{ $value }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                            </div>
                            <div class="card-footer p-0">
                                <div class="form-group row">
                                    <label for="btn_save" class="col-sm-3 control-label"></label>
                                    <div class="col-sm-12">
                                        <button type="submit" class="btn form-submit custom-btn-submit float-right" id="footer-btn">
                                            {{ __('Save') }}
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('js')
    <script src="{{ asset('public/dist/js/custom/validation.min.js') }}"></script>
    <script src="{{ asset('public/dist/js/custom/settings.min.js') }}"></script>
@endsection
