git add .

git commit  "add tours pages, components and show views"
This commit is contained in:
2026-08-17 11:36:19 +03:30
parent e99c340f1e
commit 970786ae94
15 changed files with 595 additions and 249 deletions
+20 -4
View File
@@ -10,10 +10,26 @@ class HomeController extends Controller
{
public function index()
{
$newestFlight = Flight::latest()->take(10)->get();
$flights=Flight::latest()->paginate(5);
$newestTour = Tour::latest()->take(10)->get();
$newestFlight = Flight::
where('departure_date', '>=', now())
->orderBy('departure_date', 'asc')
->take(3)
->get();
$newestTour = Tour::latest()
->take(10)
->get();
return view('home.index', compact('newestFlight','flights', 'newestTour'));
$flights = Flight::latest()
->paginate(5);
$tours = Tour::latest()
->paginate(5);
return view('home.index', compact(
'newestFlight',
'newestTour',
'flights',
'tours'
));
}
}
+10 -5
View File
@@ -6,19 +6,24 @@ use App\Models\Tour;
class TourController extends Controller
{
// صفحه لیست تورها: اسلایدر آخرین‌ها + گرید صفحه‌بندی‌شده
public function index()
{
$newestTour = Tour::latest()->take(10)->get();
$tours = Tour::latest()->paginate(9);
$newestTour = Tour::with('travelType')
->latest()
->take(10)
->get();
$tours = Tour::with('travelType')
->latest()
->paginate(5);
return view('tours.index', compact('newestTour', 'tours'));
}
// جزئیات تور + شمارنده بازدید
public function show(Tour $tour)
{
$tour->increment('views');
$tour->load('travelType');
return view('tours.show', compact('tour'));
}
+2 -2
View File
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Model;
* Class City
*
* @property int $id
* @property int $provinces
* @property int $province_id
* @property string $name
* @property Carbon $created_at
* @property Carbon $updated_at
@@ -33,7 +33,7 @@ class City extends Model
];
protected $fillable = [
'provinces',
'province_id',
'name'
];
+1 -1
View File
@@ -34,7 +34,7 @@ class Province extends Model
}
public function cities()
{
return $this->hasMany(City::class);
return $this->belongsTo(City::class);
}
}
+7 -3
View File
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Tour
*
*
* @property int $id
* @property string $title
* @property string $summary
@@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\Model;
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
*
*
* @property Collection|Comment[] $comments
*
* @package App\Models
@@ -56,4 +56,8 @@ class Tour extends Model
{
return $this->hasMany(Comment::class);
}
}
public function travelType()
{
return $this->belongsTo(TravelType::class);
}
}
+6 -2
View File
@@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class TravelType
*
*
* @property int $id
* @property string $name
* @property int $status
@@ -33,4 +33,8 @@ class TravelType extends Model
'name',
'status'
];
}
public function tours()
{
return $this->hasMany(Tour::class, 'travel_type_id');
}
}