git add .

git commit "fix: city selection, comment user display, and back button bug"
This commit is contained in:
2026-08-22 09:13:09 +03:30
parent 669dd7cfff
commit 947d2425d9
16 changed files with 114 additions and 63 deletions
+5 -2
View File
@@ -3,11 +3,14 @@
namespace App\Http\Controllers;
use App\Models\City;
use App\Models\Province;
class CityController extends Controller
{
public function byProvince($province)
public function byProvince( Province $province)
{
return City::where('province_id', $province)->get();
return response()->json(
$province->cities()->select('id', 'name')->get()
);
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ class Province extends Model
}
public function cities()
{
return $this->belongsTo(City::class);
return $this->hasMany(City::class);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@@ -34,7 +34,13 @@
<div class="comment-header">
<div>
<h4>
@if($comment->tour_id)
{{ $comment->tour->title ?? 'مورد حذف شده' }}
@elseif($comment->flight_id)
{{ $comment->flight->airline ?? 'مورد حذف شده' }}
@else
مورد حذف شده
@endif
</h4>
<span>
{{ $comment->created_at->format('Y/m/d') }}
@@ -35,7 +35,11 @@
@if($favorite->favoritable_type == 'App\Models\Tour')
<h3>
{{ $favorite->favoritable?->title ?? 'مورد حذف شده' }} </h3>
{{ $favorite->favoritable?->title ?? 'مورد حذف شده' }}
</h3>
<h3>
{{ $favorite->favoritable?->summary ?? 'مورد حذف شده' }}
</h3>
<p>
تور
@@ -44,7 +48,10 @@
@elseif($favorite->favoritable_type == 'App\Models\Flight')
<h3>
{{ $favorite->favoritable->name }}
{{ $favorite->favoritable->airline }}
</h3>
<h3>
{{ $favorite->favoritable->flight_number }}
</h3>
<p>
@@ -632,9 +632,8 @@
.append('<option value="">در حال دریافت شهرها...</option>');
$.ajax({
url: "{{ route('users.cities.province', ':province') }}"
url: "{{ route('cities.province', ':province') }}"
.replace(':province', provinceId),
type: 'GET',
success: function (cities) {
@@ -660,13 +659,9 @@
},
error: function () {
citySelect.empty();
citySelect.append(
'<option value="">خطا در دریافت شهرها</option>'
);
citySelect.append('<option value="">خطا در دریافت شهرها</option>');
citySelect.prop('disabled', false);
}
});
+37
View File
@@ -570,5 +570,42 @@
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const provinceSelect = document.getElementById('province_id');
const citySelect = document.getElementById('city_id');
provinceSelect.addEventListener('change', function () {
const provinceId = this.value;
citySelect.innerHTML = '<option value="">در حال بارگذاری...</option>';
citySelect.disabled = true;
if (!provinceId) {
citySelect.innerHTML = '<option value="">ابتدا استان را انتخاب کنید</option>';
return;
}
fetch(`{{ url('/cities') }}/${provinceId}`)
.then(response => response.json())
.then(cities => {
citySelect.innerHTML = '<option value="">انتخاب شهرستان</option>';
cities.forEach(city => {
const option = document.createElement('option');
option.value = city.id;
option.textContent = city.name;
citySelect.appendChild(option);
});
citySelect.disabled = false;
})
.catch(() => {
citySelect.innerHTML = '<option value="">خطا در دریافت شهرها</option>';
citySelect.disabled = false;
});
});
});
</script>
@endsection
+1 -1
View File
@@ -166,7 +166,7 @@
<div class="d-flex justify-content-between">
<strong>
{{ $comment->user->name }}
{{ $comment->user ? $comment->user->first_name . ' ' . $comment->user->last_name : 'کاربر مهمان' }}
</strong>
<small>
+30 -26
View File
@@ -15,31 +15,35 @@
<link rel="stylesheet" href="{{ asset('assets/css/footer.css') }}">
</head>
<body>
@includeUnless(isset($withoutHeader),'layouts.header')
@includeUnless(isset($withoutHero),'layouts.hero')
<body>
@includeUnless(isset($withoutHeader),'layouts.header')
@includeUnless(isset($withoutHero),'layouts.hero')
@yield('content')
@includeUnless(isset($withoutFooter),'layouts.footer')
<script src="{{asset('assets/js/moment.js')}}"></script>
<script src="{{asset('assets/js/bootstrap.js')}}"></script>
<script src="{{asset('assets/js/owl-carousel.js')}}"></script>
<script src="{{asset('assets/js/blur-area.js')}}"></script>
<script src="{{asset('assets/js/icheck.js')}}"></script>
<script src="{{asset('assets/js/gmap.js')}}"></script>
<script src="{{asset('assets/js/magnific-popup.js')}}"></script>
<script src="{{asset('assets/js/ion-range-slider.js')}}"></script>
<script src="{{asset('assets/js/sticky-kit.js')}}"></script>
<script src="{{asset('assets/js/smooth-scroll.js')}}"></script>
<script src="{{asset('assets/js/fotorama.js')}}"></script>
<script src="{{asset('assets/js/bs-datepicker.js')}}"></script>
<script src="{{asset('assets/js/typeahead.js')}}"></script>
<script src="{{asset('assets/js/quantity-selector.js')}}"></script>
<script src="{{asset('assets/js/countdown.js')}}"></script>
<script src="{{asset('assets/js/window-scroll-action.js')}}"></script>
<script src="{{asset('assets/js/fitvid.js')}}"></script>
<script src="{{asset('assets/js/youtube-bg.js')}}"></script>
<script src="{{asset('assets/js/custom.js')}}"></script>
<script async="" defer="" src="{{asset('assets/js/js.js')}}"></script>
@includeUnless(isset($withoutFooter),'layouts.footer')
</body>
</html>
<script src="{{asset('assets/js/jquery-3.7.1.min.js')}}"></script>
<script src="{{asset('assets/js/moment.js')}}"></script>
<script src="{{asset('assets/js/bootstrap.js')}}"></script>
<script src="{{asset('assets/js/owl-carousel.js')}}"></script>
<script src="{{asset('assets/js/blur-area.js')}}"></script>
<script src="{{asset('assets/js/icheck.js')}}"></script>
<script src="{{asset('assets/js/gmap.js')}}"></script>
<script src="{{asset('assets/js/magnific-popup.js')}}"></script>
<script src="{{asset('assets/js/ion-range-slider.js')}}"></script>
<script src="{{asset('assets/js/sticky-kit.js')}}"></script>
<script src="{{asset('assets/js/smooth-scroll.js')}}"></script>
<script src="{{asset('assets/js/fotorama.js')}}"></script>
<script src="{{asset('assets/js/bs-datepicker.js')}}"></script>
<script src="{{asset('assets/js/typeahead.js')}}"></script>
<script src="{{asset('assets/js/quantity-selector.js')}}"></script>
<script src="{{asset('assets/js/countdown.js')}}"></script>
<script src="{{asset('assets/js/window-scroll-action.js')}}"></script>
<script src="{{asset('assets/js/fitvid.js')}}"></script>
<script src="{{asset('assets/js/youtube-bg.js')}}"></script>
<script src="{{asset('assets/js/custom.js')}}"></script>
<script async="" defer="" src="{{asset('assets/js/js.js')}}"></script>
@stack('scripts')
</body>
</html>
+10 -10
View File
@@ -1,4 +1,4 @@
@extends('layouts.app')
@extends('layouts.app')
@section('content')
@@ -61,14 +61,6 @@
</strong>
<a
href="{{ route('index') }}"
class="btn btn-outline-primary rounded-pill px-4"
>
برگشت
</a>
</div>
</div>
@@ -81,10 +73,18 @@
</div>
<div class="mt-4 d-flex justify-content-center">
<a
href="{{ route('index') }}"
class="btn btn-outline-primary rounded-pill px-4"
>
برگشت
</a>
</div>
<div class="mt-5 d-flex justify-content-center">
{{ $tours->links() }}
{{$tours->links()}}
</div>
+1 -1
View File
@@ -200,7 +200,7 @@
<div class="d-flex justify-content-between">
<strong>
{{ $comment->user?->name ?? 'کاربر مهمان' }}
{{ $comment->user ? $comment->user->first_name . ' ' . $comment->user->last_name : 'کاربر مهمان' }}
</strong>
+2 -3
View File
@@ -23,6 +23,8 @@ Route::get('/tours/{tour}', [TourController::class, 'show'])->name('tours.show')
Route::get('/comments',[CommentController::class,'index'])->name('comments.index');
Route::post('/comments',[CommentController::class,'store'])->name('comments.store');
Route::get('/cities/{province}', [CityController::class, 'byProvince'])->name('cities.province');
Route::prefix('users')->name('users.')->middleware('auth:web')->group(function (){
Route::get('/',[DashboardController::class,'index'])->name('dashboard');
@@ -37,9 +39,6 @@ Route::prefix('users')->name('users.')->middleware('auth:web')->group(function (
Route::delete('/favorite/{favorite}',[FavoriteController::class,'destroy'])->name('favorite.destroy');
Route::get('/cities/{province}', [CityController::class, 'byProvince'])->name('cities.province');
Route::get('/reservations', [ReservationController::class, 'index'])->name('reservations.index');
Route::post('/reservations', [ReservationController::class, 'store'])->name('reservations.store');