Log message #4212803

# At Username Text
# Nov 7th 2019, 16:24 javier.villanueva what error you have?
# Nov 7th 2019, 16:24 dev.cyrusjayson yes because the gave_fruits has user_id and I want to get only the data for specific user
# Nov 7th 2019, 16:23 javier.villanueva the function is for passing conditions to contain
# Nov 7th 2019, 16:23 dev.cyrusjayson the id is the id of gave_fruits. forget the select, could be more
# Nov 7th 2019, 16:22 javier.villanueva anyway you can add conditions to contain without function
# Nov 7th 2019, 16:20 javier.villanueva your gavefruits table has "id" field?
# Nov 7th 2019, 16:15 slackebot1 }]);``` What would be wrong?
# Nov 7th 2019, 16:15 dev.cyrusjayson This is working ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits']); ``` This is not working ``` $fruits = $this->Fruits->find('all') ->contain(['GaveFruits', function (Query $q){ return $q ->select(['id']) ->where(['user_id' => 1]);
# Nov 7th 2019, 15:59 slackebot1 DevicesController::crud.bulk/delete() could not be found, or is not accessible.`
# Nov 7th 2019, 15:59 slackebot1 'Crud.ApiQueryLog', 'Crud.Search', ], ], ]; ``` And my route like this: ``` $routes->resources('Devices', # @todo: this is only for demo purposes, deleting all devices is not desirable [ 'map' => [ 'deleteAll' => [ // this is the route in the URL 'action' => 'Crud.Bulk/Delete', // this is the action it matches 'method' => 'DELETE', ], ], ]); ``` The error is: `Action
# Nov 7th 2019, 15:59 noel Hi guys. I'm working with `friendsofcake/crud`. I want to map bulk delete but can't figure out how. I have my AppController components defined like this: ``` public $components = [ 'RequestHandler', 'Crud.Crud' => [ 'actions' => [ 'Crud.Index', 'Crud.View', 'Crud.Add', 'Crud.Edit', 'Crud.Delete', ], 'listeners' => [ 'CrudJsonApi.JsonApi', 'CrudJsonApi.Pagination', // Pagination != ApiPagination
# Nov 7th 2019, 15:49 dev.cyrusjayson okay I will look closely
# Nov 7th 2019, 15:49 javier.villanueva I advice you that if you dont need a model for gavefruits, dont use a model. Define the relations in UsersModel and FruitsModel
# Nov 7th 2019, 15:47 javier.villanueva but you need define better in your model
# Nov 7th 2019, 15:47 javier.villanueva you dont need this complex find
# Nov 7th 2019, 15:46 javier.villanueva https://book.cakephp.org/3/en/orm/associations.html#belongstomany-associations
# Nov 7th 2019, 15:46 javier.villanueva you should read the doc
# Nov 7th 2019, 15:44 slackebot1 }]); ```
# Nov 7th 2019, 15:44 dev.cyrusjayson not working. what is wrong here ``` Model $this->belongsToMany('GaveFruits', [ 'foreignKey' => 'fruit_id' ]); ---------- in Controller $fruits = $this->Fruits->find('all') ->contain(['GaveFruits'=>function(Query $q){ return $q ->where(['GaveFruits.user_id' => 1]);
# Nov 7th 2019, 15:40 javier.villanueva not need in this case
# Nov 7th 2019, 15:39 javier.villanueva you can specify you type of join in definition
# Nov 7th 2019, 15:37 javier.villanueva yes
# Nov 7th 2019, 15:36 dev.cyrusjayson in raw query it will be like this ``` select * from fruits left join gave_fruits on fruits.id = gave_fruits.fruits_id and gave_fruits.user_id = 1 where <condition here>```
# Nov 7th 2019, 15:33 dev.cyrusjayson okay I will have a look
# Nov 7th 2019, 15:33 javier.villanueva but if only needs the relationship you dont need it
# Nov 7th 2019, 15:32 javier.villanueva https://book.cakephp.org/3/en/orm/associations.html#using-the-through-option
# Nov 7th 2019, 15:32 javier.villanueva If you have another fields for gave_fruits (for instance gave_date) then you can use throught optionn
# Nov 7th 2019, 15:31 dev.cyrusjayson ok I will try this belongsToMany
# Nov 7th 2019, 15:31 dev.cyrusjayson because I know who is he already so I just want to pull all fruits and giving fruits to him
# Nov 7th 2019, 15:31 javier.villanueva fruits belongsToMany users
# Nov 7th 2019, 15:31 javier.villanueva could be a model, but really is a relationship
# Nov 7th 2019, 15:31 dev.cyrusjayson but I don’t mind about details of users
# Nov 7th 2019, 15:31 javier.villanueva gave_fruits is not a model
# Nov 7th 2019, 15:30 dev.cyrusjayson no. user_id is foreign key to Gave_Fruits
# Nov 7th 2019, 15:30 javier.villanueva three tables, fruits, users, fruits_users
# Nov 7th 2019, 15:30 javier.villanueva its true?
# Nov 7th 2019, 15:30 javier.villanueva only two models, not three
# Nov 7th 2019, 15:30 javier.villanueva there are FRUITS AND USERS
# Nov 7th 2019, 15:30 javier.villanueva and there are not model b
# Nov 7th 2019, 15:29 javier.villanueva you need belongsToMany assoc
# Nov 7th 2019, 15:29 javier.villanueva ok then