我有这个用例。
跨页中的默认文本,用于整个页面。使用 jQuery 将文本从“占位符”更改为“特定情况”
IE,
在 html 中我想这样做:(twig / html & js)
{% block content %}
{% set location = '<span id="location">Somewhere</span>' %}
<p>Hey, hows the weather in {{ location | raw }}?</p>
<script>
var location = detectLocation();
update $(#location).html('location');
<script>
Run Code Online (Sandbox Code Playgroud)
运行所需的输出预脚本:
嘿,某处的天气怎么样?
运行所需的输出后脚本(假设它输出澳大利亚):
嘿,澳大利亚的天气怎么样?
..但是由于树枝剥离空间,我得到了什么:
嘿,某处的天气怎么样?
简介:我无法在whereHas函数(如下)中访问$ domain变量;Laravel返回以下错误:
“未定义的变量:域”
我之所以加入我的人际关系,是因为我不确定雄辩的性质以及我如何尝试调用此查询是否会引起问题。
我有一个称为模型(Org)的中间件
组织模型有字段
子域
组织模型有
public function domains()
{
return $this->hasMany('App\Domain');
}
Run Code Online (Sandbox Code Playgroud)
域模型(表名域)具有字段
域,org_id
也有功能
public function org()
{
return $this->belongsTo('App\Org');
}
Run Code Online (Sandbox Code Playgroud)
我可以dd($domain); 在此功能之前没有任何问题。但是,我正在
“未定义的变量:域”
下面的whereHas函数中的查询参数。
laravel为什么看不到上面设置的变量?
namespace App\Http\Middleware;
use Closure;
class DomainLookup
{
protected $org;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$route = $request->route();
$domain = $route->parameter('domain');
$trimmed_domain = trim($domain, (config('app.domain')));
$this->org = \App\Org::where('subdomain',$trimmed_domain) …Run Code Online (Sandbox Code Playgroud)