Search code examples
phplaravelformsvalidation

Laravel form validation


What I want to do is to pass current user's id to create a new link that belongs to that user. When I hit submit it keeps showing error message: user id field is required. I think there might be a mistake in my controller action, but can't figure it out.

screen


Solution

  • Try this:

    Link::create(array_merge(request(['title', 'address', 'category_title']), ['user_id'=>$user]));