public function has($table, $id, $account_id) { $count = Model::Favorite()->where(['table', '=', $table])->where(['table_id', '=', (int) $id])->where(['account_id', '=', (int) $account_id])->cursor()->count(); return $count > 0 ? true : false; }