Get entries whose title has a keyword or related to a category's title I am trying to get entries that either their title has the keyword or their category field title. I am getting them from my plugin, not twig.
I tried like this:

$keywordCategory= Category::find()-&gt;title($keyword)-&gt;all();
$entries = Entry::find()-&gt;title($keyword)-&gt;relatedTo($keywordCategory)-&gt;all();


but it must be in the title and the category field. Is there a way to check using where and orWhere?
You would have to create the relatedTo condition manually first and then pass it in to the orWhere method. This is untested, but should get you on the right track.

Reference the _applyRelatedToParam() method in the ElementQuery class:
https://github.com/craftcms/cms/blob/3.1.26/src/elements/db/ElementQuery.php#L1724-L1727

$keywordCategory = Category::find()-&gt;title($keyword)-&gt;all();

$parser = new ElementRelationParamParser();
$relatedTo = $parser-&gt;parse($keywordCategory);

$entries = Entry::find()
    -&gt;where(['title' =&gt; $keyword])
    -&gt;orWhere($relatedTo)
    -&gt;all();