在 Blade 中包含 HTML

问题描述

管理员想要删除药物时,我在控制器中编写了此代码

 $msg = 'You are not authorized to delete this drug the drug belongs to,<a href="'. action('UserController@viewStore',$drug->drugStore->id) . '"> {{$drug->drugStore->name}}</a>';
            return redirect()->back()->with('error',$msg);

在另一个 Blade 文件中,我有这个会话警报:

@if(session()->has('error'))
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <strong>Wrong!</strong> {!!session('error')!!}.
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">×</span>
        </button>
    </div>
@endif

href 已成功创建,但我正在尝试添加 {{$drug->drugStore->name}},但一直将其视为纯文本。

正在显示的警报:

错了!您无权删除该药物所属的该药物,{{$drug->drugStore->name}}。

解决方法

PrintDialog printDlg = new PrintDialog(); PrintDocument printDoc = new PrintDocument(); printDoc.DocumentName = "Print Document"; printDlg.Document = printDoc; printDlg.AllowSelection = true; printDlg.AllowSomePages = true; //Call ShowDialog if (printDlg.ShowDialog() == DialogResult.OK) printDoc.Print(); 语法仅用于 Blade 文件。

在您的控制器中,您应该使用标准的 PHP 连接:

{{ $var }}