protected function selectQuery(array $where = []) { $query = parent::selectQuery($where); // Join to messages and load message id $query->join('messages', 'LEFT')->on('posts.id', '=', 'messages.post_id')->select(['messages.id', 'message_id'], ['messages.type', 'source']); return $query; }
protected function selectQuery(array $where = []) { $query = parent::selectQuery($where); // Select 'key' too $query->select($this->getTable() . '.*', 'form_attributes.key')->join('form_attributes')->on('form_attribute_id', '=', 'form_attributes.id'); return $query; }
public function update(Entity $entity) { $state = ['updated' => time()]; if ($entity->hasChanged('password')) { $state['password'] = $this->hasher->hash($entity->password); } return parent::update($entity->setState($state)); }
public function create(Entity $entity) { $id = $this->getId($entity); if ($id) { // No need to insert a new record. // Instead return the id of the notification that exists return $id; } $state = ['user_id' => $entity->user_id, 'created' => time()]; return parent::create($entity->setState($state)); }
public function create(Entity $entity) { $state = ['created' => time()]; return parent::create($entity->setState($state)); }
public function update(Entity $entity) { return parent::update($entity->setState(['updated' => time()])); }
/** * Override selectQuery to enforce filtering by search=0/1 */ protected function selectQuery(array $where = []) { $query = parent::selectQuery($where); $query->where('search', '=', (int) $this->savedSearch); return $query; }
public function __construct(Database $db, Uploader $upload) { parent::__construct($db); $this->upload = $upload; }