qcode
  • 创作工场专业版,一问多答!更智能、更完整、更原创
  • 这是一个超强内容创作平台,它会写文章、做设计、绘图、敲代码,有问必答!
🔥点击使用-高级专业版🔥

<?php

时间2023-03-20 15:57:24 提问来自 辽宁省沈阳市 的网友 分类创作 浏览529
namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Category; use App\Models\Product; class HomeController extends Controller { /** * Create a new controller instance. * Only guests are able to access the home page. The user is redirected to the dashboard if logged in. * @return void */ public function __construct() { $this->middleware('guest'); //redirects users who are logged in from accessing the home page. They will be redirected to their dashboard page instead. } /** * Show the application dashboard. * @return \Illuminate\Contracts\Support\Renderable */ public function index() { //this is the default index method for this controller - it will show when a user visits '/' in their browser and they are not logged in (guests) $categories = Category::all(); //fetch all categories from DB and assign them to variable so they can be used on view file (home.blade) - see line 18 of home/index blade file for more info on how this works return view('home', compact('categories')); //pass categories variable into view file (home) so they can be used on that page - see line 18 of home/index blade file for more info on how this works } }

点击这里,进行内容创作

创作工场 免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!

上一篇 修复下这个PHP代码 下一篇 回忆梳理书写自己如何成长的故事,包括高光时刻,生命中曾经遇到的挫折和挑战,是如何应对的?这些高光与挫折对自己成长有何影响1500字