# |
Mar 12th 2018, 06:52 |
joddit |
Checking the API docs rq |
# |
Mar 12th 2018, 06:52 |
joddit |
Examples in the book in the docs only show saving associations on existing records, not creating both initial record and associations at same time |
# |
Mar 12th 2018, 06:50 |
aneh |
wait will post sql here |
# |
Mar 12th 2018, 06:49 |
joddit |
Did it even attempt the insert for the address record(s)? |
# |
Mar 12th 2018, 06:49 |
joddit |
Did you check the SQL log in debugkit? |
# |
Mar 12th 2018, 06:48 |
aneh |
you can check here |
# |
Mar 12th 2018, 06:48 |
aneh |
https://stackoverflow.com/questions/49229158/error-saving-associated-data-cakephp-3 |
# |
Mar 12th 2018, 06:48 |
aneh |
i did not get any error from cakephp but it did not create entry on address table |
# |
Mar 12th 2018, 06:46 |
joddit |
Are you updating an existing record or creating a new record? |
# |
Mar 12th 2018, 06:45 |
joddit |
Please |
# |
Mar 12th 2018, 06:45 |
joddit |
Would be easier if you pasted the error with structure somewhere like https://gist.github.com/ |
# |
Mar 12th 2018, 06:41 |
slackebot |
} We need to save multiple address under one address header id. when i run above code it create entry in address_header but did not make any entry in addresses table. |
# |
Mar 12th 2018, 06:41 |
slackebot |
'company_id' => 4, 'name' => 'Aneh' ] ]; $entity = $this->AddressHeaders->newEntity(); $entity = $this->AddressHeaders->patchEntity($entity, $data, [ 'associated' =>['Addresses'] ]); if($this->AddressHeaders->save($entity)){ echo "save"; }else{ pr($entity->errors()); |
# |
Mar 12th 2018, 06:41 |
aneh |
Error saving associated data AddressHeadersTable $this->hasMany('Addresses', [ 'foreignKey' => 'address_header_id' ]); AddressesTable $this->belongsTo('AddressHeaders', [ 'foreignKey' => 'address_header_id', ]); Controller Code $data = [ 'user_id' => 1, 'company_id' => 4, 'address' => [ 'user_id' => 1, |
# |
Mar 12th 2018, 05:29 |
savant |
strange |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
i'm doritos? :nerd_face: |
# |
Mar 12th 2018, 05:13 |
savant |
im layz |
# |
Mar 12th 2018, 05:13 |
savant |
same |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
lmao |
# |
Mar 12th 2018, 05:13 |
angelxmoreno |
i was always a default routes kinda guy |
# |
Mar 12th 2018, 05:11 |
savant |
lots of people complained about not being able to remove them |
# |
Mar 12th 2018, 05:11 |
savant |
maybe 1.3 |
# |
Mar 12th 2018, 05:11 |
savant |
we added fallback routes in… 2.x? |
# |
Mar 12th 2018, 05:10 |
angelxmoreno |
sweet. +1 thing learned in Cake. all these years and still learning. love it |
# |
Mar 12th 2018, 05:10 |
angelxmoreno |
ok, it makes sense why i was getting the errors with the RouteCollection throwning exceptions |
# |
Mar 12th 2018, 05:09 |
savant |
or for cases where I dont want potentially duplicated content because i’ve defined a route for everything already |
# |
Mar 12th 2018, 05:09 |
angelxmoreno |
crap |
# |
Mar 12th 2018, 05:09 |
savant |
I do that for very small applications |
# |
Mar 12th 2018, 05:09 |
savant |
no fallbacks means you are explicitly defining routes |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
seems like with no fallbacks i get all sorts of errors |
# |
Mar 12th 2018, 05:08 |
joddit |
Uses the stock ones for the given scope, no? |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
i need to look into it more |
# |
Mar 12th 2018, 05:08 |
savant |
sure |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
does that make sense ? |
# |
Mar 12th 2018, 05:08 |
savant |
you can check the RouteCollection (?) class for the fallbacks method |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
``` $routes->prefix('api', function (RouteBuilder $routes) { $routes->connect('/finances/events', [ 'plugin' => 'Finances', 'controller' => 'Dashboard', 'action' => 'events', ]); $routes->fallbacks(DashedRoute::class); }); ``` |
# |
Mar 12th 2018, 05:08 |
savant |
the core ones |
# |
Mar 12th 2018, 05:08 |
savant |
It creates the fallback routes |
# |
Mar 12th 2018, 05:08 |
angelxmoreno |
@savant IDK what `$routes->fallbacks(DashedRoute::class);` does but that fixed my routing issue |
# |
Mar 12th 2018, 05:07 |
angelxmoreno |
there is nothing little about CakePHP lol. SLimPHP is my 2nd favorite framework and THAT is a little |
# |
Mar 12th 2018, 05:07 |
joddit |
Well it won't even accomplish what I need to accomplish so that idea is out |