# |
Jun 27th 2018, 08:34 |
neon1024 |
Not sure I have the energy this early in the morning to write your code for you |
# |
Jun 27th 2018, 08:34 |
magiq_ |
can you write example |
# |
Jun 27th 2018, 08:33 |
neon1024 |
Just query them using the alias, as you would a regular model |
# |
Jun 27th 2018, 08:33 |
magiq_ |
I already define association, but I cant to query to relation of related models |
# |
Jun 27th 2018, 08:33 |
neon1024 |
The same way you would if you were creating a thread in a single model |
# |
Jun 27th 2018, 08:32 |
neon1024 |
Well you’d alias the models |
# |
Jun 27th 2018, 08:32 |
neon1024 |
Also, I would suggest that in fact it’s not related to itsself, as the association is in the parent. If I understand you correctly |
# |
Jun 27th 2018, 08:32 |
magiq_ |
how to $query->where(['SomeModel2.Parent.Type' => 1']) |
# |
Jun 27th 2018, 08:32 |
slackebot4 |
!ruleone |
# |
Jun 27th 2018, 08:32 |
slackebot4 |
Command sent from Slack by neon1024: |
# |
Jun 27th 2018, 08:31 |
magiq_ |
$query = $this->SomeModel() ... This model has relation to another model for example SomeModel2, and SomeModel2 has relation to itself through parent |
# |
Jun 27th 2018, 08:30 |
magiq_ |
I got $this->SomeModel |
# |
Jun 27th 2018, 08:30 |
neon1024 |
Morning all |
# |
Jun 27th 2018, 08:20 |
hmic |
you can create the jointable as a regular table too with belongsTo both other tables and query this table directly ;) |
# |
Jun 27th 2018, 08:20 |
hmic |
chrisshick: use through association |
# |
Jun 27th 2018, 07:15 |
chrisshick |
using the association? |
# |
Jun 27th 2018, 07:15 |
chrisshick |
Is there a way to query on data in middle table of a belongs to many? |
# |
Jun 27th 2018, 05:12 |
narendravaghela |
morning all |
# |
Jun 26th 2018, 21:09 |
chrispecoraro |
Is there some camel-case magic going on here? |
# |
Jun 26th 2018, 21:09 |
chrispecoraro |
If I name a controller `EmployerApiController.php`, it looks for `ApiController` |
# |
Jun 26th 2018, 21:06 |
chrispecoraro |
figured it out.. ROOT was set one level below my app name... |
# |
Jun 26th 2018, 21:03 |
jurrieb |
thanks! |
# |
Jun 26th 2018, 21:03 |
itmpls |
er - who had a subdomain setup with cake and middleware here? |
# |
Jun 26th 2018, 20:56 |
saeideng |
$request->withParam |
# |
Jun 26th 2018, 20:52 |
jurrieb |
Hello can some one tell me if i can set a request parameter? |
# |
Jun 26th 2018, 20:44 |
chrispecoraro |
I get "Controller class ApiController could not be found." I guess there is some magic going on somewhere... |
# |
Jun 26th 2018, 20:44 |
chrispecoraro |
So I can then have `Controller/api/v1/EmployeeApiController.php`? |
# |
Jun 26th 2018, 20:43 |
chrispecoraro |
And then ```App::build([ 'Controller' => [ ROOT . '/app/Controller/', ROOT . '/app/Controller/api/v1/' ] ]); ``` |
# |
Jun 26th 2018, 20:43 |
chrispecoraro |
```Router::mapResources('api/v1/employeeApi');``` |
# |
Jun 26th 2018, 20:43 |
chrispecoraro |
So can I do: |
# |
Jun 26th 2018, 20:38 |
chrispecoraro |
Ok thanks SOOO much! |
# |
Jun 26th 2018, 20:36 |
hmic |
you might want to upgrade to 3.x to get all the new things ;-) |
# |
Jun 26th 2018, 20:36 |
hmic |
routing prefixes in 2.x do not work with subdirs but are mapped in the same contoller. if you add another search path for controllers, you still can't have the same classname as in the non-api dir. 2.x does not utilize namespaces and it's not possible to emulate the behavior so easily |
# |
Jun 26th 2018, 20:34 |
hmic |
you can have and use a custom view class easily to do just that without involving any template per action in your api prefixed controllers |
# |
Jun 26th 2018, 20:32 |
chrispecoraro |
```<?php echo json_encode(compact('employees')); ``` |
# |
Jun 26th 2018, 20:32 |
chrispecoraro |
Also, it seems like overkill just to create a view for entity in the RESTful API just to do: |
# |
Jun 26th 2018, 20:31 |
chrispecoraro |
and/or use a URL prefix with API URLs? |
# |
Jun 26th 2018, 20:30 |
chrispecoraro |
..in conjunction with ```App::build([ 'Controller' => [ ROOT . '/app/Controller/', ROOT . '/app/Controller/api/v1/' ] ]); ``` |
# |
Jun 26th 2018, 20:30 |
chrispecoraro |
```Router::mapResources('employees'); Router::parseExtensions(); ``` |
# |
Jun 26th 2018, 20:30 |
chrispecoraro |
So as far as you know, I can't use: |
# |
Jun 26th 2018, 20:29 |
hmic |
aditionally read the migration guide of course to make sure you catch up on all the ugly details :O |