Thursday, October 18, 2018

CakePHP JWT AUTH Plugin

https://github.com/ADmad/cakephp-jwt-auth

CakePhp Eluquent Subquery Example

public function beforeSave(Event $event, Entity $entity){ } public function initialize(array $config) { $this->addBehavior('Timestamp'); //gestion des colonnes created et modified $this->hasMany('ForumPosts'); $this->hasOne('LastForumPost', [ 'className' => 'ForumPosts', 'foreignKey' => false, 'conditions' => function ($exp, $query) { $subquery = $query ->getConnection() ->newQuery() ->select(['SubLastForumPost.id']) ->from(['SubLastForumPost' => 'forum_posts']) ->where([ 'SubLastForumPost.draft = false', //to remove for admin 'SubLastForumPost.created IS NOT NULL', 'ForumCategories.id = SubLastForumPost.forum_category_id', 'SubLastForumPost.parent_id IS NULL']) ->order(['SubLastForumPost.created' => 'DESC']) ->limit(1); return $exp->add(['LastForumPost.id' => $subquery]); } ]); }From cakephp forum