feat: add view count feature for tours and flights
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class TourController extends Controller
|
||||
},
|
||||
'comments.user'
|
||||
]);
|
||||
$tour->increment('views_count');
|
||||
|
||||
return view('tours.show', compact('title' , 'tour'));
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -51,8 +51,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="listing-side-share">
|
||||
<a href="#"><i class="far fa-share-nodes"></i> اشتراک</a>
|
||||
<span><i class="far fa-eye"></i> 250 مشاهده</span>
|
||||
<span><i class="far fa-eye"></i> {{$flight->views_count}} مشاهده</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user