コード例 #1
0
 /**
  * Set type value.
  */
 public function setTypeAttribute()
 {
     $this->attributes['type_id'] = EloquentNotificationTypeRepository::findByType($this->type)->id;
 }
コード例 #2
0
 /**
  * Get driver notifications with conditions
  *
  * @param $from
  *
  * @param $to
  *
  * @return mixed
  */
 public function with_notifications($from, $to)
 {
     $query = $this->notifications();
     if (!$this->notify_sale) {
         $query->where('type_id', '<>', EloquentNotificationTypeRepository::findByType('sales')->id);
     }
     if (!$this->notify_inventory) {
         $query->where('type_id', '<>', EloquentNotificationTypeRepository::findByType('inventory')->id);
     }
     if (!$this->notify_feedback) {
         $query->where('type_id', '<>', EloquentNotificationTypeRepository::findByType('thumbs')->id);
     }
     if (!$this->notify_others) {
         $query->where('type_id', '<>', EloquentNotificationTypeRepository::findByType('emails')->id);
     }
     return $query->where('created_at', '>=', $from)->where('created_at', '<=', $to)->orderBy('created_at', 'desc')->get();
 }