feat: add view count feature for tours and flights

This commit is contained in:
2026-08-19 13:51:44 +03:30
parent eebededa4d
commit 33de5fe54f
6 changed files with 12 additions and 7 deletions
@@ -32,6 +32,7 @@ class FlightController extends Controller
public function show(Flight $flight) public function show(Flight $flight)
{ {
$title = 'جزئیات پرواز'; $title = 'جزئیات پرواز';
$flight->increment('views_count');
return view('flights.show' , compact('title' , 'flight')); return view('flights.show' , compact('title' , 'flight'));
} }
+1
View File
@@ -41,6 +41,7 @@ class TourController extends Controller
}, },
'comments.user' 'comments.user'
]); ]);
$tour->increment('views_count');
return view('tours.show', compact('title' , 'tour')); return view('tours.show', compact('title' , 'tour'));
} }
+4 -2
View File
@@ -53,7 +53,8 @@ class Flight extends Model
'price' => 'int', 'price' => 'int',
'capacity' => 'int', 'capacity' => 'int',
'status' => FlightStatus::class, 'status' => FlightStatus::class,
'trip_type' => FlightTripType::class 'trip_type' => FlightTripType::class,
'views_count' => 'int'
]; ];
protected $fillable = [ protected $fillable = [
@@ -66,7 +67,8 @@ class Flight extends Model
'price', 'price',
'capacity', 'capacity',
'status', 'status',
'trip_type' 'trip_type',
'views_count'
]; ];
#[Scope] #[Scope]
protected function applySort(Builder $query, ?string $sort = null): void protected function applySort(Builder $query, ?string $sort = null): void
+4 -2
View File
@@ -42,7 +42,8 @@ class Tour extends Model
'destination_city_id' => 'int', 'destination_city_id' => 'int',
'file_id' => 'int', 'file_id' => 'int',
'tour_mode'=> 'int', 'tour_mode'=> 'int',
'tour_scope' => 'int' 'tour_scope' => 'int',
'views_count' => 'int'
]; ];
protected $fillable = [ protected $fillable = [
@@ -54,7 +55,8 @@ class Tour extends Model
'file_id', 'file_id',
'tour_type', 'tour_type',
'tour_mode', 'tour_mode',
'tour_scope' 'tour_scope',
'views_count'
]; ];
#[Scope] #[Scope]
protected function applySort(Builder $query, ?string $sort = null): void protected function applySort(Builder $query, ?string $sort = null): void
@@ -51,8 +51,7 @@
</form> </form>
</div> </div>
<div class="listing-side-share"> <div class="listing-side-share">
<a href="#"><i class="far fa-share-nodes"></i> اشتراک</a> <span><i class="far fa-eye"></i> {{$flight->views_count}} مشاهده</span>
<span><i class="far fa-eye"></i> 250 مشاهده</span>
</div> </div>
</div> </div>
</div> </div>
@@ -66,7 +66,7 @@
</div> </div>
<div class="listing-side-share"> <div class="listing-side-share">
<span><i class="far fa-eye"></i> 250 مشاهده</span> <span><i class="far fa-eye"></i> {{$tour->views_count}} مشاهده</span>
</div> </div>
</div> </div>
</div> </div>