Using parameters in find() method

find() does not only take single value as parameter like below

Post::find(1);

find() method also can accept array like below

Post::find([1,2]) // it selects id of 1 and 2 from posts tbl 

find() method also can take second parameter where we can specify number of fields also so that less data is fetched from database server

Post::find([1,2], ['id','title']); // suppose posts tbl has id, user_id, title, description, created_at, updated_at 

Related Posts


Using WhereIn

Updating multiple rows

Using Like

Using orWhere

What is Query Builder?

Using "with" in eloquent query

Getting last inserted id

Selecting last row of a table

Using local scope in eloquent

Using global scope in eloquent