Fenos\Notifynder\Models\NotifynderCollection::translate PHP Method

translate() public method

This method translate the body text from another language. It used by collection.
public translate ( $language ) : Illuminate\Database\Eloquent\Collection
$language (String)
return Illuminate\Database\Eloquent\Collection
    public function translate($language)
    {
        // Loop through the notifications
        foreach ($this->items as $key => $item) {
            try {
                $translation = $this->translator()->translate($language, $this->items[$key]['body']['name']);
                $this->items[$key]['body']['text'] = $translation;
            } catch (NotificationTranslationNotFoundException $e) {
                $this->items[$key]['body']['text'];
            }
        }
        $this->parse();
        return $this;
    }