Suppose we need to fetch records from post table where user id of post needs to be 1 and they are either created on the day of 22 or updated on the day of 23 of any month and year, then we can achieve this fetching by following snippet.
$posts = Post::select([ 'id','title', 'created_at','updated_at'])->where( 'user_id', 1 )->where(function( $q ){ return $q->whereDay('created_at', 22)->orWhereDay('updated_at',23); })->get();
With above snippet it produces following raw sql where we can see date(created_at) or date(updated_at) are being put inside bracket with another 'and' condition of user_id.
select * from `posts` where `user_id` = ? and (date(`created_at`) = ? or date(`updated_at`) = ?)