我有一个表comments,看起来像这样,添加了一些模型内容:
+------------+---------+----------+-------------------+------------------------------------+---------------------------+
| comment_id | user_id | movie_id | comment_parent_id | comment_content | comment_creation_datetime |
+------------+---------+----------+-------------------+------------------------------------+---------------------------+
| 26 | 1 | 16329 | 0 | Första | 2016-01-24 10:42:49 |
| 27 | 1 | 16329 | 26 | Svar till första | 2016-01-24 10:42:55 |
| 28 | 1 | 16329 | 26 | Andra svar till förta | 2016-01-24 10:43:06 |
| 29 | 1 | 16329 | 28 | Svar till "andra svar till första" …Run Code Online (Sandbox Code Playgroud) 我一直在试图弄清楚如何if not在 Twig 模板引擎中使用该子句。
根据文件:
您还可以使用not来检查计算结果为false的值:
所以我尝试像这样使用它:
{% if not signed_in %}
You are not signed in.
{% endif %}
Run Code Online (Sandbox Code Playgroud)
并且signed_in来自中间件。看起来像这样:
if (!$this->container->auth->check()) {
/* Render a Sign-up */
return $this->container->view->render($response, 'subscriber/index.twig', ['signed_in' => false]);
}
Run Code Online (Sandbox Code Playgroud)
因此,如果我{{ dump(signed_in) }}未登录,它就会返回false. 但是当我登录时,singed_in返回null.
我当前正在使用的解决方案是{% if signed_in is defined %},但这实际上不是我正在寻找的,或者是吗?
所以我有一个约会,可以这么说720402。格式为年(72)月(04)日(02)。我希望能够从这个带有碳的字符串中输出年龄。而Carbon有这个年龄函数
$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;但我无法将当前格式转换为正确的格式以供碳使用。
我有一个部分菜单,包括一个输入搜索栏.但我不希望搜索栏在所有页面上都是visibel,只有两个特定的uri.有没有办法删除刀片中包含的内容?
目前它看起来像这样:
<a href="{{ route('all') }}">all</a>
<a href="{{ route('nes') }}">nes</a>
<a href="{{ route('snes') }}">snes</a>
@include('partials._search')
Run Code Online (Sandbox Code Playgroud)
我在想类似的东西
<a href="{{ route('all') }}">all</a>
<a href="{{ route('nes') }}">nes</a>
<a href="{{ route('snes') }}">snes</a>
@if($url)
@include('partials._search')
@endif
Run Code Online (Sandbox Code Playgroud)