protected $middleware = [
\App\Http\Middleware\Syspoint::class,
]
use Session;
class Syspoint
{
echo \Session::get('syspoint');
}
Run Code Online (Sandbox Code Playgroud)
每当页面请求,中间件包含会话时,我都需要运行中间件.
我放在里面protected $middleware,但全球中间件无法获得会话.
正如在基本的 Laracasts.com 教程(从头开始的 Laracast 5.7)中一样,我尝试使用以下方法public function show(prototypes $prototypes)参数来构造视图。但是我的视图创建正确但$prototypes为空。
该路线运行良好( /prototypes/1/edit),并且我确保prototype存在 id 为 1 的对象。我找到了一些较旧的解决方案,其中规定使用类似(integer $id)参数的内容,但这会导致更多代码。它应该像这样工作:
控制器:
public function edit(prototypes $prototypes)
{
//
return view('prototypes.edit', compact('prototypes'));
}
Run Code Online (Sandbox Code Playgroud)
根据Laracast From Scratch 的说法,这应该可行。
你知道我该如何解决这个问题吗?
该prototypes.edit方法知道如何使用正确的参数,这背后的机制是什么?