0

I'm using the following code: $vacation = vacation::find(30);

But instead of fetching the ID I want it to fetch the ID_user field.

How can I make this change?

Thanks !!

John-PT
  • 69
  • 8
  • your question is not clear . your model in relation with user ? – just code Jun 02 '22 at 18:29
  • `::find()` uses the Primary Key of the model, which is usually `id`. If you want to find by another key, use `->where()`: `vacation::where('ID_user', 30)->first()`. Also, model Names are `PascalCase`; your model should be named `Vacation`, not `vacation`. – Tim Lewis Jun 02 '22 at 18:30

0 Answers0