# |
Apr 27th 2017, 18:57 |
btx |
easier ** |
# |
Apr 27th 2017, 18:57 |
btx |
always makin things easy for future me :P |
# |
Apr 27th 2017, 18:57 |
aaronds |
for sure |
# |
Apr 27th 2017, 18:57 |
btx |
yeah but at least it will be doing it in one place globally, so if you ever need to add weird logic it will be easy to find where :) |
# |
Apr 27th 2017, 18:56 |
aaronds |
That surely still needs to figure out namespace/prefix stuff in the same disgusting manner? |
# |
Apr 27th 2017, 18:54 |
btx |
maybe something like a `Trait` that provides a method on the controller to build a url according to your app rules? |
# |
Apr 27th 2017, 18:53 |
aaronds |
You're correct @btx, that would be a side effect |
# |
Apr 27th 2017, 18:53 |
aaronds |
I suppose for now I'll just use ReflectionMethod or something to figure out what the prefix should be based on the namespace of the class. But this feels wrong and horrible, it just allows for automagicalabilities. |
# |
Apr 27th 2017, 18:52 |
btx |
that would be almost 100% guaranteed to break tho if you ever need to overload a class provided by, ie., a plugin |
# |
Apr 27th 2017, 18:51 |
btx |
hmm. not sure about that one lol |
# |
Apr 27th 2017, 18:49 |
aaronds |
so, what that really needs, is `Router::url(['prefix' => $namespaceOfController, 'controller' => $controllerName, 'action' => 'bar']);` |
# |
Apr 27th 2017, 18:48 |
aaronds |
@btx, I should have mentioned I'm attempting to do this given an instance of a controller >_< |
# |
Apr 27th 2017, 18:45 |
btx |
sure , you can do something like `Router::url( ['prefix'=>false, 'controller'=>'Foo', 'action'=>'bar'] )` but if anything ever changes (e.g. if you need to overload FooController in the future, or nest it) you need to replace all occurances in your code. |
# |
Apr 27th 2017, 18:45 |
aaronds |
I'm thinking something to the effect of Route::url(App\Controller\FooController, 'myAction'); |
# |
Apr 27th 2017, 18:43 |
aaronds |
@btx, I've already got some routes established using Route::prefix (in my case, it's an admin/ prefix), with the relevant controllers residing in App\Controller\Admin. Rather than hard coding named routes for each controller, is there not a way to generate a URL for a controller that is outside this prefix (e.g at /foo, residing in App\Controller\FooController)? |
# |
Apr 27th 2017, 18:38 |
btx |
np |
# |
Apr 27th 2017, 18:38 |
Leonardo_0112 |
btx: OK, thanks for the explanations ;) |
# |
Apr 27th 2017, 18:37 |
btx |
@aaronds - one of the safest (imho) ways to generate urls is to use named routes (combinations of ‘_namePrefix’ and ‘_name’) |
# |
Apr 27th 2017, 18:36 |
btx |
Dealer hasOne Store, Store belongsTo Dealers. So you need a `Stores.dealer_id` (and nothing needed in Dealers) |
# |
Apr 27th 2017, 18:35 |
aaronds |
Hi all. Does anyone know the easiest possible way to generate a URL for a given controller + method, even if that controller happens to be in another namespace? |
# |
Apr 27th 2017, 18:35 |
Leonardo_0112 |
btx: in my case, one Dealer has only one Store, but i decided to split in in two table (delaers and stores, intead just one). Which table receives the *_id? dealers or stores? |
# |
Apr 27th 2017, 18:33 |
btx |
@Leonardo_0112 - hasOne would require the related table to have a `*_id` column in it. Only use that when model A has one and only one of model B. If a Dealer can have multiple stores then the relationship is Dealer hasMany Stores, Stores belongsTo Dealers |
# |
Apr 27th 2017, 18:30 |
Leonardo_0112 |
btx: should i use foreign keys? |
# |
Apr 27th 2017, 18:30 |
youto_us |
Hi guys, how do you deal with multiple forms and when the securityComponement isactivated. I tried to set 'secure' => 'skip' in the form's options. My forms are not targeting the same URL. The last form of the template overwrite the security token. |
# |
Apr 27th 2017, 18:30 |
Leonardo_0112 |
btx: how i do hasOne association? When a table is just a complement for another, a 1:1 relation |
# |
Apr 27th 2017, 18:29 |
btx |
they should be belongsTo - that’s why it’s look for store_id in Dealers |
# |
Apr 27th 2017, 18:28 |
Leonardo_0112 |
btx: they are hasOne association |
# |
Apr 27th 2017, 18:26 |
btx |
fwiw I would do chaining syntax, too `$this->Stores->find()->contain(['Dealers.Users'])` |
# |
Apr 27th 2017, 18:25 |
btx |
@Leonardo_0112 did you make sure to set your associations on the related models? E.g. Stores belongsTo Dealers belongsTo Users |
# |
Apr 27th 2017, 18:15 |
Leonardo_0112 |
I'm facing a database retrieve data issue, so I created a gist (https://gist.github.com/anonymous/3b3cb40a06c1fd0a493b79903fd6274a). Any ideas how can I solve it? |
# |
Apr 27th 2017, 17:50 |
chris-andre |
Does someone know about a gantt chart class? |
# |
Apr 27th 2017, 17:02 |
dakota |
pedroseco, how are you doing it? |
# |
Apr 27th 2017, 16:42 |
pedroseco |
can’t seem to make it work, always not found. |
# |
Apr 27th 2017, 16:42 |
pedroseco |
How can we load a Theme inside a plugin? |
# |
Apr 27th 2017, 16:42 |
pedroseco |
Hi guys. |
# |
Apr 27th 2017, 16:35 |
dariolap |
records on applications that have the same agent_id and company_id |
# |
Apr 27th 2017, 16:35 |
dariolap |
Hi all, I have a model Applications that belongs to Agents and Companies.... when i save on Applications i also add Agent and Company entities (if they exists)....now, the problem at buildRules level... i have added $rules->isUnique(['agent_id', 'company_id'] on ApplicationsTable the problem is that cake is not "mapping" agent_id by looking ad the Agent entity i have passed (same thing for company entity) in this case i am able to save multiple |
# |
Apr 27th 2017, 15:51 |
joris_ |
for apache: `sudo a2enmod mod_rewrite andand sudo services apache2 restart |
# |
Apr 27th 2017, 15:49 |
joris_ |
have you enable mod_rewrite ? |
# |
Apr 27th 2017, 15:45 |
greenmanspirit |
hey all, I am on 2.x and when I set the document root to app/webroot, all of my routes seem to not work anymore. It is giving me a 404 for all of my routes. |
# |
Apr 27th 2017, 15:30 |
dereuromark |
What you mean? Is that an issue? Worked for me so far. |