📄 crud_config.php
📁 Path: /home/skhata/excellenteducation.com.np/admin/includes/crud_config.php
📊 Size: 9.23 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
/**
* Config-driven CRUD registry. Each module maps to a table + field definitions,
* powering crud.php (list) and crud_form.php (add/edit) generically so we don't
* hand-write near-identical CRUD screens for every simple content type.
*/
function crud_modules(): array {
return [
'sliders' => [
'table' => 'sliders', 'title' => 'Hero Sliders', 'singular' => 'Slide',
'order_by' => 'sort_order ASC', 'icon' => 'fa-images',
'fields' => [
'badge_text' => ['label' => 'Badge Text', 'type' => 'text'],
'title' => ['label' => 'Title', 'type' => 'text', 'required' => true],
'subtitle' => ['label' => 'Subtitle', 'type' => 'textarea'],
'image' => ['label' => 'Background Image', 'type' => 'image', 'upload_dir' => 'sliders'],
'button_text' => ['label' => 'Button Text', 'type' => 'text'],
'button_link' => ['label' => 'Button Link (e.g. contact.php)', 'type' => 'text'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['title', 'status', 'sort_order'],
],
'features' => [
'table' => 'features', 'title' => 'Why Choose Us', 'singular' => 'Feature',
'order_by' => 'sort_order ASC', 'icon' => 'fa-star',
'fields' => [
'icon' => ['label' => 'Font Awesome Icon Class (e.g. fa-solid fa-star)', 'type' => 'text'],
'color' => ['label' => 'Accent Color', 'type' => 'select', 'options' => ['red' => 'Red', 'green' => 'Green', 'gold' => 'Gold'], 'default' => 'red'],
'title' => ['label' => 'Title', 'type' => 'text', 'required' => true],
'description' => ['label' => 'Description', 'type' => 'textarea'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['title', 'color', 'status', 'sort_order'],
],
'services' => [
'table' => 'services', 'title' => 'Services', 'singular' => 'Service',
'order_by' => 'sort_order ASC', 'icon' => 'fa-briefcase',
'fields' => [
'icon' => ['label' => 'Font Awesome Icon Class', 'type' => 'text'],
'title' => ['label' => 'Title', 'type' => 'text', 'required' => true],
'description' => ['label' => 'Description', 'type' => 'textarea'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['title', 'status', 'sort_order'],
],
'testimonials' => [
'table' => 'testimonials', 'title' => 'Testimonials', 'singular' => 'Testimonial',
'order_by' => 'sort_order ASC', 'icon' => 'fa-quote-left',
'fields' => [
'name' => ['label' => 'Student Name', 'type' => 'text', 'required' => true],
'photo' => ['label' => 'Photo', 'type' => 'image', 'upload_dir' => 'testimonials'],
'location' => ['label' => 'Location (e.g. Studying in Melbourne, Australia)', 'type' => 'text'],
'rating' => ['label' => 'Rating (1-5)', 'type' => 'number', 'default' => 5],
'message' => ['label' => 'Testimonial Message', 'type' => 'textarea'],
'video_url' => ['label' => 'Video URL (optional, for video testimonials)', 'type' => 'text'],
'sort_order'=> ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['name', 'location', 'rating', 'status'],
],
'team' => [
'table' => 'team_members', 'title' => 'Team Members', 'singular' => 'Team Member',
'order_by' => 'sort_order ASC', 'icon' => 'fa-people-group',
'fields' => [
'name' => ['label' => 'Name', 'type' => 'text', 'required' => true],
'role' => ['label' => 'Role / Title', 'type' => 'text'],
'photo' => ['label' => 'Photo', 'type' => 'image', 'upload_dir' => 'team'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['name', 'role', 'status'],
],
'partners' => [
'table' => 'partners', 'title' => 'Partners', 'singular' => 'Partner',
'order_by' => 'sort_order ASC', 'icon' => 'fa-handshake',
'fields' => [
'name' => ['label' => 'Partner / University Name', 'type' => 'text', 'required' => true],
'logo' => ['label' => 'Logo', 'type' => 'image', 'upload_dir' => 'partners'],
'website_url' => ['label' => 'Website URL', 'type' => 'text'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['name', 'website_url', 'status'],
],
'gallery_categories' => [
'table' => 'gallery_categories', 'title' => 'Gallery Categories', 'singular' => 'Category',
'order_by' => 'sort_order ASC', 'icon' => 'fa-folder',
'fields' => [
'name' => ['label' => 'Category Name', 'type' => 'text', 'required' => true, 'slug_source' => true],
'slug' => ['label' => 'Slug', 'type' => 'text', 'auto_slug' => true],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
],
'list_columns' => ['name', 'slug', 'sort_order'],
],
'gallery_items' => [
'table' => 'gallery_items', 'title' => 'Gallery Items', 'singular' => 'Gallery Item',
'order_by' => 'sort_order ASC', 'icon' => 'fa-image',
'fields' => [
'category_id' => ['label' => 'Category', 'type' => 'select_dynamic', 'options_query' => 'SELECT id, name FROM gallery_categories ORDER BY sort_order'],
'title' => ['label' => 'Title / Caption', 'type' => 'text'],
'image' => ['label' => 'Image', 'type' => 'image', 'upload_dir' => 'gallery'],
'type' => ['label' => 'Type', 'type' => 'select', 'options' => ['image' => 'Image', 'video' => 'Video'], 'default' => 'image'],
'video_url' => ['label' => 'Video URL (if type = Video)', 'type' => 'text'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['title', 'type', 'status'],
],
'blog_categories' => [
'table' => 'blog_categories', 'title' => 'Blog Categories', 'singular' => 'Category',
'order_by' => 'name ASC', 'icon' => 'fa-tags',
'fields' => [
'name' => ['label' => 'Category Name', 'type' => 'text', 'required' => true, 'slug_source' => true],
'slug' => ['label' => 'Slug', 'type' => 'text', 'auto_slug' => true],
],
'list_columns' => ['name', 'slug'],
],
'faqs' => [
'table' => 'faqs', 'title' => 'FAQs', 'singular' => 'FAQ',
'order_by' => 'group_key ASC, sort_order ASC', 'icon' => 'fa-circle-question',
'fields' => [
'group_key' => ['label' => 'Group', 'type' => 'select', 'options' => ['about' => 'About Page', 'ielts' => 'IELTS', 'toefl' => 'TOEFL', 'sat' => 'SAT', 'pte' => 'PTE', 'gre' => 'GRE', 'gmat' => 'GMAT'], 'default' => 'about'],
'question' => ['label' => 'Question', 'type' => 'text', 'required' => true],
'answer' => ['label' => 'Answer', 'type' => 'textarea'],
'sort_order' => ['label' => 'Sort Order', 'type' => 'number', 'default' => 0],
'status' => ['label' => 'Status', 'type' => 'select', 'options' => ['active' => 'Active', 'inactive' => 'Inactive'], 'default' => 'active'],
],
'list_columns' => ['group_key', 'question', 'status'],
],
];
}
function crud_module(string $key): ?array {
$modules = crud_modules();
return $modules[$key] ?? null;
}