Support the ongoing development of Laravel.io →
Validation Laravel Requests

Hi all, I am building an API for my application and I want to limit my endpoints to the JSON Data, I just want to see. For instance when I handle Post-data I just want to handle certain fields, due to the fact that I use, currently, mass assignment in my model I am thinking about a way to prevent, that some wrong data is inserted into the datebase.

The most important fields are protected by $guarded array in the model, but I want to limit the input to certian fields. Is this possible with the request validator? Or should I go away from the mass assignment, in this case?

Kind regardsVav

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.