0

I want to send notifications by Laravel, everything works fine but I have sort of style issue,

How can I add <br> tag to this line of php?

public function toTelegram($product)
    {
     return TelegramMessage::create()
         ->to('@xxxxx')
         ->content('New Product is here ' .$product->title) //need br here
         ->button('Shop Now', 'http://domain.co/store/'. $product->slug);
    }

I want $product->title shows in a new line when the user receives the notification.

PS: I tried \n , \r\n even <br> but nothing changed.

this is how it looks like now:

screen 1

Bablu Ahmed
  • 4,412
  • 5
  • 49
  • 64
mafortis
  • 6,750
  • 23
  • 130
  • 288

3 Answers3

0

Replace below line

content('New Product is here ' .$product->title)

by

content(nl2br("New Product is here  \n" .$product->title))
Bhoomi
  • 527
  • 2
  • 14
0

I think you should change this line,
->content('New Product is here ' .$product->title) //need br here
to this,
->content('New Product is here '.'<br>'.$product->title)
try replacing the < br> with \n...

omkaartg
  • 2,676
  • 1
  • 10
  • 21
0
->content('New Product is here '.PHP_EOL.$product->title);

I think PHP_EOL should work. It is php after all.

Also doing some research i think this one should also work:

->content("New Product is here  \n".$product->title); //double quotes
pr1nc3
  • 8,108
  • 3
  • 23
  • 36