Laravel is there a way to add values to a request array

前端 未结 13 2208
闹比i
闹比i 2020-12-07 15:24

I come across a situation in Laravel while calling a store() or update() method with Request parameter to add some additional value to the request before calling Eloquent fu

13条回答
  •  广开言路
    2020-12-07 15:45

    You can add parameters to the request from a middleware by doing:

    public function handle($request, Closure $next)
    {
        $request->route()->setParameter('foo', 'bar');
        return $next($request);
    }
    

提交回复
热议问题