diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index d04eaf6..79fa756 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Auth; use App\Enums\UserStatus; use App\Http\Controllers\Controller; use App\Http\Requests\RegisterRequest; +use App\Models\Province; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -17,13 +18,13 @@ class RegisterController extends Controller $withoutHeader = true; $withoutFooter = true; $withoutHero = true; - - return view('auth.register',compact('withoutHeader','withoutFooter','withoutHero')); + $provinces=Province::orderBy('name')->get(); + return view('auth.register',compact('withoutHeader','withoutFooter','withoutHero','provinces')); } public function post(RegisterRequest $request) { - $inputs = $request->validated(); + $inputs = $request->validated(); if ($request->hasFile('image')) { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..dc0ebbd --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,14 @@ + [ 'required', - 'unique:users,national_code' + 'unique:users,national_code', + 'ir_national_id' ], 'gender' => [ @@ -59,14 +61,13 @@ class RegisterRequest extends FormRequest 'mobile' => [ 'required', 'unique:users,mobile', - 'ir_mobile:zero_code' + 'ir_mobile' ], 'email' => [ 'required', 'email', 'unique:users,email', - 'ir_national_id' ], 'username' => [ @@ -81,13 +82,14 @@ class RegisterRequest extends FormRequest ], 'province_id' => [ - 'required', + 'nullable', 'exists:provinces,id', ], 'city_id' => [ - 'required', - 'exists:cities,id', + 'nullable', + Rule::exists('cities', 'id') + ->where(fn ($query) => $query->where('province_id', $this->province_id)), ], diff --git a/app/Models/Admin.php b/app/Models/Admin.php index e51a2d3..4562a3b 100644 --- a/app/Models/Admin.php +++ b/app/Models/Admin.php @@ -7,6 +7,7 @@ namespace App\Models; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; /** @@ -23,12 +24,15 @@ use Illuminate\Database\Eloquent\Model; * @property int $status * @property Carbon|null $created_at * @property Carbon|null $updated_at + * + * @property Collection|Role[] $roles * * @package App\Models */ class Admin extends Model { protected $table = 'admins'; + public static $snakeAttributes = false; protected $casts = [ 'status' => 'int' @@ -48,4 +52,9 @@ class Admin extends Model 'image', 'status' ]; + + public function roles() + { + return $this->belongsToMany(Role::class, 'admin_roles'); + } } diff --git a/app/Models/AdminRole.php b/app/Models/AdminRole.php new file mode 100644 index 0000000..4d4d9e0 --- /dev/null +++ b/app/Models/AdminRole.php @@ -0,0 +1,43 @@ + 'int', + 'role_id' => 'int' + ]; + + public function admin() + { + return $this->belongsTo(Admin::class); + } + + public function role() + { + return $this->belongsTo(Role::class); + } +} diff --git a/app/Models/City.php b/app/Models/City.php new file mode 100644 index 0000000..51eb137 --- /dev/null +++ b/app/Models/City.php @@ -0,0 +1,44 @@ + 'int' + ]; + + protected $fillable = [ + 'provinces', + 'name' + ]; + + public function users() + { + return $this->hasMany(User::class); + } +} diff --git a/app/Models/Comment.php b/app/Models/Comment.php index 2893747..6233565 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -29,6 +29,7 @@ use Illuminate\Database\Eloquent\Model; class Comment extends Model { protected $table = 'comments'; + public static $snakeAttributes = false; protected $casts = [ 'user_id' => 'int', diff --git a/app/Models/Favorite.php b/app/Models/Favorite.php index 63c7ae7..c12b975 100644 --- a/app/Models/Favorite.php +++ b/app/Models/Favorite.php @@ -26,6 +26,7 @@ class Favorite extends Model { protected $table = 'favorites'; public $timestamps = false; + public static $snakeAttributes = false; protected $casts = [ 'user_id' => 'int', diff --git a/app/Models/File.php b/app/Models/File.php index 3a286fe..2fd7955 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -26,6 +26,7 @@ use Illuminate\Database\Eloquent\Model; class File extends Model { protected $table = 'files'; + public static $snakeAttributes = false; protected $casts = [ 'size' => 'int' diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 15973bb..a35469a 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -32,6 +32,7 @@ use Illuminate\Database\Eloquent\Model; class Flight extends Model { protected $table = 'flights'; + public static $snakeAttributes = false; protected $casts = [ 'departure_date' => 'datetime', diff --git a/app/Models/Permission.php b/app/Models/Permission.php new file mode 100644 index 0000000..4b4c735 --- /dev/null +++ b/app/Models/Permission.php @@ -0,0 +1,42 @@ +belongsToMany(Role::class, 'role_permissions'); + } +} diff --git a/app/Models/Province.php b/app/Models/Province.php new file mode 100644 index 0000000..92bebe9 --- /dev/null +++ b/app/Models/Province.php @@ -0,0 +1,36 @@ +hasMany(User::class); + } + +} diff --git a/app/Models/Role.php b/app/Models/Role.php new file mode 100644 index 0000000..0f7fef4 --- /dev/null +++ b/app/Models/Role.php @@ -0,0 +1,48 @@ +belongsToMany(Admin::class, 'admin_roles'); + } + + public function permissions() + { + return $this->belongsToMany(Permission::class, 'role_permissions'); + } +} diff --git a/app/Models/RolePermission.php b/app/Models/RolePermission.php new file mode 100644 index 0000000..8d25f07 --- /dev/null +++ b/app/Models/RolePermission.php @@ -0,0 +1,43 @@ + 'int', + 'permission_id' => 'int' + ]; + + public function permission() + { + return $this->belongsTo(Permission::class); + } + + public function role() + { + return $this->belongsTo(Role::class); + } +} diff --git a/app/Models/Setting.php b/app/Models/Setting.php new file mode 100644 index 0000000..7a5cb1f --- /dev/null +++ b/app/Models/Setting.php @@ -0,0 +1,32 @@ + 'int', diff --git a/app/Models/TourFlight.php b/app/Models/TourFlight.php index ec3e314..4f835e3 100644 --- a/app/Models/TourFlight.php +++ b/app/Models/TourFlight.php @@ -23,6 +23,7 @@ class TourFlight extends Model { protected $table = 'tour_flights'; public $timestamps = false; + public static $snakeAttributes = false; protected $casts = [ 'tour_id' => 'int', diff --git a/app/Models/TravelType.php b/app/Models/TravelType.php index 66f453d..2adf351 100644 --- a/app/Models/TravelType.php +++ b/app/Models/TravelType.php @@ -23,6 +23,7 @@ use Illuminate\Database\Eloquent\Model; class TravelType extends Model { protected $table = 'travel_types'; + public static $snakeAttributes = false; protected $casts = [ 'status' => 'int' diff --git a/app/Models/User.php b/app/Models/User.php index 9464f5a..2d6fabd 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -8,14 +8,15 @@ namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Database\Eloquent\Model; /** * Class User * * @property int $id - * @property string $Firstname - * @property string $Lastname + * @property string $first_name + * @property string $last_name * @property string $national_code * @property int $gender * @property int $marital_status @@ -25,24 +26,28 @@ use Illuminate\Database\Eloquent\Model; * @property string|null $profile_image * @property string $username * @property string $password - * @property string|null $province - * @property string|null $city + * @property int $province_id + * @property int $city_id * @property int $status * @property Carbon $created_at * @property Carbon $updated_at * + * @property City $city * @property Collection|Comment[] $comments * @property Collection|Favorite[] $favorites * * @package App\Models */ -class User extends Model +class User extends Authenticatable { protected $table = 'users'; + public static $snakeAttributes = false; protected $casts = [ 'gender' => 'int', 'marital_status' => 'int', + 'province_id' => 'int', + 'city_id' => 'int', 'status' => 'int' ]; @@ -62,11 +67,20 @@ class User extends Model 'profile_image', 'username', 'password', - 'province', - 'city', + 'province_id', + 'city_id', 'status' ]; + public function city() + { + return $this->belongsTo(City::class); + } + public function province() + { + return $this->belongsTo(Province::class); + } + public function comments() { return $this->hasMany(Comment::class); diff --git a/database/backup/airline_agency.sql b/database/backup/airline_agency.sql new file mode 100644 index 0000000..e53de5b --- /dev/null +++ b/database/backup/airline_agency.sql @@ -0,0 +1,235 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.3 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1:3306 +-- Generation Time: Aug 15, 2026 at 12:26 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 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 NOT NULL, + `tour_id` bigint UNSIGNED NOT 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`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- 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 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- 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 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, + `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 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, + `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 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- -------------------------------------------------------- + +-- +-- 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=MyISAM 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` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `city` varchar(50) COLLATE utf8mb4_unicode_ci 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`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- +-- Constraints for dumped tables +-- + +-- +-- 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; +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/auth/register.blade.php b/resources/views/auth/register.blade.php index 561ad23..a054957 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,336 +1,591 @@ @extends('layouts.app') - @section('content') +
+ style="background-image:url({{ asset('img/adult-book-business-cactus-297755_1500x800.jpg') }});"> +
+
+
+
+
+
+
+