It seems that the issue lies in the way you are retrieving the note using the with() method in your controller. The where clause 'type', Note::getTypeIndex('note') is correctly filtering the notes based on the type, but you're not retrieving the related model correctly.
To retrieve the note, you need to modify your code slightly. Instead of using with(), you can use the load() method to eagerly load the relationship and apply the necessary constraints.
$plans = Plan::query() ->whereHas('note', function ($query) { $query->where('type', Note::getTypeIndex('note')); }) ->with(['note' => function ($query) { $query->where('type', Note::getTypeIndex('note')); }]) ->get();