/** * Add message with alias. * * @param $message * @return void */ protected function addAliased($message) { $inserted = false; foreach ($this->notifications as $m) { if ($message->getAlias() == $m->getAlias()) { $index = $this->notifications->indexOf($m); if ($index !== false) { $this->notifications->offsetUnset($index); $this->notifications->setAtPosition(is_null($message->getPosition()) ? $index : $message->getPosition(), $message); $inserted = true; } } } if (!$inserted) { if (!is_null($message->getPosition())) { $this->notifications->setAtPosition($message->getPosition(), $message); } else { $this->notifications->addUnique($message); } } }
/** * Returns all flashable messages. * * @return \Krucas\Notification\Collection */ protected function getFlashable() { $collection = new Collection(); foreach ($this->all() as $message) { if ($message->isFlashable()) { $collection->addUnique($message); } } return $collection; }
/** * Returns all messages for given type. * * @param $type * @return \Krucas\Notification\Collection */ public function get($type) { $collection = new Collection(); foreach ($this->notifications as $key => $message) { if ($message->getType() == $type) { if (!is_null($message->getPosition())) { $collection->setAtPosition($key, $message); } else { $collection->addUnique($message); } } } return $collection; }