# |
Feb 17th 2020, 16:37 |
dan874 |
thats what we were trying to achieve with the above solution |
# |
Feb 17th 2020, 16:37 |
dan874 |
but if your doing a route for instance that has a ID how do you then in your controller method tell it to swap that ID for the model? |
# |
Feb 17th 2020, 16:37 |
flashios09 |
```function (User $user) { // ... }``` |
# |
Feb 17th 2020, 16:35 |
flashios09 |
but if you need typehint for any property, all you have to do is to write something like this: |
# |
Feb 17th 2020, 16:35 |
dan874 |
no need to apologise @flashios09 sorry for my terrible explanation. |
# |
Feb 17th 2020, 16:34 |
flashios09 |
sorry @dan874 i can’t help you here |
# |
Feb 17th 2020, 16:33 |
dan874 |
it was just something we were trying out so im going to look more into the request with Param area. thanks all though as its guided me down a path |
# |
Feb 17th 2020, 16:32 |
dan874 |
so im just wondering if the size of the model is causing an issue with the request as its loading in a number of contains at the same time. |
# |
Feb 17th 2020, 16:32 |
dan874 |
as in i go through the session is maintained correctly and it all works |
# |
Feb 17th 2020, 16:32 |
dan874 |
so if i remove the $request->withParam line everything works as expected |
# |
Feb 17th 2020, 16:31 |
ndm |
Even if someone had done something like that, it wouldn't necessarily help to figure what might be happening in your application. It would probably be better if you elaborated on the latter. What is that particular route and set of data? What does "_blowing up_" exactly mean? What does your error logs say? ... |
# |
Feb 17th 2020, 16:23 |
dan874 |
and this allows us to typehint entities on the controllers |
# |
Feb 17th 2020, 16:23 |
slackebot |
$request->getParam('_matchedRoute')); $paramIndex = array_search($parameter, $passedParams, true); if (!empty($paramIndex)) { return $request->withParam('pass.' . ($paramIndex - 1), $model); } return $request; }``` |
# |
Feb 17th 2020, 16:23 |
dan874 |
at the core its just ``` /** * Bind the model to the route as part of the request * * @param ServerRequestInterface $request * @param Entity $model * @param string $parameter * @return ServerRequestInterface */ public function bindModelToRoute( ServerRequestInterface $request, Entity $model, string $parameter )ServerRequestInterface { $passedParams = explode('/:', |
# |
Feb 17th 2020, 16:22 |
flashios09 |
sorry i don’t know anything about Laravel, i haven’t used any other php framework |
# |
Feb 17th 2020, 16:21 |
dan874 |
but looking at it, this is what seems to be causing the issue with my session now as for some reason on a particular route with a particular set of data its blowing it up. |
# |
Feb 17th 2020, 16:21 |
dan874 |
sorry its a laravel term. basically if i have a model called user and in the route i have a `userId` then what ive done is in a middleware swap that user id out with the user so in the controller i can typehint the user entity |
# |
Feb 17th 2020, 16:20 |
flashios09 |
@dan874 what do you mean by *route model binding* ? |
# |
Feb 17th 2020, 16:19 |
flashios09 |
change `posts` with your table name |
# |
Feb 17th 2020, 16:19 |
flashios09 |
```SELECT Posts.id AS `Posts__id`, 1 AS `my_filter`, DATE(modified) AS `modified_date` FROM posts Posts``` |
# |
Feb 17th 2020, 16:18 |
dan874 |
has anyone ever tried to setup route model binding in cakephp? |
# |
Feb 17th 2020, 16:17 |
flashios09 |
try to execute the query manually (copy/paste it) |
# |
Feb 17th 2020, 16:15 |
flashios09 |
@shifat.it both works for me |
# |
Feb 17th 2020, 16:08 |
shifat.it |
Following code works ``` ->select([ 'id', 'my_filter' => 1, 'modified_date' => 'DATE(modified)', ])``` But following doesn't works ``` ->select([ 'id', 'my_filter' =>"1", 'modified_date' => 'DATE(modified)', ])``` why? latter one shows column doesnt exist |
# |
Feb 17th 2020, 16:07 |
flashios09 |
where can i ask about FriendsOfCake/crud-json-api ? |
# |
Feb 17th 2020, 16:06 |
flashios09 |
hi |
# |
Feb 17th 2020, 15:58 |
admad |
@dan874 if you are using default file based session make sure you haven't run out disk space |
# |
Feb 17th 2020, 15:54 |
dan874 |
it gets all the way to read from the session storage for `Auth.User` and blows up |
# |
Feb 17th 2020, 15:54 |
dan874 |
its just odd as this has literally just started to happen when it was stable for about a month and a half |
# |
Feb 17th 2020, 15:53 |
dan874 |
so its trying to read for the logged in user using the AuthComponent. |
# |
Feb 17th 2020, 15:52 |
k4t |
check your logs first, you can have more detailes info there |
# |
Feb 17th 2020, 15:51 |
dan874 |
just trying to figure out i there is something going on in a before filter that might be causing it |
# |
Feb 17th 2020, 15:50 |
k4t |
what do you have in cakephp logs? |
# |
Feb 17th 2020, 15:47 |
dan874 |
has anyone ever come across an issue where a simple redirect would cause a session to stop working? for some reason im not getting `Error: [RuntimeException] Could not start the session` when hitting the new page after the redirect and im then logged out. |
# |
Feb 17th 2020, 15:43 |
willem |
with a table setup like so. how would i get the full history in a cake query? |
# |
Feb 17th 2020, 15:42 |
slackebot |
who fill give me ready solution and do whole work for me. Looking for advices/hints. Thank you! |
# |
Feb 17th 2020, 15:42 |
k4t |
can you recommend some kind of tutorial/articles/examples in which I can read about good practices for implementing data filtering? You know, in my project I have 3 dropdowns: dates, products, products type. Date and Product Type filters should add/remove query string parameter from url. Products filter contains normal links to each product but it should keep query string filters from Dates and Products Type filters. I am not looking for someone |
# |
Feb 17th 2020, 15:38 |
k4t |
Hello |
# |
Feb 17th 2020, 13:52 |
dereuromark |
Also the respective docs then per use case. |
# |
Feb 17th 2020, 13:52 |
dereuromark |
Did you read the above articles in detail? That should answer this very question. |
# |
Feb 17th 2020, 13:50 |
md.islam11 |
can i call a function of table in select() ? |