How to search associated data using friendsofcake/search plugin?

I am using friends…ke/search plugin.
In my table class -

$this->belongsTo(‘Users’, [
‘className’ => ‘CakeDC\Users\Model\Table\UsersTable’,
‘foreignKey’ => ‘user_id’,
‘joinType’ => ‘INNER’
$this->belongsToMany(‘Facilities’, [
‘through’ => ‘FacilitiesProviders’,

$this->Users->target()->aliasField(‘last_name’). - working fine.

$this->aliasField(‘specialty’), - also working fine.

$this->Facilities->target()->aliasField(‘name’), - This is not working.

I wouldn’t, write your own search, you will be much happier in long run with your own code. It’s just a form that sits above an html table that POST.

    <form method="post" action="<?php echo DIR; ?>dog/indexadmin">
        <label>sch</label><input type="text" name="psch" value="">
        <label>Avail y or n</label><input type="text" name="aval" value="" size="10">
        <input type="submit" name="submit" value="Search">       
<div id="tbl-container">
    <table style="width:94%;">
            <th style="width:100px;">dogpic</th>
            <th style="width:80px;">name</th>
            <th style="width:10px;">sex</th>
            <th style="width:150px;">comments</th>
            <th style="width:20px;">adopted</th>
            <th style="width:40px;">lastedit</th>

Look a lot of this stuff is just appling good ole common sense.

Of course handle the search criteria in your controller.