cebozkurt
cebozkurt

Ceyhun Emre BOZKURT

@cebozkurt

2 Posts 4 Views

  • No matching results...
  • Searching...

/ 255

In response to @bernhardk

My approach ensures cleaner controllers and allows for logic reuse across various parts of my API project at least from my perspective :D. It's perfect for consistently binding and validating the user ID.

For simpler cases where it's only needed in one place, I directly use auth()->user() within the controller.

167

Binding user ID in Laravel requests without the headache: Extend FormRequest, override prepareForValidation(), and merge the user()->id automatically. This way, no need to pass user_id in every request manually! 🎉


image
image

2

130