第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在郵件刀片視圖中的另一個變量中使用變量

在郵件刀片視圖中的另一個變量中使用變量

PHP
慕田峪9158850 2021-11-05 13:16:42
我在 Laravel 中使用 Mail 庫來發(fā)送帶有傳遞給刀片視圖的自定義數(shù)據(jù)的 html 電子郵件。當郵件必須呈現(xiàn)從數(shù)據(jù)庫中的一行獲取的 html 時產(chǎn)生的問題,其中包括我通過視圖傳遞的變量。這是我的可郵寄類中的構(gòu)建函數(shù)public function build(){   return $this->from('hello@test.it')     ->view('view')     ->with([       'url'     => 'https://google.com',       'text' => $this->parameters->text,      ]);}然后在刀片視圖中:<div>  {!! $text !!}</div>這是 $text 變量的樣子:<p>  <span>This is my text for the mail</span>  <a href="{{ $url }}">Click here to compile</a></p>鏈接 href 應包含 url 變量值,而不是不傳遞變量名本身
查看完整描述

2 回答

?
慕斯王

TA貢獻1864條經(jīng)驗 獲得超2個贊

一個簡單的解決方案是使用 php 進行格式化:


public function build()

{

    return $this->from('hello@test.it')

     ->view('view')

     ->with([

       'text' => str_replace('{{ $url }}','https://google.com',$this->parameters->text)

      ]);

 }


查看完整回答
反對 回復 2021-11-05
?
LEATH

TA貢獻1936條經(jīng)驗 獲得超7個贊

我沒有自己嘗試,但您可以嘗試使用Blade::compileString(),即:


public function build()

{

    return $this->from('hello@test.it')

      ->view('view')

      ->with([

        'url'     => 'https://google.com',

        'text' => \Blade::compileString($this->parameters->text),

    ]);

}


查看完整回答
反對 回復 2021-11-05
  • 2 回答
  • 0 關注
  • 171 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號