Log message #4227341

# At Username Text
# Feb 17th 2020, 16:48 neon1024 I don’t really see any benefits to the approach either
# Feb 17th 2020, 16:47 neon1024 You could use a middleware perhaps, but you’d have to set the entity into the request, and with associated data I would worry about setting a large entity and associated data into the request, as the request is passed to so many places
# Feb 17th 2020, 16:46 neon1024 ..but it wouldn’t allow it to be passed into the method
# Feb 17th 2020, 16:46 neon1024 You could use `beforeFilter()` for this, and set the found entity to a class property in the controller
# Feb 17th 2020, 16:46 flashios09 for some magic, i’m not sure but i think that you need to extend the controller and play with the invokeAction and the Reflection class
# Feb 17th 2020, 16:43 dan874 so instead of `int $proposal` the method could be `Proposal $proposal`
# Feb 17th 2020, 16:43 dan874 some magic to get the entity
# Feb 17th 2020, 16:42 flashios09 here you want to add typehint or have some magic to get the proposal entity ?
# Feb 17th 2020, 16:41 flashios09 yes, this is how cake works
# Feb 17th 2020, 16:40 dan874 but in cake we have `view(int $proposalId)` and then have to load the entity in inside the controller.
# Feb 17th 2020, 16:40 dan874 ok so i have a route `Proposals/view/1025173/primary` which maps to a `ProposalController/view` method, that method currently has no typehint as the parameter being passed to it is just a integer, what we can do in laravel is basically setup on the route a model binding so it knows when i give it ID `1025173` that it goes to the proposal table and loads that model in so in the `view(Proposal $proposal)` method like that.
# Feb 17th 2020, 16:38 flashios09 if you can explain more *what do you want to do*, maybe i can help you but with cake approach not Laravel
# Feb 17th 2020, 16:38 dan874 so when you get to the controller you already have your table/entity ready loaded, if that makes sense?
# 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