routes/web.php
Route::get('/san-pham/{id}', 'FrontendController@productDetail')->name('frontend.productDetail');
productDetail()
:/** * Action hiển thị chi tiết Sản phẩm */ public function productDetail(Request $request, $id) { $sanpham = SanPham::find($id); // Query Lấy các hình ảnh liên quan của các Sản phẩm đã được lọc $danhsachhinhanhlienquan = DB::table('cusc_hinhanh') ->where('sp_ma', $id) ->get(); // Query danh sách Loại $danhsachloai = Loai::all(); // Query danh sách màu $danhsachmau = Mau::all(); return view('frontend.pages.product-detail') ->with('sp', $sanpham) ->with('danhsachhinhanhlienquan', $danhsachhinhanhlienquan) ->with('danhsachmau', $danhsachmau) ->with('danhsachloai', $danhsachloai); }
resources/views/frontend/pages/product-detail.blade.php
{{-- View này sẽ kế thừa giao diện từ `frontend.layouts.master` --}} @extends('frontend.layouts.master') {{-- Thay thế nội dung vào Placeholder `title` của view `frontend.layouts.master` --}} @section('title') Sản phẩm Shop Hoa tươi - Sunshine @endsection {{-- Thay thế nội dung vào Placeholder `custom-css` của view `frontend.layouts.master` --}} @section('custom-css') @endsection {{-- Thay thế nội dung vào Placeholder `main-content` của view `frontend.layouts.master` --}} @section('main-content') <!-- Product info --> @include('frontend.widgets.product-info', ['sp' => $sp, 'hinhanhlienquan' => $danhsachhinhanhlienquan]) @endsection {{-- Thay thế nội dung vào Placeholder `custom-scripts` của view `frontend.layouts.master` --}} @section('custom-scripts') @endsection
Thực hiện các bước tuần tự theo nội dung Bài học nhé!
Cùng nhau học tập, khám phá các kiến thức nền tảng về Lập trình web, mobile, database nhé.
Nền tảng kiến thức - Hành trang tới tương lai hân hạnh phục vụ Quý khách!
Khám phá, trải nghiệm ngay
Vui lòng đăng nhập để gởi bình luận!
Đăng nhậpChưa có bình luận nào!