@extends('layouts.admin')

@section('title', 'ویرایش محتوا')

@section('content')
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    ویرایش محتوا: {{ $content->title }}
                </h2>
            </div>
            <div class="body">
                <form action="{{ route('admin.contents.update', $content->id) }}" method="POST" enctype="multipart/form-data">
                    @csrf
                    @method('PUT')
                    <div class="row clearfix">
                        <div class="col-sm-6">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="title">عنوان *</label>
                                    <input type="text" id="title" name="title" class="form-control" value="{{ old('title', $content->title) }}" required>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label for="category_id">دسته‌بندی</label>
                                <select class="form-control show-tick" id="category_id" name="category_id">
                                    <option value="">-- انتخاب کنید --</option>
                                    @foreach($categories as $category)
                                        <option value="{{ $category->id }}" {{ old('category_id', $content->category_id) == $category->id ? 'selected' : '' }}>{{ $category->name_fa }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="row clearfix">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label for="content_type">نوع محتوا *</label>
                                <select class="form-control show-tick" id="content_type" name="content_type" required>
                                    <option value="video" {{ old('content_type', $content->content_type) == 'video' ? 'selected' : '' }}>ویدیو</option>
                                    <option value="audio" {{ old('content_type', $content->content_type) == 'audio' ? 'selected' : '' }}>صوت</option>
                                    <option value="image" {{ old('content_type', $content->content_type) == 'image' ? 'selected' : '' }}>عکس</option>
                                    <option value="text" {{ old('content_type', $content->content_type) == 'text' ? 'selected' : '' }}>متن</option>
                                    <option value="pdf" {{ old('content_type', $content->content_type) == 'pdf' ? 'selected' : '' }}>PDF</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label for="status">وضعیت *</label>
                                <select class="form-control show-tick" id="status" name="status" required>
                                    <option value="draft" {{ old('status', $content->status) == 'draft' ? 'selected' : '' }}>پیش‌نویس</option>
                                    <option value="published" {{ old('status', $content->status) == 'published' ? 'selected' : '' }}>منتشر شده</option>
                                    <option value="archived" {{ old('status', $content->status) == 'archived' ? 'selected' : '' }}>آرشیو</option>
                                </select>
                            </div>
                        </div>
                         <div class="col-sm-4">
                             <div class="form-group">
                                <label for="is_premium">نوع دسترسی</label>
                                <select class="form-control show-tick" id="is_premium" name="is_premium">
                                    <option value="0" {{ old('is_premium', $content->is_premium) == '0' ? 'selected' : '' }}>رایگان</option>
                                    <option value="1" {{ old('is_premium', $content->is_premium) == '1' ? 'selected' : '' }}>پریمیوم (اشتراکی)</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="row clearfix">
                        <div class="col-sm-12">
                            <div class="form-group">
                                <div class="form-line">
                                    <label for="description">توضیحات</label>
                                    <textarea id="description" name="description" rows="5" class="form-control">{{ old('description', $content->description) }}</textarea>
                                </div>
                            </div>
                        </div>
                    </div>

                    <button type="submit" class="btn btn-primary m-t-15 waves-effect">ذخیره تغییرات</button>
                    <a href="{{ route('admin.contents.index') }}" class="btn btn-default m-t-15 waves-effect">بازگشت</a>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
