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)
{
$title = 'جزئیات پرواز';
$flight->increment('views_count');
return view('flights.show' , compact('title' , 'flight'));
}
+1
View File
@@ -41,6 +41,7 @@ class TourController extends Controller
},
'comments.user'
]);
$tour->increment('views_count');
return view('tours.show', compact('title' , 'tour'));
}
+4 -2
View File
@@ -53,7 +53,8 @@ class Flight extends Model
'price' => 'int',
'capacity' => 'int',
'status' => FlightStatus::class,
'trip_type' => FlightTripType::class
'trip_type' => FlightTripType::class,
'views_count' => 'int'
];
protected $fillable = [
@@ -66,7 +67,8 @@ class Flight extends Model
'price',
'capacity',
'status',
'trip_type'
'trip_type',
'views_count'
];
#[Scope]
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',
'file_id' => 'int',
'tour_mode'=> 'int',
'tour_scope' => 'int'
'tour_scope' => 'int',
'views_count' => 'int'
];
protected $fillable = [
@@ -54,7 +55,8 @@ class Tour extends Model
'file_id',
'tour_type',
'tour_mode',
'tour_scope'
'tour_scope',
'views_count'
];
#[Scope]
protected function applySort(Builder $query, ?string $sort = null): void