git commit "implement flight management with search filter and sorting"

This commit is contained in:
2026-08-19 09:07:34 +03:30
parent 40dbf3b575
commit 700bd38c20
11 changed files with 903 additions and 237 deletions
@@ -5,14 +5,20 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\FlightStoreRequest; use App\Http\Requests\Admin\FlightStoreRequest;
use App\Models\Flight; use App\Models\Flight;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
class FlightController extends Controller 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')); return view('admin.flights.index', compact('flights'));
} }
@@ -32,7 +38,6 @@ class FlightController extends Controller
$data = $request->validated(); $data = $request->validated();
if ($request->hasFile('image')) { if ($request->hasFile('image')) {
$data['image'] = $request $data['image'] = $request
+30 -26
View File
@@ -23,65 +23,69 @@ class FlightStoreRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'airline'=>[ 'airline' => [
'required', 'required',
'string', 'string',
'max:100' 'max:100'
], ],
'flight_number'=>[ 'flight_number' => [
'required', 'required',
'string', 'string',
'max:50' 'max:50'
], ],
'origin'=>[ 'origin' => [
'required', 'required',
'string', 'string',
'max:100' 'max:100'
], ],
'destination'=>[ 'destination' => [
'required', 'required',
'string', 'string',
'max:100' 'max:100'
], ],
'departure_date'=>[ 'departure_date' => [
'required', 'required',
'date', 'string',
'after_or_equal:today' ],
], 'departure_time' => [
'departure_time'=>[
'required', 'required',
'date_format:H:i' 'date_format:H:i'
], ],
'arrival_time'=>[ 'arrival_time' => [
'required' 'required'
], ],
'flight_class'=>[ 'flight_class' => [
'nullable', 'nullable',
'string', 'string',
'max:50' 'max:50'
], ],
'capacity'=>[ 'capacity' => [
'required', 'required',
'integer', 'integer',
'min:1' 'min:1'
], ],
'price'=>[ 'price' => [
'required', 'required',
'numeric', 'numeric',
'min:0' 'min:0'
], ],
'image' => [ 'image' => [
'nullable', 'required',
'image', 'image',
'mimes:jpg,jpeg,png,webp', 'mimes:jpg,jpeg,png,webp',
'max:2048' 'max:2048'
], ],
'type'=>[ 'views'=>[
'required', 'nullable',
'integer', 'integer',
'in:0,2,3' 'min:0'
], ],
'status'=>[ 'type' => [
'required',
'integer',
'in:0,2,3'
],
'status' => [
'required', 'required',
'in:0,1,2,3,4' 'in:0,1,2,3,4'
] ]
+2
View File
@@ -39,4 +39,6 @@ class File extends Model
'original_name', 'original_name',
'path' 'path'
]; ];
} }
+46 -9
View File
@@ -6,8 +6,6 @@
namespace App\Models; namespace App\Models;
use App\Enums\FlightStatus;
use App\Enums\FlightType;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
@@ -53,6 +51,10 @@ class Flight extends Model
'status' => 'int', 'status' => 'int',
]; ];
protected $attributes = [
'views' => 0,
];
protected $fillable = [ protected $fillable = [
'airline', 'airline',
'flight_number', 'flight_number',
@@ -79,10 +81,12 @@ class Flight extends Model
{ {
return $this->hasMany(Comment::class); return $this->hasMany(Comment::class);
} }
public function favorites() public function favorites()
{ {
return $this->morphMany(Favorite::class, 'favoritable'); return $this->morphMany(Favorite::class, 'favoritable');
} }
public function reservations() public function reservations()
{ {
return $this->morphMany( return $this->morphMany(
@@ -90,15 +94,48 @@ class Flight extends Model
} }
#[Scope] #[Scope]
public function applySearch(Builder $query, array $filters): void public function applySearch(Builder $query, ?array $filters = []): void
{ {
$query $query->when($filters['search'] ?? null, function ($query, $search) {
->when($filters['origin'] ?? null, function($query,$origin){
$query->where('origin',$origin); $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');
}
} }
} }
+14
View File
@@ -9,3 +9,17 @@ if (!function_exists('getUserFullName')) {
return $user->first_name . ' ' . $user->last_name; 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);
}
}
+511
View File
@@ -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 */;
+42 -27
View File
@@ -8,6 +8,15 @@
ثبت پرواز جدید ثبت پرواز جدید
</h4> </h4>
@if($errors->any())
<div class="alert alert-danger">
<ul class="mb-0">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('admin.flights.store') }}" <form action="{{ route('admin.flights.store') }}"
method="POST" method="POST"
@@ -83,7 +92,30 @@
</div> </div>
<div class="col-md-4 mb-3">
<label>
ساعت حرکت
</label>
<input type="time"
name="departure_time"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
ساعت رسیدن
</label>
<input type="time"
name="arrival_time"
class="form-control">
</div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
@@ -91,9 +123,11 @@
نوع پرواز نوع پرواز
</label> </label>
<option value="0">داخلی</option> <select name="type" class="form-control"> <option value="0">داخلی</option>
<option value="2">خارجی</option> <option value="2">خارجی</option>
<option value="3">چارتر</option> <option value="3">چارتر</option>
</select>
</div> </div>
@@ -176,31 +210,12 @@
وضعیت وضعیت
</label> </label>
<select name="status" <select name="status" class="form-control"> <option value="0">پیش‌نویس</option>
class="form-control"> <option value="1">فعال</option>
<option value="2">غیرفعال</option>
<option value="1"> <option value="3">تمام شده</option>
فعال <option value="4">لغو شده</option>
</option>
<option value="0">
پیش نویس
</option>
<option value="2">
غیرفعال
</option>
<option value="3">
تمام شده
</option>
<option value="4">
لغو شده
</option>
</select> </select>
</div> </div>
+121 -126
View File
@@ -8,213 +8,216 @@
ویرایش پرواز ویرایش پرواز
</h4> </h4>
@if($errors->any())
<div class="alert alert-danger">
<ul class="mb-0">
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('admin.flights.update', $flight->id) }}" <form action="{{ route('admin.flights.update',$flight->id) }}"
method="POST" method="POST"
enctype="multipart/form-data"> enctype="multipart/form-data">
@csrf @csrf
@method('PUT') @method('PUT')
<div class="row"> <div class="row">
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label>نام ایرلاین</label> <label>
ایرلاین
</label>
<input type="text" <input type="text"
name="airline" name="airline"
class="form-control" class="form-control"
value="{{ old('airline', $flight->airline) }}"> value="{{ old('airline') }}">
@error('airline') @error('airline')
<small class="text-danger"> <small class="text-danger">
{{ $message }} {{ $message }}
</small> </small>
@enderror @enderror
</div> </div>
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label>
<label>شماره پرواز</label> شماره پرواز
</label>
<input type="text" <input type="text"
name="flight_number" name="flight_number"
class="form-control" class="form-control"
value="{{ old('flight_number', $flight->flight_number) }}"> value="{{ old('flight_number') }}">
@error('flight_number')
<small class="text-danger">
{{ $message }}
</small>
@enderror
</div> </div>
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label>
<label>مبدا</label> مبدا
</label>
<input type="text" <input type="text"
name="origin" name="origin"
class="form-control" class="form-control"
value="{{ old('origin', $flight->origin) }}"> value="{{ old('origin') }}">
</div> </div>
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label>
<label>مقصد</label> مقصد
</label>
<input type="text" <input type="text"
name="destination" name="destination"
class="form-control" class="form-control"
value="{{ old('destination', $flight->destination) }}"> value="{{ old('destination') }}">
</div> </div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label>تاریخ حرکت</label> <label>
ساعت حرکت
<input type="date" </label>
name="departure_date"
class="form-control"
value="{{ old('departure_date', $flight->departure_date) }}">
</div>
<div class="col-md-4 mb-3">
<label>ساعت حرکت</label>
<input type="time" <input type="time"
name="departure_time" name="departure_time"
class="form-control" class="form-control">
value="{{ old('departure_time', $flight->departure_time) }}">
</div> </div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label>ساعت رسیدن</label> <label>
ساعت رسیدن
</label>
<input type="time" <input type="time"
name="arrival_time" name="arrival_time"
class="form-control" class="form-control">
value="{{ old('arrival_time', $flight->arrival_time) }}">
</div> </div>
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
<label>کلاس پرواز</label> <label>
نوع پرواز
<input type="text" </label>
name="flight_class"
class="form-control"
value="{{ old('flight_class', $flight->flight_class) }}">
</div>
<div class="col-md-4 mb-3">
<label>ظرفیت</label>
<input type="number"
name="capacity"
class="form-control"
value="{{ old('capacity', $flight->capacity) }}">
</div>
<div class="col-md-4 mb-3">
<label>قیمت</label>
<input type="number"
name="price"
class="form-control"
value="{{ old('price', $flight->price) }}">
</div>
<div class="col-md-6 mb-3">
<label>وضعیت</label>
<select name="status" class="form-control">
<option value="0"
{{ $flight->status == 0 ? 'selected':'' }}>
پیش نویس
</option>
<option value="1"
{{ $flight->status == 1 ? 'selected':'' }}>
فعال
</option>
<option value="2"
{{ $flight->status == 2 ? 'selected':'' }}>
غیرفعال
</option>
<option value="3"
{{ $flight->status == 3 ? 'selected':'' }}>
تمام شده
</option>
<option value="4"
{{ $flight->status == 4 ? 'selected':'' }}>
لغو شده
</option>
<select name="type" class="form-control">
<option value="0">داخلی</option>
<option value="2">خارجی</option>
<option value="3">چارتر</option>
</select> </select>
</div> </div>
<div class="col-md-4 mb-3">
<div class="col-md-6 mb-3"> <label>
تاریخ حرکت
</label>
<label>تصویر</label> <input type="text"
name="departure_date"
id="departure_date"
class="form-control"
autocomplete="off">
</div>
<div class="col-md-4 mb-3">
<label>
کلاس پرواز
</label>
<input type="text"
name="flight_class"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
ظرفیت
</label>
<input type="number"
name="capacity"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
قیمت
</label>
<input type="number"
name="price"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
عکس
</label>
<input type="file" <input type="file"
name="image" name="image"
class="form-control"> class="form-control">
</div>
@if($flight->image)
<img src="{{ asset('storage/'.$flight->image) }}"
width="120"
class="mt-2">
@endif <div class="col-md-4 mb-3">
<label>
وضعیت
</label>
<select name="status" class="form-control">
<option value="0">پیش‌نویس</option>
<option value="1">فعال</option>
<option value="2">غیرفعال</option>
<option value="3">تمام شده</option>
<option value="4">لغو شده</option>
</select>
</div> </div>
@@ -222,20 +225,12 @@
<button class="btn btn-primary"> <button class="btn btn-primary">
ذخیره تغییرات ذخیره
</button> </button>
<a href="{{ route('admin.flights.index') }}"
class="btn btn-secondary">
بازگشت
</a>
</form> </form>
</div> </div>
@endsection @endsection
+12 -1
View File
@@ -111,13 +111,17 @@
<tr> <tr>
<th> <th>
# شناسه
</th> </th>
<th> <th>
ایرلاین ایرلاین
</th> </th>
<th>
تصویر
</th>
<th> <th>
شماره پرواز شماره پرواز
</th> </th>
@@ -163,6 +167,13 @@
{{ $flight->airline }} {{ $flight->airline }}
</td> </td>
<td>
@if($flight->image)
<img src="{{ getImageUrl($flight->image) }}"
width="120">
@endif
</td>
<td> <td>
{{ $flight->flight_number }} {{ $flight->flight_number }}
+113 -43
View File
@@ -4,59 +4,129 @@
<div class="container py-5"> <div class="container py-5">
<h2 class="mb-4"> <div class="d-flex justify-content-between align-items-center mb-4">
آرشیو پروازها
</h2>
<h2 class="fw-bold">
<div class="row"> آرشیو پروازها ✈️
</h2>
@foreach($flights as $flight)
<div class="col-md-4 mb-4">
<div class="card shadow-sm">
<img src="{{ asset($flight->image) }}"
class="card-img-top"
height="200">
<div class="card-body">
<h5>
{{ $flight->airline }}
</h5>
<p>
{{ $flight->origin }}
-
{{ $flight->destination }}
</p>
<strong>
{{ number_format($flight->price) }}
تومان
</strong>
</div>
</div>
</div>
@endforeach
</div> </div>
<br>
<br>
<div class="mt-4"> <div class="row g-4">
@foreach($flights as $flight)
<div class="col-lg-4 col-md-6">
<div class="card h-100 shadow-sm border-0 rounded-4 overflow-hidden">
<div class="position-relative">
<img src="{{ getImageUrl($flight->image) }}"
class="card-img-top"
style="height:220px; object-fit:cover;"
alt="{{ $flight->airline }}">
<span class="position-absolute top-0 end-0 m-3 badge bg-primary">
{{ $flight->flight_class ?? 'Economy' }}
</span>
</div>
<div class="card-body">
<h5 class="fw-bold mb-3">
{{ $flight->airline }}
</h5>
<div class="text-muted mb-2">
<i class="bi bi-geo-alt"></i>
{{ $flight->origin }}
→
{{ $flight->destination }}
</div>
<div class="mb-2">
📅
{{ verta($flight->departure_date)->format('Y/m/d') }}
</div>
<div class="d-flex justify-content-between align-items-center mt-4">
<strong class="text-primary fs-5">
{{ number_format($flight->price) }}
تومان
</strong>
<a href="#"
class="btn btn-outline-primary rounded-pill">
مشاهده
</a>
</div>
</div>
</div>
</div>
@endforeach
</div>
<div class="mt-5 d-flex justify-content-center">
{{ $flights->links() }} {{ $flights->links() }}
</div> </div>
</div> </div>
@endsection @endsection
+3 -1
View File
@@ -33,8 +33,10 @@ Route::prefix('admin')->name('admin.')->group(function (){
Route::prefix('tours')->name('tours.')->controller(TourController::class)->group(function (){ Route::prefix('tours')->name('tours.')->controller(TourController::class)->group(function (){
Route::get('/','index')->name('index'); Route::get('/','index')->name('index');
Route::get('create','create')->name('create');
Route::post('store','store')->name('store');
Route::prefix('{tour}')->group(function (){ Route::prefix('{tour}')->group(function (){
Route::get('show','show')->name('show');
Route::get('edit','edit')->name('edit'); Route::get('edit','edit')->name('edit');
Route::put('update','update')->name('update'); Route::put('update','update')->name('update');