# |
Jul 17th 2019, 07:41 |
koeller |
@admad So the proper way would be that the client sends another index request? |
# |
Jul 17th 2019, 07:41 |
conehead |
@h.mavisakalian probably you need something like this: ``` $query = $this->Users->find(‘all’,[ ‘conditions’ => ['yourField IN' => $searchArray], ‘order’ => [‘Users.id’ => ‘ASC’] ]); ``` |
# |
Jul 17th 2019, 07:40 |
admad |
@koeller for a REST API for a delete request you just respond with a success/failure status |
# |
Jul 17th 2019, 07:39 |
admad |
@maymeow if it's a standalone plugin first plug it into an app :slightly_smiling_face: |
# |
Jul 17th 2019, 07:39 |
koeller |
@admad: Okay, what would be the best way then? setting a view variable with the result of the finder im using in index Action? |
# |
Jul 17th 2019, 07:39 |
graziel |
@maymeow you are probably missing cache config after updating cake https://github.com/cakephp/app/blob/master/config/app.default.php#L111 |
# |
Jul 17th 2019, 07:38 |
admad |
@koeller since you mention using JWT auth I assume you are working on a stateless REST API. There's no redirection for such requests. |
# |
Jul 17th 2019, 07:37 |
maymeow |
Any idea how to solve this? |
# |
Jul 17th 2019, 07:36 |
admad |
how do you expect `‘conditions’ => $searchArray` to work without specifying which fields/columns to use? |
# |
Jul 17th 2019, 07:35 |
dereuromark |
see awesome list |
# |
Jul 17th 2019, 07:35 |
h.mavisakalian |
which plugin is that? |
# |
Jul 17th 2019, 07:35 |
slackebot |
$this->Crud->on('afterDelete') with $this->redirect(['index']) and $this->setAction('index'), but I would only recieve a NotFoundException. I'm a bit puzzled here. Thank you for reading! |
# |
Jul 17th 2019, 07:35 |
koeller |
Hi everyone, I have a question regarding the friendsofcake/CRUD plugin. I'm doing a simple delete and try to redirect to index, so that the response of the request would be a list of all items for logged user. I'm using JWT as Authentication method. Reading this:https://crud.readthedocs.io/en/latest/actions/delete.html#crud-beforeredirect I thought, it should automatically redirect to index, but it won't. So I tried to manually redirect in |
# |
Jul 17th 2019, 07:35 |
dereuromark |
use Search plugin for this |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
What am I doing wrong? |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
But it doesn’t work |
# |
Jul 17th 2019, 07:34 |
h.mavisakalian |
$query = $this->Users->find(‘all’,[ ‘conditions’ => $searchArray, ‘order’ => [‘Users.id’ => ‘ASC’] ]); |
# |
Jul 17th 2019, 07:33 |
h.mavisakalian |
Now I want to search the database this way |
# |
Jul 17th 2019, 07:33 |
h.mavisakalian |
I created an array from a search query with all values using exlode(’ ’, $searchValue); |
# |
Jul 17th 2019, 07:31 |
h.mavisakalian |
Good morning everyone. I have a question about search queries in CakePHP 3.X |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
here you can set conditions |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
``` class ArticlesTable extends Table { public function initialize(array $config) { $this->hasMany('Comments') ->setConditions(['approved' => true]); $this->hasMany('UnapprovedComments', [ 'className' => 'Comments' ]) ->setConditions(['approved' => false]) ->setProperty('unapproved_comments'); } } ``` |
# |
Jul 17th 2019, 07:25 |
aivaras.godliauskas |
https://book.cakephp.org/3.0/en/orm/associations.html#default-association-conditions |
# |
Jul 17th 2019, 07:24 |
neon1024 |
I need gmp, sodium and intl |
# |
Jul 17th 2019, 07:24 |
neon1024 |
Anyone know where I can find package names for PHP extension for Debian Fastly? |
# |
Jul 17th 2019, 07:23 |
aivaras.godliauskas |
Hi @neon1024 Fun fact im useing n3on as my nic |
# |
Jul 17th 2019, 07:23 |
felix.robaglia |
I'd be curious how ! I'm an intern and have a lot to learn @aivaras.godliauskas ^^ How can I say it directly in the table ? |
# |
Jul 17th 2019, 07:23 |
neon1024 |
Morning all :wave: |
# |
Jul 17th 2019, 07:23 |
aivaras.godliauskas |
or you can try and use some kind of soft delete for example https://github.com/UseMuffin/Trash |
# |
Jul 17th 2019, 07:23 |
neon1024 |
I quite like creating my own query and passing it to the Paginator :slightly_smiling_face: |
# |
Jul 17th 2019, 07:22 |
aivaras.godliauskas |
if you want to do it right way you can add this condition in table itself, where realiation is defined |
# |
Jul 17th 2019, 07:22 |
admad |
no. read up about custom finders on manul |
# |
Jul 17th 2019, 07:22 |
felix.robaglia |
Like a method i'll put in my AppController admad? |
# |
Jul 17th 2019, 07:22 |
felix.robaglia |
Wow, thanks a lot, I must be blind then cause it has to be in the doc ! Ty guys ! |
# |
Jul 17th 2019, 07:22 |
admad |
also a cleaner way would be to make a custom finder for that |
# |
Jul 17th 2019, 07:21 |
admad |
or use `conditions` like that :slightly_smiling_face: |
# |
Jul 17th 2019, 07:21 |
aivaras.godliauskas |
@felix.robaglia you can go ``` $this->paginate = [ 'contain' => ['Contracts'=>[ 'conditions'=>['delete IS'=>null] ] ] ]; ``` i believe |
# |
Jul 17th 2019, 07:21 |
admad |
@felix.robaglia `['contain' => ['Contracts' => function ($q) { $q->where(...)}]` |
# |
Jul 17th 2019, 07:19 |
felix.robaglia |
But I would like to only get contracts that have NULL in their 'deleted' column. I'm sorry if that's a dumb question or anything, but I did read the doc and i'm still stuck ! Thanks :slightly_smiling_face: |
# |
Jul 17th 2019, 07:19 |
felix.robaglia |
``` $this->paginate = [ 'contain' => ['Contracts'] ]; ``` |
# |
Jul 17th 2019, 07:19 |
felix.robaglia |
Hello, I'm discovering hasMany relations and i'm stuck on something I guess is really easy. I have a clients table, and it hasMany contracts. So I use this piece of code to retrieve contracts in my Clients Controller : |