Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 public function create(Entity $entity)
 {
     $state = ['created' => time()];
     return parent::create($entity->setState($state));
 }
Ejemplo n.º 6
0
 public function update(Entity $entity)
 {
     return parent::update($entity->setState(['updated' => time()]));
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 8
0
 public function __construct(Database $db, Uploader $upload)
 {
     parent::__construct($db);
     $this->upload = $upload;
 }