diff --git a/app/Http/Controllers/Admin/FlightController.php b/app/Http/Controllers/Admin/FlightController.php index 00e835c..6d4e3c0 100644 --- a/app/Http/Controllers/Admin/FlightController.php +++ b/app/Http/Controllers/Admin/FlightController.php @@ -5,14 +5,20 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Http\Requests\Admin\FlightStoreRequest; use App\Models\Flight; +use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; class FlightController extends Controller { - public function index() + public function index(Request $request) { - $flights = Flight::latest()->paginate(4); + $flights = Flight::query() + ->applySearch($request->all()) + ->filterType($request->type) + ->sort($request->sort) + ->latest() + ->paginate(4); return view('admin.flights.index', compact('flights')); } @@ -32,7 +38,6 @@ class FlightController extends Controller $data = $request->validated(); - if ($request->hasFile('image')) { $data['image'] = $request diff --git a/app/Http/Requests/Admin/FlightStoreRequest.php b/app/Http/Requests/Admin/FlightStoreRequest.php index 280c87c..c79e500 100644 --- a/app/Http/Requests/Admin/FlightStoreRequest.php +++ b/app/Http/Requests/Admin/FlightStoreRequest.php @@ -23,65 +23,69 @@ class FlightStoreRequest extends FormRequest public function rules(): array { return [ - 'airline'=>[ + 'airline' => [ 'required', 'string', 'max:100' ], - 'flight_number'=>[ - 'required', + 'flight_number' => [ + 'required', 'string', 'max:50' ], - 'origin'=>[ + 'origin' => [ 'required', 'string', 'max:100' ], - 'destination'=>[ + 'destination' => [ 'required', 'string', 'max:100' ], - 'departure_date'=>[ + 'departure_date' => [ 'required', - 'date', - 'after_or_equal:today' - ], - 'departure_time'=>[ + 'string', + ], + 'departure_time' => [ 'required', 'date_format:H:i' ], - 'arrival_time'=>[ + 'arrival_time' => [ 'required' ], - 'flight_class'=>[ + 'flight_class' => [ 'nullable', 'string', 'max:50' ], - 'capacity'=>[ + 'capacity' => [ 'required', 'integer', 'min:1' ], - 'price'=>[ + 'price' => [ 'required', 'numeric', 'min:0' ], - 'image' => [ - 'nullable', - 'image', - 'mimes:jpg,jpeg,png,webp', - 'max:2048' - ], - 'type'=>[ - 'required', - 'integer', - 'in:0,2,3' - ], - 'status'=>[ + 'image' => [ + 'required', + 'image', + 'mimes:jpg,jpeg,png,webp', + 'max:2048' + ], + 'views'=>[ + 'nullable', + 'integer', + 'min:0' + ], + 'type' => [ + 'required', + 'integer', + 'in:0,2,3' + ], + 'status' => [ 'required', 'in:0,1,2,3,4' ] diff --git a/app/Models/File.php b/app/Models/File.php index 2fd7955..a214c2b 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class File - * + * * @property int $id * @property string $name * @property string $extension @@ -39,4 +39,6 @@ class File extends Model 'original_name', 'path' ]; + + } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 1c9fd45..6475380 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -6,8 +6,6 @@ namespace App\Models; -use App\Enums\FlightStatus; -use App\Enums\FlightType; use Carbon\Carbon; use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; @@ -53,6 +51,10 @@ class Flight extends Model 'status' => 'int', ]; + protected $attributes = [ + 'views' => 0, + ]; + protected $fillable = [ 'airline', 'flight_number', @@ -79,10 +81,12 @@ class Flight extends Model { return $this->hasMany(Comment::class); } + public function favorites() { return $this->morphMany(Favorite::class, 'favoritable'); } + public function reservations() { return $this->morphMany( @@ -90,15 +94,48 @@ class Flight extends Model } #[Scope] - public function applySearch(Builder $query, array $filters): void + public function applySearch(Builder $query, ?array $filters = []): void { - $query - ->when($filters['origin'] ?? null, function($query,$origin){ - $query->where('origin',$origin); - }) + $query->when($filters['search'] ?? null, function ($query, $search) { + + $query->where(function ($q) use ($search) { + + $q->where('airline', 'like', "%{$search}%") + ->orWhere('flight_number', 'like', "%{$search}%") + ->orWhere('origin', 'like', "%{$search}%") + ->orWhere('destination', 'like', "%{$search}%"); - ->when($filters['destination'] ?? null, function($query,$destination){ - $query->where('destination',$destination); }); + + }); + } + + + #[Scope] + public function filterType(Builder $query, $type = null): void + { + $query->when($type !== null && $type !== '', function ($query) use ($type) { + + $query->where('type', $type); + + }); + } + + + #[Scope] + public function sort(Builder $query, $sort = null): void + { + if ($sort == 'price_asc') { + + $query->orderBy('price', 'asc'); + + } + + + if ($sort == 'price_desc') { + + $query->orderBy('price', 'desc'); + + } } } diff --git a/app/helpers/helpers.php b/app/helpers/helpers.php index e0c6802..61e3108 100644 --- a/app/helpers/helpers.php +++ b/app/helpers/helpers.php @@ -9,3 +9,17 @@ if (!function_exists('getUserFullName')) { return $user->first_name . ' ' . $user->last_name; } } + +if (!function_exists('getImageUrl')) { + + function getImageUrl(?string $path): ?string + { + if (!$path) { + return null; + } + + return \Illuminate\Support\Facades\Storage::url($path); + } + +} + diff --git a/database/backup/airline_agency (3).sql b/database/backup/airline_agency (3).sql new file mode 100644 index 0000000..104c17e --- /dev/null +++ b/database/backup/airline_agency (3).sql @@ -0,0 +1,511 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.3 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1:3306 +-- Generation Time: Aug 18, 2026 at 04:18 PM +-- Server version: 8.4.7 +-- PHP Version: 8.3.28 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `airline_agency` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `admins` +-- + +DROP TABLE IF EXISTS `admins`; +CREATE TABLE IF NOT EXISTS `admins` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `first_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `last_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + `mobile` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL, + `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `status` tinyint NOT NULL DEFAULT '1' COMMENT 'Status: Inactive=0, Active=1, Blocked=2', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`), + UNIQUE KEY `mobile` (`mobile`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `admins` +-- + +INSERT INTO `admins` (`id`, `first_name`, `last_name`, `username`, `email`, `mobile`, `password`, `image`, `status`, `created_at`, `updated_at`) VALUES +(2, 'hatame', 'andarza', 'hatame14', 'hatame14@gmail.com', '09119533286', '$2y$12$3ms35N3wjROPUQkTL9hYA.Gd7V4qZqKkKimkWbhApqoZFA7w/UDmy', NULL, 1, '2026-08-18 08:03:58', '2026-08-18 09:14:58'), +(3, 'melika', 'ghobadi', 'mina14', 'hatame@gmail.com', '09119533278', '$2y$12$qoJVvwBKEIDDYMsYvGJnGO4zREv15706PPZORBM0ectUKaH1POevu', NULL, 1, '2026-08-18 10:23:53', '2026-08-18 10:34:13'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `admin_roles` +-- + +DROP TABLE IF EXISTS `admin_roles`; +CREATE TABLE IF NOT EXISTS `admin_roles` ( + `admin_id` bigint UNSIGNED NOT NULL, + `role_id` bigint UNSIGNED NOT NULL, + PRIMARY KEY (`admin_id`,`role_id`), + KEY `fk_admin_roles_role` (`role_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `admin_roles` +-- + +INSERT INTO `admin_roles` (`admin_id`, `role_id`) VALUES +(2, 1), +(3, 2); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `cities` +-- + +DROP TABLE IF EXISTS `cities`; +CREATE TABLE IF NOT EXISTS `cities` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `province_id` bigint UNSIGNED NOT NULL, + `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `comments` +-- + +DROP TABLE IF EXISTS `comments`; +CREATE TABLE IF NOT EXISTS `comments` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` bigint UNSIGNED DEFAULT NULL, + `tour_id` bigint UNSIGNED DEFAULT NULL, + `flight_id` bigint UNSIGNED DEFAULT NULL, + `rating` tinyint NOT NULL, + `comment` text COLLATE utf8mb4_unicode_ci, + `status` tinyint NOT NULL DEFAULT '0' COMMENT 'Status: 0=Pending, 1=Approved, 2=Rejected', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `tour_id` (`tour_id`), + KEY `user_id` (`user_id`), + KEY `comments_ibfk_3` (`flight_id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `comments` +-- + +INSERT INTO `comments` (`id`, `user_id`, `tour_id`, `flight_id`, `rating`, `comment`, `status`, `created_at`, `updated_at`) VALUES +(17, NULL, 2, NULL, 5, 'عالیی', 0, '2026-08-18 04:38:26', '2026-08-18 04:38:26'), +(19, NULL, 5, NULL, 5, 'خیلی تور خوبی بود', 0, '2026-08-18 08:37:10', '2026-08-18 08:37:10'), +(20, 6, NULL, 2, 5, 'asggsz', 0, '2026-08-18 12:03:38', '2026-08-18 12:03:38'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `favorites` +-- + +DROP TABLE IF EXISTS `favorites`; +CREATE TABLE IF NOT EXISTS `favorites` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` bigint UNSIGNED NOT NULL, + `favoritable_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `favoritable_id` bigint UNSIGNED NOT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `unique_favorite` (`user_id`,`favoritable_type`,`favoritable_id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `favorites` +-- + +INSERT INTO `favorites` (`id`, `user_id`, `favoritable_type`, `favoritable_id`, `created_at`) VALUES +(5, 5, 'App\\Models\\Tour', 3, '2026-08-18 05:19:17'), +(6, 6, 'App\\Models\\Tour', 2, '2026-08-18 11:59:38'), +(7, 6, 'App\\Models\\Tour', 5, '2026-08-18 12:11:45'), +(8, 6, 'App\\Models\\Tour', 3, '2026-08-18 15:09:57'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `files` +-- + +DROP TABLE IF EXISTS `files`; +CREATE TABLE IF NOT EXISTS `files` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `extension` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, + `size` bigint UNSIGNED NOT NULL, + `original_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `flights` +-- + +DROP TABLE IF EXISTS `flights`; +CREATE TABLE IF NOT EXISTS `flights` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `airline` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `flight_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `origin` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `destination` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `departure_date` date DEFAULT NULL, + `departure_time` time DEFAULT NULL, + `arrival_time` time DEFAULT NULL, + `flight_class` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `capacity` int DEFAULT NULL, + `price` decimal(10,2) DEFAULT NULL, + `image` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `views` int NOT NULL, + `type` int NOT NULL COMMENT 'internal=0\r\n,external=2\r\n,charter=3', + `status` tinyint DEFAULT NULL COMMENT 'Status: 0=Draft, 1=Active, 2=Inactive, 3=Finished, 4=Cancelled', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `flights` +-- + +INSERT INTO `flights` (`id`, `airline`, `flight_number`, `origin`, `destination`, `departure_date`, `departure_time`, `arrival_time`, `flight_class`, `capacity`, `price`, `image`, `views`, `type`, `status`, `created_at`, `updated_at`) VALUES +(1, 'ایران ایر', 'IR123', 'تهران', 'مشهد', '2026-08-20', '08:30:00', '10:00:00', 'Economy', 150, 2500000.00, 'assets/img/side_banners/flight/1.jpg', 51, 0, 1, '2026-08-17 04:29:53', '2026-08-18 12:11:56'), +(2, 'کیش ایر', 'QR450', 'تهران', 'دوحه', '2026-09-05', '18:00:00', '20:30:00', 'Business', 100, 12000000.00, 'assets/img/side_banners/flight/3.jpg', 46, 0, 1, '2026-08-17 04:32:47', '2026-08-18 12:03:38'), +(3, 'بیلبظی', 'IR124', 'ربلبط', 'سشیبلاتن', '2026-09-05', '08:30:00', '20:30:00', 'Economy', 100, 500000.00, '', 0, 10, 1, '2026-08-18 15:48:34', '2026-08-18 15:48:34'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `permissions` +-- + +DROP TABLE IF EXISTS `permissions`; +CREATE TABLE IF NOT EXISTS `permissions` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `uq_permissions_name` (`name`), + UNIQUE KEY `uq_permissions_slug` (`slug`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `permissions` +-- + +INSERT INTO `permissions` (`id`, `name`, `slug`, `description`, `created_at`, `updated_at`) VALUES +(1, ' درج پرواز\r\n \r\n', ' flight_create \r\n', ' اجازه ثبت پرواز\r\n', '2026-08-18 10:04:41', '2026-08-18 10:04:41'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `provinces` +-- + +DROP TABLE IF EXISTS `provinces`; +CREATE TABLE IF NOT EXISTS `provinces` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `provinces` +-- + +INSERT INTO `provinces` (`id`, `name`, `created_at`, `updated_at`) VALUES +(1, 'مازندران', NULL, NULL), +(2, 'تهران', NULL, NULL), +(3, 'گلستان', NULL, NULL), +(4, 'گیلان', NULL, NULL), +(5, 'مشهد', NULL, NULL); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `reservations` +-- + +DROP TABLE IF EXISTS `reservations`; +CREATE TABLE IF NOT EXISTS `reservations` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` bigint UNSIGNED NOT NULL, + `reservable_id` bigint UNSIGNED NOT NULL, + `reservable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `price` int NOT NULL, + `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT 'pending', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `reservations_user_id_foreign` (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `reservations` +-- + +INSERT INTO `reservations` (`id`, `user_id`, `reservable_id`, `reservable_type`, `price`, `status`, `created_at`, `updated_at`) VALUES +(6, 5, 2, 'App\\Models\\Flight', 12000000, 'pending', '2026-08-18 04:46:03', '2026-08-18 04:46:03'), +(7, 6, 2, 'App\\Models\\Flight', 12000000, 'pending', '2026-08-18 12:00:15', '2026-08-18 12:00:15'), +(8, 6, 2, 'App\\Models\\Flight', 12000000, 'pending', '2026-08-18 12:03:56', '2026-08-18 12:03:56'), +(9, 6, 1, 'App\\Models\\Flight', 2500000, 'pending', '2026-08-18 12:11:58', '2026-08-18 12:11:58'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `roles` +-- + +DROP TABLE IF EXISTS `roles`; +CREATE TABLE IF NOT EXISTS `roles` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `slug` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL, + `description` text COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`), + UNIQUE KEY `slug` (`slug`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `roles` +-- + +INSERT INTO `roles` (`id`, `name`, `slug`, `description`, `created_at`, `updated_at`) VALUES +(1, 'مدیر پرواز', 'flight_manager', 'مدیریت بخش پرواز', '2026-08-18 10:03:15', '2026-08-18 10:03:15'), +(2, 'مدیر تور', 'Tour_management', 'مدیریت بخش تور', '2026-08-18 10:25:58', '2026-08-18 10:25:58'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `role_permissions` +-- + +DROP TABLE IF EXISTS `role_permissions`; +CREATE TABLE IF NOT EXISTS `role_permissions` ( + `role_id` bigint UNSIGNED NOT NULL, + `permission_id` bigint UNSIGNED NOT NULL, + PRIMARY KEY (`role_id`,`permission_id`), + KEY `fk_role_permissions_permission` (`permission_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `role_permissions` +-- + +INSERT INTO `role_permissions` (`role_id`, `permission_id`) VALUES +(2, 1); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `settings` +-- + +DROP TABLE IF EXISTS `settings`; +CREATE TABLE IF NOT EXISTS `settings` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `code` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, + `value` text COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `tours` +-- + +DROP TABLE IF EXISTS `tours`; +CREATE TABLE IF NOT EXISTS `tours` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `summary` text COLLATE utf8mb4_unicode_ci NOT NULL, + `description` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `image` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `travel_type_id` tinyint UNSIGNED NOT NULL, + `price` decimal(12,2) NOT NULL, + `views` int NOT NULL, + `departure_date` date NOT NULL, + `status` tinyint NOT NULL COMMENT 'Draft=0|Active=1|Inactive=2|Finished=3||Cancelled=4', + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `tours` +-- + +INSERT INTO `tours` (`id`, `title`, `summary`, `description`, `image`, `travel_type_id`, `price`, `views`, `departure_date`, `status`, `created_at`, `updated_at`) VALUES +(2, 'تور 7 روزه مشهد', 'سفر زیارتی به مشهد مقدس با هتل 4 ستاره', 'تور کامل مشهد شامل اقامت، ترانسفر و خدمات گردشگری', 'assets/img/exp-page/slider/1.jpg', 1, 4500000.00, 38, '2026-08-20', 1, '2026-08-17 07:13:38', '2026-08-18 08:36:54'), +(3, 'تور کیش 5 روزه', 'تور تفریحی کیش با هتل نزدیک دریا', 'سفر به جزیره کیش همراه با اقامت و خدمات ویژه', 'assets/img/tours/kish.jpg', 2, 6500000.00, 7, '2026-09-05', 1, '2026-08-17 07:13:38', '2026-08-18 04:42:42'), +(4, 'تور استانبول 6 روزه', 'تور خارجی استانبول با پرواز رفت و برگشت', 'اقامت در هتل، ترانسفر فرودگاهی و گشت شهری', 'assets/img/tours/istanbul.jpg', 2, 18500000.00, 1, '2026-09-15', 1, '2026-08-17 07:13:38', '2026-08-17 09:04:24'), +(5, 'تور شمال 3 روزه', 'سفر طبیعت گردی به شمال ایران', 'اقامت در ویلا و بازدید از جاذبه های گردشگری شمال', 'assets/img/tours/north.jpg', 1, 2800000.00, 2, '2026-08-28', 1, '2026-08-17 07:13:38', '2026-08-18 08:37:10'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `tour_flights` +-- + +DROP TABLE IF EXISTS `tour_flights`; +CREATE TABLE IF NOT EXISTS `tour_flights` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `tour_id` bigint NOT NULL, + `flight_id` bigint NOT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `tour_id` (`tour_id`), + KEY `flight_id` (`flight_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `travel_types` +-- + +DROP TABLE IF EXISTS `travel_types`; +CREATE TABLE IF NOT EXISTS `travel_types` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + `status` tinyint NOT NULL DEFAULT '1' COMMENT 'Status: 0=Inactive, 1=Active', + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +CREATE TABLE IF NOT EXISTS `users` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `national_code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, + `gender` tinyint NOT NULL COMMENT 'male:0 | famale:1', + `marital_status` tinyint NOT NULL COMMENT 'single:0|Married:1|Separated:2', + `spouse_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `mobile` varchar(11) COLLATE utf8mb4_unicode_ci NOT NULL, + `email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, + `profile_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `password` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, + `province_id` bigint UNSIGNED DEFAULT NULL, + `city_id` bigint UNSIGNED DEFAULT NULL, + `status` tinyint NOT NULL COMMENT 'Draft=0|Active=1|Inactive=2|Expired=3|Cancelled=4', + `created_at` timestamp NOT NULL, + `updated_at` timestamp NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`), + KEY `city_id` (`city_id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Dumping data for table `users` +-- + +INSERT INTO `users` (`id`, `first_name`, `last_name`, `national_code`, `gender`, `marital_status`, `spouse_name`, `mobile`, `email`, `profile_image`, `username`, `password`, `province_id`, `city_id`, `status`, `created_at`, `updated_at`) VALUES +(1, 'حاتمه', 'اندرزا', '2081391694', 1, 0, NULL, '09119533286', 'hatame@gmail.com', NULL, 'hatame14', '$2y$12$6OqCJMCgK3I3bckMWzVFse8xmHcsaIzqAE/GULjX74iT.FoZjqaJO', NULL, NULL, 0, '2026-08-16 05:18:26', '2026-08-16 05:18:26'), +(2, 'شهرزاد', 'زندی', '2080706640', 1, 0, NULL, '09112345678', 'shahrzad@gmail.com', NULL, 'shahrzad', '$2y$12$X5fVgkc3d/aYaLnDl6g3lOp5vjJiB0ZEl.1eepjr2e34DnuZQ9fZa', NULL, NULL, 0, '2026-08-16 05:56:30', '2026-08-16 05:56:30'), +(3, 'مینا', 'اسمعیلی', '2011093232', 1, 1, 'مهدی', '09013921486', 'mina@gmail.com', NULL, 'mina14', '$2y$12$7MKYeFaQi0PC1g8q4jQYSe6mVMpPrmGMPLsKvHVVq6Q2Q7Xx4a6qe', NULL, NULL, 0, '2026-08-16 06:38:10', '2026-08-16 06:38:10'), +(5, 'سدنا', 'اندرزا', '2081391692', 1, 1, 'محمد', '09119533281', 'fateme@gmail.com', '1787033369.jpg', 'fateme15', '$2y$12$EmRu587AaPaStm4FZRlIM..zU1angDObUIvgGhZBYBhPL6u3Fm75y', 1, NULL, 0, '2026-08-18 04:41:34', '2026-08-18 11:25:13'), +(6, 'سوگند', 'اصغری', '2150788772', 1, 0, NULL, '09032097811', 'sogand@gmail.com', '1787054360.jpg', 'sogand12', '$2y$12$595f7ziX9RVnQoLen4P11e6PSixIt02WAAi8oQRKGte0JuLN4FPBG', 1, NULL, 0, '2026-08-18 11:59:21', '2026-08-18 11:59:21'); + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `admin_roles` +-- +ALTER TABLE `admin_roles` + ADD CONSTRAINT `fk_admin_roles_admin` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_admin_roles_role` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `comments` +-- +ALTER TABLE `comments` + ADD CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`tour_id`) REFERENCES `tours` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, + ADD CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; + +-- +-- Constraints for table `favorites` +-- +ALTER TABLE `favorites` + ADD CONSTRAINT `favorites_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; + +-- +-- Constraints for table `reservations` +-- +ALTER TABLE `reservations` + ADD CONSTRAINT `reservations_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; + +-- +-- Constraints for table `role_permissions` +-- +ALTER TABLE `role_permissions` + ADD CONSTRAINT `fk_role_permissions_permission` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_role_permissions_role` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `users` +-- +ALTER TABLE `users` + ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/resources/views/admin/flights/create.blade.php b/resources/views/admin/flights/create.blade.php index 10b8986..3b3ba52 100644 --- a/resources/views/admin/flights/create.blade.php +++ b/resources/views/admin/flights/create.blade.php @@ -8,6 +8,15 @@ ثبت پرواز جدید + @if($errors->any()) +