# |
Jul 3rd 2021, 13:01 |
admad |
might as well look into using foc/search since you are at it. It will make your code very clean. |
# |
Jul 3rd 2021, 13:00 |
kevin.pfeifer |
i will do that |
# |
Jul 3rd 2021, 13:00 |
admad |
remove *everything* related to the request :) |
# |
Jul 3rd 2021, 12:59 |
kevin.pfeifer |
but yes, i can remove the request type check |
# |
Jul 3rd 2021, 12:58 |
kevin.pfeifer |
well first it was all present in the controller and then i moved all that inside that finder method |
# |
Jul 3rd 2021, 12:57 |
admad |
why the hell are you even checking request type in there currently? :) |
# |
Jul 3rd 2021, 12:57 |
kevin.pfeifer |
:) |
# |
Jul 3rd 2021, 12:57 |
kevin.pfeifer |
seems logical |
# |
Jul 3rd 2021, 12:56 |
kevin.pfeifer |
:thinking_face: |
# |
Jul 3rd 2021, 12:56 |
admad |
exactly, why should the finder need anything else from the request? |
# |
Jul 3rd 2021, 12:55 |
kevin.pfeifer |
so then I don’t have the whole request object inside my finder and just use the params |
# |
Jul 3rd 2021, 12:55 |
admad |
then use `$options['search']` in your finder to read the search args |
# |
Jul 3rd 2021, 12:54 |
admad |
And the changes is pretty easy, all you have to do is `find('index', ['search' => $this->request->getQuery()])` |
# |
Jul 3rd 2021, 12:53 |
kevin.pfeifer |
alright, then I will change that. thx for the info :bow: |
# |
Jul 3rd 2021, 12:52 |
admad |
@kevin.pfeifer ORM should never know anything about the incoming request. |
# |
Jul 3rd 2021, 09:32 |
kevin.pfeifer |
i was just trying to clean up my controller index function and thought this was fine ^^ |
# |
Jul 3rd 2021, 09:28 |
kevin.pfeifer |
so I shouldn't get the query args through the request object, instead I should pass them via the options. |
# |
Jul 3rd 2021, 03:37 |
admad |
@kevin.pfeifer your code is bad given the fact that you are directly using the query instance inside it instead of passing the querystring args through finder options. |
# |
Jul 2nd 2021, 21:57 |
kevin.pfeifer |
and yes my app has no authentication/authorization till now :) |
# |
Jul 2nd 2021, 21:56 |
kevin.pfeifer |
I don't want to make it a competition but I think my custom finder doesn't look that much better :,) |
# |
Jul 2nd 2021, 21:54 |
tyler.adam.lazenby |
btw yes I know I need to use authorization. |
# |
Jul 2nd 2021, 21:53 |
slackebot2 |
$contactToList) { if ($contactToList->contact_id === $contact->id) { $contact->isPart = true; break; } } } if ($this->request->is('ajax')) { $this->response = $this->response->withDisabledCache(); return $this->response ->withType('application/json') |
# |
Jul 2nd 2021, 21:53 |
slackebot2 |
->withStringBody(json_encode($contacts)); } return $contacts; }``` |
# |
Jul 2nd 2021, 21:53 |
slackebot2 |
$contacts = $this->Authorization->applyScope($contacts, 'index'); $contactToLists = $this->Contacts->ContactToLists->find() ->where(['contact_list_id' => $contact_list_id]); /** @var \App\Model\Entity\Contact $contact */ foreach ($contacts as $contact) { $contact->isPart = false; /** @var \App\Model\Entity\ContactToList $contactToList */ foreach ($contactToLists as |
# |
Jul 2nd 2021, 21:53 |
slackebot2 |
$contacts = $this->Contacts->find(); $contacts = $contacts->where([ 'OR' => [ "CONCAT_WS(' ', first_name, last_name) LIKE" => $contacts->func()->concat(['%', $param, '%']), 'first_name LIKE' => $contacts->func()->concat(['%', $param, '%']), 'last_name LIKE' => $contacts->func()->concat(['%', $param, '%']), ], ])->orderAsc('first_name'); |
# |
Jul 2nd 2021, 21:53 |
tyler.adam.lazenby |
```/** * Ajax Contact Search * @return \Cake\Http\Response|mixed|null */ public function searchContacts() { $this->Authorization->skipAuthorization(); $param = $this->request->getQuery('param'); $referrer = $this->request->referer(); $params = Router::getRouteCollection()->parse($referrer); $contact_list_id = $params['id']; // All Contacts |
# |
Jul 2nd 2021, 21:52 |
tyler.adam.lazenby |
I mean... let me just show you my nonesense |
# |
Jul 2nd 2021, 21:52 |
kevin.pfeifer |
but basically that should be the base how you filter/search in php |
# |
Jul 2nd 2021, 21:52 |
kevin.pfeifer |
I too have to refactor my search to that plugin because its pretty awesome |
# |
Jul 2nd 2021, 21:52 |
tyler.adam.lazenby |
Thank you kevin |
# |
Jul 2nd 2021, 21:51 |
tyler.adam.lazenby |
I didn't even know this existed |
# |
Jul 2nd 2021, 21:15 |
kevin.pfeifer |
custom API Point based on https://github.com/FriendsOfCake/search ? |
# |
Jul 2nd 2021, 19:41 |
tyler.adam.lazenby |
what have you found is the best live search js component for cakephp? |
# |
Jul 2nd 2021, 18:59 |
kevin.pfeifer |
as a native german speaker I can definitely NOT recommend using it in any matter :,) |
# |
Jul 2nd 2021, 16:49 |
dereuromark |
Is klingonian already out again these days?^^ |
# |
Jul 2nd 2021, 16:44 |
tyler.adam.lazenby |
speak? What is this speaking you .... never mind |
# |
Jul 2nd 2021, 16:17 |
admad |
What do you wanna do instead, speak Cherokee? :P |
# |
Jul 2nd 2021, 15:52 |
tyler.adam.lazenby |
The fact that I let the program do that and not question whether that was correct or not is a testament to that. |
# |
Jul 2nd 2021, 15:51 |
tyler.adam.lazenby |
I am merican and we tend to let others influence how we speak way too much to have really any say |
# |
Jul 2nd 2021, 15:39 |
staccato123 |
I'm sure we used to be cooler... |
# |
Jul 2nd 2021, 15:37 |
staccato123 |
bitte sehr! |