# |
Nov 9th 2019, 14:26 |
slackebot1 |
QueryExpression $exp * @var Query $q */ // Concatenated Table1 Name $conc1 = $q->func() ->concat( [ 'Table1.first_name' => 'literal', ' ', 'Table1.last_name' => 'literal' ] ); $conc2 = $q->func() |
# |
Nov 9th 2019, 14:26 |
kevin.pfeifer |
Hey Chat, I have a question (current CakePHP 4 Version): I like to perform a concatinated where search on my base table and a connected table. ``` $query = $this->Table1->find( 'all' ) ->contain( ['Table2',] ); $search = $current_request->getQuery( 'search' ); $query->where( function( $exp, $q ) use ( $search ) { /** * @var |
# |
Nov 9th 2019, 09:16 |
alexdd55976 |
morning |
# |
Nov 9th 2019, 03:12 |
francisdoydora |
nevermind, figured it out :slightly_smiling_face: |
# |
Nov 9th 2019, 02:52 |
francisdoydora |
good morning everyone :slightly_smiling_face: ```$this->Auth->identify()``` fails when I put it in a Cell. anyway this can be fixed? error returned is ```Error: Method App\View\Cell\SwitchSidebarCell::__toString() must not throw an exception, caught Error: Could not render cell - Call to a member function identify() on null [/var/www/html/juniorhigh/src/View/Cell/SwitchSidebarCell.php, line 39]``` |
# |
Nov 8th 2019, 21:09 |
sdevore |
> You can use the second parameter of Router::connect() to provide any routing parameters that are composed of the default values of the route: ``` Router::connect( '/government', array('controller' => 'pages', 'action' => 'display', 5) ); ``` |
# |
Nov 8th 2019, 21:06 |
ricksaccous |
might need the double star i dunno |
# |
Nov 8th 2019, 21:06 |
ricksaccous |
ie just write the link using controller/action params but in routes make it route to /contact/* |
# |
Nov 8th 2019, 21:05 |
ricksaccous |
why aren't you using routes to handle this for you |
# |
Nov 8th 2019, 20:56 |
devito |
if you use the string I would need to build the query param and concat it it would seem. |
# |
Nov 8th 2019, 20:50 |
sdevore |
well you can always just use the string you want. Although is is a bit limiting. Let me look at another project here in a little bit and see if I did anything specific in that project because I am pretty sure I have handled in it differently |
# |
Nov 8th 2019, 20:17 |
devito |
i am also using query string params other wise I would just specify the url as a string |
# |
Nov 8th 2019, 20:16 |
devito |
got a cake2 html helper question. When using the link function and specifying a controller and action, is there a way to have the url go to the named route declaration instead of the controller/action route? like just go to /contact instead of /pages/contact ? |
# |
Nov 8th 2019, 18:39 |
samuel.assuncao |
@amanfulgence what youi want to do specifcally |
# |
Nov 8th 2019, 17:49 |
amanfulgence |
help me how create and use middelware |
# |
Nov 8th 2019, 17:18 |
samuel.assuncao |
Someone got a idea ? |
# |
Nov 8th 2019, 17:18 |
slackebot1 |
associations too, I do not see any example on documentation how i can do that with the cake ORM |
# |
Nov 8th 2019, 17:18 |
slackebot1 |
'Plants' ]); But Instead of getting the actual saved value from my table Purchase, I need get the data from the tables from a certain date. Sales Purchases to get volume_vendido -> created date and filter it to the $date(which is YYYY-MM-DD already) I also need the same for Purchases_Transfers (which is volume_transferido) and Purchase_Devolutions (which is volume_devolvido) So I need a where condition which will filter the |
# |
Nov 8th 2019, 17:18 |
samuel.assuncao |
$purchases = TableRegistry::get('Purchases')->find() ->where([ 'data_compra <=' => $date, 'volume_comprado + volume_transferido - volume_devolvido - volume_vendido > 0' ]) //certo ->matching('Plants') ->orderAsc('Plants.razao_social') ->orderAsc('Purchases.created') ->contain([ 'Distributors', |
# |
Nov 8th 2019, 17:18 |
samuel.assuncao |
Hi guys! |
# |
Nov 8th 2019, 12:51 |
dev.cyrusjayson |
and more <3 |
# |
Nov 8th 2019, 12:50 |
dev.cyrusjayson |
more <3 here |
# |
Nov 8th 2019, 12:47 |
dev.cyrusjayson |
oh! |
# |
Nov 8th 2019, 12:46 |
frank |
@dev.cyrusjayson Yeah, it’s just because it’s looking in the namespace of your controller when you don’t define it at the top |
# |
Nov 8th 2019, 12:43 |
dev.cyrusjayson |
that is the response |
# |
Nov 8th 2019, 12:43 |
frank |
@dev.cyrusjayson use Cake\ORM\Query; at the top |
# |
Nov 8th 2019, 12:43 |
dev.cyrusjayson |
I get this error ``` [TypeError] Argument 1 passed to App\Controller\FruitsController::App\Controller\{closure}() must be an instance of App\Controller\Query, instance of Cake\ORM\Query given, called in ...``` |
# |
Nov 8th 2019, 12:40 |
frank |
@dev.cyrusjayson This is what I mean, does this give the error also? ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits' => function (Query $q) { return $q ->select(['id', 'name']) ->where(['user_id' => 1]); }]); ``` |
# |
Nov 8th 2019, 12:37 |
frank |
@dev.cyrusjayson Wait, so with the `=>` it gave that as well? |
# |
Nov 8th 2019, 12:35 |
dev.cyrusjayson |
‘Illegal offset type in isset or empty’ |
# |
Nov 8th 2019, 12:32 |
frank |
@dev.cyrusjayson Okay, yeah that should work. What did the internal server error say, did it provide any context? |
# |
Nov 8th 2019, 12:31 |
dev.cyrusjayson |
here |
# |
Nov 8th 2019, 12:30 |
dev.cyrusjayson |
gave_fruits, sorry not in the screenshot |
# |
Nov 8th 2019, 12:29 |
frank |
@dev.cyrusjayson In which table is the user_id? |
# |
Nov 8th 2019, 12:24 |
dev.cyrusjayson |
this is the models |
# |
Nov 8th 2019, 12:22 |
dev.cyrusjayson |
following this is not helping https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#passing-conditions-to-contain |
# |
Nov 8th 2019, 12:20 |
dev.cyrusjayson |
An Internal Server Error Occurred |
# |
Nov 8th 2019, 12:19 |
dev.cyrusjayson |
@frank I got internal error this is only thing is working but I want to filter the GaveFruits by user_id so I can get specific only ```$fruits = $this->Fruits->find('all') ->contain(['GaveFruits']);``` |
# |
Nov 8th 2019, 12:16 |
frank |
@dev.cyrusjayson Could you try `'GaveFruits' => function ….` instead of `'GaveFruits', function ….` (arrow vs comma) |
# |
Nov 8th 2019, 12:08 |
slackebot1 |
[CORE/src/ORM/EagerLoader.php, line 410]``` but if I remove the ->where([‘user_id’ => 1]) everything is working so I think the problem is in ->where but based on the documentation, I am fopllowing it correctly |
# |
Nov 8th 2019, 12:08 |
dev.cyrusjayson |
I have this query ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits',function (Query $q){ return $q ->select(['id', 'name']) ->where(['user_id' => 1]); }]); ``` and I get this error ```Warning (2): Illegal offset type in isset or empty |