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.
<div>
<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">
</form>
</div>
<div id="tbl-container">
<table style="width:94%;">
<tr>
<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>
MORE CODE ...
Look a lot of this stuff is just appling good ole common sense.
Of course handle the search criteria in your controller.