I am new to cakephp 3. Below is my code.
$getFlags = $this->Posts->find('all')->contain(['Users', 'Flags.Users', 'Flags.FlagReasons', 'Flags.Users.Schools']);
output
{
"id": 114,
"title": "",
"allow_comment": 0,
"owner_id": 84,
"created": "2016-04-08T04:41:08+0000",
"status": 1,
"flags": [],
"user": {
"id": 84,
"profile_image": "bc7484cd8caad0de055f8d7ef15551f5.png",
"is_active": 1
}
Here i want to give a condition,when there is an empty flag ,it will not be listed in result. Only post having flag will come. Please suggest me. ANy suggstion will highly appreciate.
There are two ways to get this done: