Log message #4212797

# At Username Text
# Nov 7th, 16:15 slackebot1 }]);``` What would be wrong?
# Nov 7th, 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, 15:59 slackebot1 DevicesController::crud.bulk/delete() could not be found, or is not accessible.`
# Nov 7th, 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, 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, 15:49 dev.cyrusjayson okay I will look closely
# Nov 7th, 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, 15:47 javier.villanueva but you need define better in your model
# Nov 7th, 15:47 javier.villanueva you dont need this complex find
# Nov 7th, 15:46 javier.villanueva https://book.cakephp.org/3/en/orm/associations.html#belongstomany-associations
# Nov 7th, 15:46 javier.villanueva you should read the doc
# Nov 7th, 15:44 slackebot1 }]); ```
# Nov 7th, 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, 15:40 javier.villanueva not need in this case
# Nov 7th, 15:39 javier.villanueva you can specify you type of join in definition
# Nov 7th, 15:37 javier.villanueva yes
# Nov 7th, 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, 15:33 dev.cyrusjayson okay I will have a look
# Nov 7th, 15:33 javier.villanueva but if only needs the relationship you dont need it
# Nov 7th, 15:32 javier.villanueva https://book.cakephp.org/3/en/orm/associations.html#using-the-through-option
# Nov 7th, 15:32 javier.villanueva If you have another fields for gave_fruits (for instance gave_date) then you can use throught optionn
# Nov 7th, 15:31 dev.cyrusjayson ok I will try this belongsToMany
# Nov 7th, 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, 15:31 javier.villanueva fruits belongsToMany users
# Nov 7th, 15:31 javier.villanueva could be a model, but really is a relationship
# Nov 7th, 15:31 dev.cyrusjayson but I don’t mind about details of users
# Nov 7th, 15:31 javier.villanueva gave_fruits is not a model
# Nov 7th, 15:30 dev.cyrusjayson no. user_id is foreign key to Gave_Fruits
# Nov 7th, 15:30 javier.villanueva three tables, fruits, users, fruits_users
# Nov 7th, 15:30 javier.villanueva its true?
# Nov 7th, 15:30 javier.villanueva only two models, not three
# Nov 7th, 15:30 javier.villanueva there are FRUITS AND USERS
# Nov 7th, 15:30 javier.villanueva and there are not model b
# Nov 7th, 15:29 javier.villanueva you need belongsToMany assoc
# Nov 7th, 15:29 javier.villanueva ok then
# Nov 7th, 15:29 dev.cyrusjayson hhhmmm… im not good at explaining. let me give an example. there are 3 fruits apple, orange, banana I gave apple and orange to user 1 and I want to display all fruits and what fruits I gave to user 1 Fruits Gave Fruits apple apple orange orange banana
# Nov 7th, 15:29 javier.villanueva IF YES
# Nov 7th, 15:27 javier.villanueva no, my question is if model b is a MODEL of only a relationship between model A and users
# Nov 7th, 15:27 dev.cyrusjayson model b could have 2 data from model a but model a always greater
# Nov 7th, 15:26 javier.villanueva it has more fields than model_a_id, user_id
# Nov 7th, 15:25 javier.villanueva and do you need model b?