

<?php $__env->startSection('title', 'إدارة المدن'); ?>
<?php $__env->startSection('page-title', 'إدارة المدن'); ?>
<?php $__env->startSection('page-icon', 'fas fa-city'); ?>

<?php $__env->startSection('content'); ?>

<div class="row g-3 mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <i class="fas fa-filter"></i>
                البحث والفلترة
            </div>
            <div class="card-body">
                <form method="GET" action="<?php echo e(route('admin.cities.index')); ?>" class="row g-3">
                    <div class="col-md-4">
                        <div class="input-group">
                            <input type="text" class="form-control" name="search"
                                   value="<?php echo e(request('search')); ?>" placeholder="البحث في المدن...">
                            <button class="btn btn-primary" type="submit">
                                <i class="fas fa-search"></i>
                            </button>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <select name="governorate_id" class="form-select" onchange="this.form.submit()">
                            <option value="">جميع المحافظات</option>
                            <?php $__currentLoopData = $governorates; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $governorate): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($governorate->id); ?>"
                                        <?php echo e(request('governorate_id') == $governorate->id ? 'selected' : ''); ?>>
                                    <?php echo e($governorate->name_ar); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-2">
                        <select name="is_active" class="form-select" onchange="this.form.submit()">
                            <option value="">جميع الحالات</option>
                            <option value="1" <?php echo e(request('is_active') == '1' ? 'selected' : ''); ?>>نشط</option>
                            <option value="0" <?php echo e(request('is_active') == '0' ? 'selected' : ''); ?>>غير نشط</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <a href="<?php echo e(route('admin.cities.create')); ?>" class="btn btn-primary">
                            <i class="fas fa-plus"></i> إضافة مدينة جديدة
                        </a>
                        <a href="<?php echo e(route('admin.cities.index')); ?>" class="btn btn-secondary">
                            <i class="fas fa-refresh"></i> إعادة تعيين
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="row g-3">
    <div class="col-12">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <div>
                    <i class="fas fa-list"></i>
                    قائمة المدن
                </div>
                <a href="<?php echo e(route('admin.cities.create')); ?>" class="btn btn-primary btn-sm">
                    <i class="fas fa-plus"></i> إضافة
                </a>
            </div>
            <div class="card-body p-0">
                <?php if($cities->count() > 0): ?>
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>الاسم بالعربية</th>
                                    <th>الاسم بالإنجليزية</th>
                                    <th>المحافظة</th>
                                    <th>الرمز</th>
                                    <th>الإحداثيات</th>
                                    <th>الترتيب</th>
                                    <th>الحالة</th>
                                    <th>الإجراءات</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($city->id); ?></td>
                                        <td><?php echo e($city->name_ar); ?></td>
                                        <td><?php echo e($city->name_en); ?></td>
                                        <td>
                                            <span class="badge badge-info"><?php echo e($city->governorate->name_ar); ?></span>
                                        </td>
                                        <td>
                                            <?php if($city->code): ?>
                                                <span class="badge badge-secondary"><?php echo e($city->code); ?></span>
                                            <?php else: ?>
                                                <span style="color: var(--text-muted);">-</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if($city->latitude && $city->longitude): ?>
                                                <small style="color: var(--text-muted);">
                                                    <?php echo e($city->latitude); ?>, <?php echo e($city->longitude); ?>

                                                </small>
                                            <?php else: ?>
                                                <span style="color: var(--text-muted);">غير محدد</span>
                                            <?php endif; ?>
                                        </td>
                                        <td><?php echo e($city->sort_order); ?></td>
                                        <td>
                                            <?php if($city->is_active): ?>
                                                <span class="badge badge-success">نشط</span>
                                            <?php else: ?>
                                                <span class="badge badge-danger">غير نشط</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <div class="btn-group" role="group">
                                                <a href="<?php echo e(route('admin.cities.show', $city)); ?>"
                                                   class="btn btn-info btn-sm" title="عرض">
                                                    <i class="fas fa-eye"></i>
                                                </a>
                                                <a href="<?php echo e(route('admin.cities.edit', $city)); ?>"
                                                   class="btn btn-warning btn-sm" title="تعديل">
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form action="<?php echo e(route('admin.cities.toggle-status', $city)); ?>"
                                                      method="POST" class="d-inline">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('PATCH'); ?>
                                                    <button type="submit" class="btn btn-<?php echo e($city->is_active ? 'secondary' : 'success'); ?> btn-sm"
                                                            title="<?php echo e($city->is_active ? 'إلغاء التفعيل' : 'تفعيل'); ?>">
                                                        <i class="fas fa-<?php echo e($city->is_active ? 'pause' : 'play'); ?>"></i>
                                                    </button>
                                                </form>
                                                <form action="<?php echo e(route('admin.cities.destroy', $city)); ?>"
                                                      method="POST" class="d-inline"
                                                      onsubmit="return confirm('هل أنت متأكد من حذف هذه المدينة؟')">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="submit" class="btn btn-danger btn-sm" title="حذف">
                                                        <i class="fas fa-trash"></i>
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="p-3 border-top" style="border-color: rgba(255,255,255,0.04) !important;">
                        <?php echo e($cities->appends(request()->query())->links('pagination::bootstrap-4')); ?>

                    </div>
                <?php else: ?>
                    <div class="empty-state">
                        <i class="fas fa-city d-block"></i>
                        لا توجد مدن
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\taxi_app\resources\views/admin/cities/index.blade.php ENDPATH**/ ?>