Archived
1
0
Fork 0
This repository has been archived on 2026-06-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
wow-raid-bingo/app/View/Components/CardText.php

43 lines
933 B
PHP

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