1
0
Fork 0
wow-raid-bingo/app/View/Components/CardText.php
2021-10-18 11:56:52 +02:00

40 lines
830 B
PHP

<?php
namespace App\View\Components;
use Illuminate\View\Component;
use App\Models\Card;
class CardText extends Component
{
protected Card $card;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(Card $card)
{
$this->card = $card;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
$subject = preg_quote(__($this->card->subject));
// Replace non escaped '?' with subject and also Unescape escaped '?'
$text = preg_replace(
['/(?<!\\\\)\?/u', '/\\\\\\?/u'] ,
["<strong>$subject</strong>", '?'],
$this->card->body);
return $text;
}
}