@extends('backend.layouts.master')
@section('title')
Edit lecture - {{ $lesson->title }}
@endsection
@section('page-right-side')
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ route('admin.lessons.index', $course->id) }}">Lectures</a></li>
<li class="breadcrumb-item active" aria-current="page">Edit lecture</li>
</ol>
</nav>
@endsection
@section('admin-content')
@section('admin-content')
<form action="{{ route('admin.lessons.update', [$course->id, $lesson->id]) }}" method="post"
enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<div class="col-12 col-md-3">
<div class="row">
<div class="col-12 mb-3">
<label for="chapter_id" class="form-label">
Chapter <span class="text-danger">*</span>
</label>
<select name="chapter_id" id="chapter_id" class="form-control">
<option value="">--Select--</option>
@foreach ($chapters as $chapter)
<option
value="{{ $chapter->id }}"{{ $lesson->chapter_id == $chapter->id ? 'selected' : '' }}>
{{ $chapter->title }}
</option>
@endforeach
</select>
</div>
<div class="col-12 mb-3">
<label for="status" class="form-label">
Status <span class="text-danger">*</span>
</label>
<select name="status" id="status" class="form-control">
<option value="1" {{ $lesson->status == 1 ? 'selected' : '' }}>Active</option>
<option value="0" {{ $lesson->status == 0 ? 'selected' : '' }}>Inactive</option>
</select>
</div>
<div class="col-12 mb-3">
<label for="label" class="form-label">
Label <span class="text-danger">*</span>
</label>
<select name="label" id="label" class="form-control">
@foreach ($labels as $label => $labelString)
<option value="{{ $label }}" {{ $lesson->label === $label ? 'selected' : '' }}>
{{ $labelString }}
</option>
@endforeach
</select>
</div>
</div>
<div class="row">
<div class="col-12 col-md-6 mb-3">
<label for="priority" class="form-label">
Priority <span class="text-info">(optional)</span>
</label>
<input type="number" name="priority" id="priority" class="form-control"
value="{{ $lesson->priority }}">
</div>
<div class="col-12 col-md-6 mb-3">
<label for="value" class="form-label">
Value <span class="text-info">(optional)</span>
</label>
<input type="number" name="value" id="value" class="form-control"
value="{{ $lesson->value }}">
</div>
</div>
<div class="row">
<div class="col-12 mb-3">
<label for="is_free" class="form-label">
Is free ?
<span class="text-info">(optional)</span>
</label>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="is_free" id="is_free" value="1"
{{ $lesson->is_free ? 'checked' : '' }}>
<label class="form-check-label" for="is_free">Click to make it free </label>
</div>
</div>
<div class="col-12 mb-3">
<label for="is_live" class="form-label">
Is live ?
<span class="text-info">(optional)</span>
</label>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" name="is_live" id="is_live" value="1"
{{ $lesson->is_live ? 'checked' : '' }}>
<label class="form-check-label" for="is_live">Click to make it live </label>
</div>
</div>
<div class="col-12 mb-3">
<label for="banner" class="form-label">
Banner image <span class="text-info">(optional)</span>
</label>
@if ($lesson->banner)
<a href="{{ Storage::url($lesson->banner) }}" target="_blank">
<img src="{{ Storage::url($lesson->banner) }}" alt="" width="50" />
</a>
@endif
<input type="file" name="banner" id="banner" class="form-control">
</div>
</div>
</div>
<div class="col-12 col-md-9">
<div class="card card-body">
<div class="row">
<div class="col-12 col-md-9 mb-3">
<label for="title" class="form-label">
Title
<span class="text-danger">*</span>
</label>
<input type="text" class="form-control" name="title" id="title"
placeholder="Enter lecture name" required value="{{ $lesson->title }}">
</div>
<div class="col-12 col-md-3 mb-3">
<label for="type" class="form-label">
Type
<span class="text-danger">*</span>
</label>
<select name="type" id="type" class="form-control" required>
@foreach ($types as $type => $typeString)
<option value="{{ $type }}" {{ $lesson->type === $type ? 'selected' : '' }}>
{{ $typeString }}
</option>
@endforeach
</select>
</div>
<div class="col-12 col-md-12 mb-3 is-video">
<div class="d-flex justify-content-between">
<label for="video_url" class="form-label">
Video file / Embedd URL
<span class="text-danger">*</span>
@if (!empty($lesson->video_url))
<a href="{{ Storage::url($lesson->video_url) }}" target="_blank">
<i class="fa fa-download"></i>
</a>
@endif
</label>
<label>
<input type="checkbox" id="is-video-checkbox"
{{ !empty($lesson->video_url) ? 'checked' : '' }}>
Provide Video
</label>
</div>
<input type="file" name="video_url" id="video_url" class="form-control">
<input type="url" name="embedded_url" id="embedded_url" class="form-control"
placeholder="Enter embedd URL" value="{{ $lesson->embedded_url }}">
</div>
<div class="col-12 col-md-12 mb-3">
<label for="editor" class="form-label">
Description
<span class="text-danger">*</span>
</label>
<textarea class="form-control" name="description" id="editor" rows="3">{!! $lesson->description !!}</textarea>
</div>
<div class="col-6 col-md-6 mb-3">
<label for="meta_description" class="form-label">
Meta Description
<span class="text-info">(optional)</span>
</label>
<textarea class="form-control" name="meta_description" id="meta_description" rows="2">{!! $lesson->meta_description !!}</textarea>
</div>
<div class="col-6 col-md-6 mb-3">
<label for="meta_keywords" class="form-label">
Meta Keywords
<span class="text-info">(optional)</span>
</label>
<textarea class="form-control" name="meta_keywords" id="meta_keywords" rows="2">{!! $lesson->meta_keywords !!}</textarea>
</div>
</div>
<div class="mb-3">
<a href="{{ route('admin.lessons.index', $course->id) }}" class="btn btn-secondary mr-3">
Cancel
</a>
<button type="submit" class="btn btn-success">
Save
</button>
</div>
</div>
</div>
</div>
</form>
@endsection
@section('scripts')
<script>
const isVideo = parseInt("{{ !empty($lesson->video_url) ? '1' : '0' }}");
console.log(isVideo);
if (isVideo) {
$("#embedded_url").hide();
} else {
$("#video_url").hide();
}
$("#type").on('change', function(e) {
const type = e.target.value;
if (type !== 'video') {
$(".is-video").hide('slow');
} else {
$(".is-video").show('slow');
}
});
$("#is-video-checkbox").on('click', function(e) {
if ($("#is-video-checkbox").is(':checked')) {
$("#video_url").show();
$("#embedded_url").hide();
} else {
$("#video_url").hide();
$("#embedded_url").show();
}
});
</script>
@endsection
|