# |
Jul 19th 2017, 13:21 |
neon1024 |
Plus, I’m not sure you can use matching inside a contain |
# |
Jul 19th 2017, 13:20 |
sauvaget |
same error |
# |
Jul 19th 2017, 13:20 |
sauvaget |
yeah, just tried that aswell |
# |
Jul 19th 2017, 13:20 |
neon1024 |
It’s just ‘Projects’ |
# |
Jul 19th 2017, 13:19 |
sauvaget |
as soon as I integrate the matching() I receive a "FavoriteEntries is not associated with" |
# |
Jul 19th 2017, 13:17 |
hmic |
whats the problem? |
# |
Jul 19th 2017, 13:17 |
hmic |
looks like it is |
# |
Jul 19th 2017, 13:15 |
sauvaget |
I've added the whole query. Just wanted to ask in general if it is possible to do something like that? |
# |
Jul 19th 2017, 13:14 |
sauvaget |
sry ;) https://gist.github.com/l0rdseth/d8676a93f64311cd66a9a3ba985c1400 |
# |
Jul 19th 2017, 13:12 |
hmic |
!tell sauvaget about gist |
# |
Jul 19th 2017, 13:09 |
sauvaget |
unfortunatly, I am getting some association error. :( |
# |
Jul 19th 2017, 13:09 |
slackebot |
return $q->where(['active' => 1]); } ]) ->order(['created' => 'DESC']); }, ]) ``` |
# |
Jul 19th 2017, 13:09 |
sauvaget |
Hey guys, can I use a matching within a contain? ``` ->contain([ 'FavoriteEntries' => function ($q) { return $q ->select([ 'id', 'projectId', 'favoriteListId', ]) ->matching([ 'FavoriteEntries.Projects' => function ($q) { |
# |
Jul 19th 2017, 12:58 |
hmic |
welcome |
# |
Jul 19th 2017, 12:58 |
Ecorce |
Ok, thank you very much everyone :) |
# |
Jul 19th 2017, 12:58 |
hmic |
with none of that, you are right, it would look in the current namespace/dir only |
# |
Jul 19th 2017, 12:57 |
hmic |
or you explicitely use it with that namespace |
# |
Jul 19th 2017, 12:57 |
hmic |
you eighter have a use statement in the top of the controller importing it |
# |
Jul 19th 2017, 12:57 |
Ecorce |
yep, I didn't write the namespace of the AppController to use. I guess it extended that App\Controller\AppController, by default |
# |
Jul 19th 2017, 12:54 |
hmic |
no, you need to use the correct one too - that what the namespaces are good for :p |
# |
Jul 19th 2017, 12:54 |
adriencs |
you extended the wrong AppController ? |
# |
Jul 19th 2017, 12:52 |
Ecorce |
ouch I've found... needed to use App\Controller\Api\AppController in every Controller using it... I thought it would be enough just to create an AppController (the extended class) inside the same folder. |
# |
Jul 19th 2017, 12:47 |
Ecorce |
However, in the beforeFilter of that controller (my second page), there's a $this->Auth->allow() and no error thrown... |
# |
Jul 19th 2017, 12:46 |
Ecorce |
In the second page, that session data is unset (confirmation in debugkit= |
# |
Jul 19th 2017, 12:45 |
Ecorce |
I check in the beforeFilter of the Api/AppController is $this->Auth->user('id') is set. If not, I throw an exception (except for login, obviously). |
# |
Jul 19th 2017, 12:44 |
adriencs |
you have an error ? what it say |
# |
Jul 19th 2017, 12:42 |
adriencs |
yup that's it |
# |
Jul 19th 2017, 12:42 |
adriencs |
something like `App\Controller\Api` |
# |
Jul 19th 2017, 12:42 |
Ecorce |
Yep : namespace App\Controller\Api; (my prefix is "api") |
# |
Jul 19th 2017, 12:41 |
hmic |
correct. and yes, you need to adapt the namespace in the (copied) AppController file to your prefix namespace! |
# |
Jul 19th 2017, 12:40 |
adriencs |
seem correct, what about `namespaces` ? |
# |
Jul 19th 2017, 12:38 |
Ecorce |
my new AppController extends Cake\Controller\Controller (like the initial one), is that correct? |
# |
Jul 19th 2017, 12:32 |
Ecorce |
confirmation : justf after login, there's a "Auth.User" session, then nothing set |
# |
Jul 19th 2017, 12:31 |
Ecorce |
stateless auth? |
# |
Jul 19th 2017, 12:22 |
hmic |
usually it would. but for testing if the prefix works for the first time i think his approach is understandable - copy you current appcontroller and start from there |
# |
Jul 19th 2017, 12:21 |
admad |
shouldn't you API be using stateless auth? :slightly_smiling_face: |
# |
Jul 19th 2017, 12:20 |
hmic |
use debugkit? no: use debugkit! |
# |
Jul 19th 2017, 12:20 |
hmic |
Ecorce, looks like it's not |
# |
Jul 19th 2017, 12:19 |
Ecorce |
Problem is : Auth works on login, but during the next action called, Auth doesn't seem to be loaded ($this->Auth->user('id') returns null, whereas the login was successful) |
# |
Jul 19th 2017, 12:18 |
Ecorce |
Mmm now I have a problem with the Auth Component, which is loaded inside my "prefix" AppController. However, this is the whole copy of the basic AppController, why don't the code work? |
# |
Jul 19th 2017, 12:01 |
neon1024 |
Well if anyone has any ideas, please let me know. Think I’ll eat lunch and delete the test as it doesn’t seem possible |