You need to use whereHas
for the constraints to transfer over to the main Project query.
$constraint = function($query) {
$query->where('created_at', '>', Carbon::now()->subDays(30));
};
Project::with(['tasks' => $constraint])
->whereHas(['tasks' => $constraint])
->get();
Note that you can drop the with() if you want to display all the projects' tasks.
This is somewhat inefficient and can be improved by using joins instead of whereHas, but should get you started.