我需要使用my laravel刀片文件中的else条件。打印不同的图标。这是我当前的刀片文件
@foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>
<a href="/projects/{{ $project->id }}/tasks/{{ $task->id }}/edit" class="editInline"><i class="glyphicon glyphicon-pencil"></i></a>
<a href="" class="editInline"><i class="glyphicon glyphicon-trash"></i></a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}</a>
</span></h4>
</div>
</li>
</ul>
<hr>
@endforeach
我需要这样一个刀片文件
@if (Auth::user()->id)->exists()) {
@foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}</a>
</span></h4>
</div>
</li>
</ul>
<hr>
@endforeach
else
@foreach ($project->tasks as $task)
<ul>
<li>
<div>
<div class="pull-right icons-align">
<a href="{{url('projects/'.$project->id.'/task/'.$task->id.'/subtask')}}" class="editInline"><i class="glyphicon glyphicon-plus"></i></a>
<a href="/projects/{{ $project->id }}/tasks/{{ $task->id }}/edit" class="editInline"><i class="glyphicon glyphicon-pencil"></i></a>
<a href="" class="editInline"><i class="glyphicon glyphicon-trash"></i></a>
</div>
<h4><i class="fa fa-check-square-o"></i> <span><a href="/projects/{{$project->id}}/tasks/{{ $task->id }}">{{ $task->task_name }}</a>
</span></h4>
</div>
</li>
</ul>
<hr>
@endforeach
我该如何配置?
答案 0 :(得分:1)
我在你的代码中发现的错误很少见
没有using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = @"c:\temp\test.xml";
static void Main(string[] args)
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
XmlReader reader = XmlReader.Create(FILENAME,settings);
while (!reader.EOF)
{
if (reader.Name != "root")
{
reader.ReadToFollowing("root");
}
if (!reader.EOF)
{
XElement root = (XElement)XElement.ReadFrom(reader);
}
}
}
}
}
的{{1}},如果不应该使用else
,则首先使用@
。
你也错过了关闭{
。
这是代码
@endif
答案 1 :(得分:1)
下面显示如何使用laravel blade
语句您可以使用@ if,@ elseif,@ else和@endif指令构造if语句。这些指令的功能与它们的PHP对应程序完全相同:
@if (count($records) === 1)
<p>I have one record!</p>
@elseif (count($records) > 1)
<p>I have multiple records!</p>
@else
<p> I don't have any records! </p>
@endif