@extends('admin.layout.app')
@section('title', 'Edit News/Podcast')
@push('custom_css')
<link rel="stylesheet" href="{{ asset('assets/js/loader/waitMe.css') }}">
@endpush
@section('content')
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">Edit News & Podcasts</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="{{route('admin.dashboard')}}">Dashboard</a></li>
<li class="breadcrumb-item active">Edit News & Podcasts</li>
</ol>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header align-items-center d-flex">
<h4 class="card-title mb-0 flex-grow-1">Edit News & Podcasts</h4>
</div><!-- end card header -->
<div class="card-body">
<form method="post" data-post-uri="{{route('admin.news_podcasts.update',$thisNews->id)}}"
id="podcast_form" data-type="edit">
<div class="row gy-4 mb-3">
<div class="col-md-6">
<div>
<label for="placeholderInput" class="form-label">Type</label>
<select class="form-select mb-3" aria-label="Default select example" name="type"
id="select_type" disabled>
<option @if($thisNews->type == 1)selected @endif value="1">News</option>
<option @if($thisNews->type == 2)selected @endif value="2">Podcasts</option>
</select>
</div>
</div>
<div class="col-md-6">
<div>
<label for="placeholderInput" class="form-label">Headline</label>
<input type="text" class="form-control" placeholder="Enter headline"
name="title" value="{{$thisNews->title}}">
</div>
</div>
<!--end col-->
</div>
<div id="audio_area">
</div>
<div>
<div>
<label for="placeholderInput" class="form-label">Description</label>
<textarea id="editor">{{$thisNews->description}}</textarea>
</div>
</div>
<div class="mt-3">
<button type="submit" class="btn btn-primary" id="submit">Submit</button>
</div>
</form>
</div>
</div>
@endsection
@push('custom_scripts')
<script src="{{ asset('assets/js/loader/waitMe.js') }}"></script>
<script src="{{asset('assets/js/custom/news_podcasts.js')}}"></script>
{{-- <script src="{{asset('assets/js/pages/form-editor.init.js')}}"></script>--}}
<script>
if ($("#select_type").val() == 2) {
addAudioFile()
}
function addAudioFile() {
$('#audio_area').html('<div class="row gy-4 align-items-end d-flex mb-3"> ' +
'<div class="col-md-6"> <div> <label for="placeholderInput" class="form-label">Change Audio</label> ' +
'<input class="form-control" type="file" accept="audio/*" id="audio" value="{{route('image', ['news_podcasts/audios', $thisNews->audio_file])}}">' +
' <input class="form-control" type="text" name="audio_file" hidden> ' +
'</div> ' +
'</div> ' +
'<div class="col-md-6"> <div> <label for="placeholderInput" class="form-label">Current Audio</label><br> ' +
' <audio controls="controls" style="height: 35px;">'+
' <source src="{{route('image', ['news_podcasts', $thisNews->audio_file])}}" type="audio/mpeg" />'+
' Your browser does not support the audio element.'+
' </audio>' +
'</div> ' +
'</div> ' +
'</div>')
$('#audio').on('change', function () {
getBase64($(this)[0].files[0]).then(
data => $('input[name="audio_file"]').val(data)
)
})
}
</script>
@endpush