git add .
git commit "add tours pages, components and show views"
This commit is contained in:
@@ -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'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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'
|
||||
];
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Province extends Model
|
||||
}
|
||||
public function cities()
|
||||
{
|
||||
return $this->hasMany(City::class);
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user