我有一个有图像的列表页面。单击每个图像时,页面应转到相应的详细信息页面。所以我有一个href attribut,我通过传递它的id来定义路由。
以下是我的刀片
@foreach (array_chunk($program, 3, true) as $prgms)
<div class="card-deck mb-30">
@foreach ($prgms as $prgm)
<div class="col-md-4 card">
<a href="{{url('programDtls/'.$prgm['id'])}}">
<img class="card-img-top" src="{{asset(App\Http\Controllers\Controller::getThumbPath($prgm['thumbnail'],$folder='home'))}}" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">{{$prgm['title']}}</h4>
<p class="card-text clsComInnerText mb-10">{{$prgm['description']}}</p>
<p class="card-text"><small class="text-muted">{{date('d-m-Y',strtotime($prgm['episode_date']))}} {{$prg_time}} {{$day = date('l', strtotime($prgm['episode_date']))}} </small></p>
</div>
</a>
</div>
@endforeach
</div>
@endforeach
列表页面路线
Route::get('programListPage/{id}', 'ProgramListPageController@index');
详情页面路线
Route::get('programDtls/{id}', 'ProgramDtlsController@index');
ProgramListPageController @索引
public function index($id) {
$category_details = Category::select('title','description')->where('id',$id)->first();
$program = ProgramDetails::select('id','title','description','thumbnail','programs_id','episode_date')->where('category_id',$id)->where('category_videos',1)->where('enabled',1)->get()->toArray();
$trending_video = ProgramDetails::select('video_url','thumbnail')->where('is_trending',1)->where('category_id',$id)->first();
if(count($trending_video)>0){
$trending = $trending_video['video_url'];
$image = $trending_video['thumbnail'];
}else{
$trending = " ";
$image = " ";
}
if(count($program)>0){
foreach ($program as $prgm) {
$prg_times = Programslots::where('programs_id',$prgm['programs_id'])->get();
foreach($prg_times as $time){
$prg_time = date('h:ia ', strtotime($time['show_time']));
}
}
}else{
$prg_time = " ";
$day = " ";
}
return View('programListPage', ['category_details' => $category_details, 'program' => $program,'prg_time' => $prg_time,'trending_video'=>$trending,'image'=>$image]);
}
ProgramDtlsController @索引
public function index($program_details_id) {
$program_id = ProgramDetails::select('programs_id','description','title','episode_no','video_url','thumbnail')->where('id',$program_details_id)->get();
$program = Programs::select('id','poster_image','video_url','is_video','description')->where('id',$program_id[0]['programs_id'])->orderBy('updated_at', 'desc')->get();
$video_url=ProgramDetails::select('id','video_url','thumbnail','title','episode_no','description','promo_url')->where('enabled', 1)->where('programs_id',$program[0]['id'])->get()->toArray();
$featured_image= Programs::select('poster_image')->where('is_featured', 1)->orderBy('updated_at', 'desc')->get();
$image_album= AlbumMaster::select('id','album_title','cover_image')->where('enabled', 1)->where('program_details_id',$program_details_id)->orderBy('updated_at', 'desc')->get();
$image_gallery=PhotoGallery::select()->where('album_master_id',$image_album[0]['id'])->get();
$result = array('program_id'=>$program_id,'program' => $program,'video_url'=>$video_url,'featured_image'=>$featured_image,'image'=>$image_gallery,'image_album'=>$image_album);
return View('programDtls')->with($result);
}
这里发生的是,当我点击图片时,网址会像下面的
一样发生变化http://localhost/abcde/public/programDtls/31
但是显示相同的列表页面本身。但是,如果我再次使用详细信息页面网址刷新,它将移动到相应的详细信息页面。我需要的是在单击列表页面中的图像时转到详细信息页面。提前谢谢,