3 months ago

Is it best practice if I store model data in $request?

Posted 3 months ago by tonviet712

I have several endpoint like:




I want to verify code each request, so I create middleware CheckCode for those request In middleware, my code is something like:

$member = Member::where('code', $request->code)->first();
if (!$member) abort(404);
	'member' => $member

return $next($request);

And in controller/action for each requests, I just get

$member = $request->member;

So is it best practices for this problem? Do you have any better solution? Thanks in advance

Please sign in or create an account to participate in this conversation.