简体   繁体   English

如何将变量名称链接到活动日志描述中? Laravel 8

[英]How can I link a variable name into activity log description? Laravel 8

<h6 class="mb-0">Collections / {{$establishment->category->name}} / {{ $establishment->name }}</h6>
        @php
        $en = $establishment->name;
            activity()->log( '$en' );
        @endphp

how can I put the establishment name into the activity log description?如何将机构名称放入活动日志描述中?

PHP double quotes vs single quotes PHP双引号与单引号

In double-quoted strings, other escape sequences are interpreted as well any variable will be replaced by their value.在双引号字符串中,其他转义序列也会被解释,任何变量都将被它们的值替换。

$count = 1;
echo "The count is $count";
//Output: The count is 1

If we use single quotes instead of double quotes for the above example it will be like this:如果我们在上面的例子中使用单引号而不是双引号,它将是这样的:

$count = 1;
echo 'The count is $count';
//Output: The count is $count

Only outputting variable:仅输出变量:

$count = 1;
echo $count;
//Output: 1

So remove single quote from ..->log() method :所以从..->log()方法中删除单引号:

$en = $establishment->name;
activity()->log( $en );
    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM