# |
Oct 3rd 2018, 17:15 |
whyrusleepingMh |
conundrum, ^r works. But "command + up arrow" I would like much more. how can I configure? |
# |
Oct 3rd 2018, 17:15 |
matsaku |
Oh ok I get the query |
# |
Oct 3rd 2018, 17:15 |
matsaku |
My relations aren't set up and I'm not sure where to start to do that. I'm really lost. CakePhp is my first try after learning oop |
# |
Oct 3rd 2018, 17:15 |
btx |
like `$users->contain(['Todos','SharedTodos'=>function($query){ return $query->where(['SharedTodos.user_id = Users.id']);}])` |
# |
Oct 3rd 2018, 17:13 |
btx |
you should still be able to `contain` the records tho as long as your relations are set up |
# |
Oct 3rd 2018, 17:13 |
matsaku |
It's just a link with two column "user_id" and "todo_id" |
# |
Oct 3rd 2018, 17:13 |
btx |
my bad |
# |
Oct 3rd 2018, 17:13 |
matsaku |
No sorry |
# |
Oct 3rd 2018, 17:13 |
btx |
o sorry I thought they were same table |
# |
Oct 3rd 2018, 17:12 |
matsaku |
You mean making the same table as Todos for SharedTodos. And when I want to share, I just duplicate the Todo in the other table ? |
# |
Oct 3rd 2018, 17:10 |
matsaku |
Oh |
# |
Oct 3rd 2018, 17:10 |
btx |
then you’d have `$user->todos` and `$user->shared_todos` |
# |
Oct 3rd 2018, 17:09 |
btx |
@matsaku i would have Todos and SharedTodos associations where SharedTodos is a Todos, but with a conditional filter then just `Users->contain['Todos','SharedTodos'])->..` |
# |
Oct 3rd 2018, 17:08 |
slackebot |
->order(['done' => 'ASC', 'created' => 'DESC']); $todos = $query->toArray(); ``` I really don't know where to look anymore :( |
# |
Oct 3rd 2018, 17:08 |
matsaku |
I'm trying this but doesn't works also : ``` $todos = TableRegistry::get('Todos'); $query = $todos->find('all') ->join([ 'table' => 'todo_shared', 'alias' => 'ts', 'type' => 'LEFT', 'conditions' => 'ts.todo_id = Todos.id' ]) ->where(['OR' => [['Todos.user_id =' => $this->Auth->user('id')], ['ts.user_id = ' => $this->Auth->user('id')]]]) |
# |
Oct 3rd 2018, 16:40 |
slackebot |
which join I should use. The point is to get all the tasks the user created and the others tasks users shared with him |
# |
Oct 3rd 2018, 16:40 |
matsaku |
An other question for my case, I need to do this request with the query builder : `SELECT * FROM todos LEFT JOIN todo_shared AS ts ON ts.user_id = $userId WHERE ts.todo_id = todos.id OR todos.id = $userId;` My actual query look like this : ``` $query = $todos->find('all') ->where(['Todos.user_id =' => $this->Auth->user('id')]) ->order(['done' => 'ASC', 'created' => 'DESC']); ``` I'm not even sure |
# |
Oct 3rd 2018, 16:36 |
narendravaghela |
SendGrid provides SMTP credentials as well which you can set in email config. |
# |
Oct 3rd 2018, 16:36 |
narendravaghela |
Agree with @admad |
# |
Oct 3rd 2018, 16:36 |
admad |
@neon1024 if you don't need the extra features their api provides then can just user their smtp login |
# |
Oct 3rd 2018, 16:34 |
narendravaghela |
I generally need emails in backend apps, so I convert it into plugins for community use |
# |
Oct 3rd 2018, 16:34 |
narendravaghela |
@neon1024 yes, and few others for emails :slightly_smiling_face: |
# |
Oct 3rd 2018, 16:15 |
matsaku |
(but with !empty in my case) |
# |
Oct 3rd 2018, 16:15 |
matsaku |
@btx thanks it works smoothly ! |
# |
Oct 3rd 2018, 16:11 |
btx |
@matsaku try `if( empty($user) )` |
# |
Oct 3rd 2018, 16:10 |
traneXH |
yaman mo hayop |
# |
Oct 3rd 2018, 16:09 |
traneXH |
gib it to hir |
# |
Oct 3rd 2018, 16:07 |
matsaku |
But you there are other proper solution I'm all ears |
# |
Oct 3rd 2018, 16:07 |
matsaku |
Ok I got it with a $user != null |
# |
Oct 3rd 2018, 15:58 |
slackebot |
the user exist. If not it throw me an error trying is_empty on null. Sorry for this simple question I feel like I'm not that far ._. |
# |
Oct 3rd 2018, 15:58 |
matsaku |
Hi there, I want to check if the user exist in the database and extract his id in a controller. How do I verify if the user exist and then get his id ? ```PHP $user = $userTable->find() ->select(['id']) ->where(['Users.email =' => $this->request->getData('user')]) ->first(); if (!$user->isEmpty()) { ``` This is the code to get user info. It works only when |
# |
Oct 3rd 2018, 15:56 |
neon1024 |
Yes, seems you’ve done this @narendravaghela :thumbsup: I shall follow your plugins technique |
# |
Oct 3rd 2018, 15:55 |
neon1024 |
Such as creating a custom mail transport |
# |
Oct 3rd 2018, 15:54 |
neon1024 |
Is there a neater way for me to integrate SendGrid, than just calling it’s call instead of Cake\Network\Email |
# |
Oct 3rd 2018, 15:38 |
btx |
@ricksaccous np, fwiw |
# |
Oct 3rd 2018, 15:30 |
neon1024 |
Great thanks, feel free to open ticket for any issues you find :slightly_smiling_face: |
# |
Oct 3rd 2018, 15:29 |
sdevore |
You I have been thinking of using it as I work on adding sparkpost api support…. Since it is early in the process I’ll check out the 2.0/develop branch if you want |
# |
Oct 3rd 2018, 15:04 |
ricksaccous |
@btx thanks for the suggestion |
# |
Oct 3rd 2018, 15:00 |
admad |
nice.. IRC spam get's gobbled up |
# |
Oct 3rd 2018, 15:00 |
btx |
haha sometimes these bot messages seem to fit the conversation |
# |
Oct 3rd 2018, 14:59 |
polly |
either works though |