如果created_time超过一年,Laravel 5.4将显示另一个按钮续订

时间:2017-08-14 08:47:37

标签: php laravel laravel-5 laravel-5.4

我是laravel的新手,我希望在用户应用程序已经超过一年时传递数据以显示用于续订应用程序的新按钮。但如果申请时间不超过一年,则不会显示续订按钮。我尝试在数据表中使用刀片@if else语句,但是当我尝试使用刀片使用@if else语句时它没有显示信息,它说:

  

DataTables警告:table id = dataTableBuilder - Ajax错误。更多   有关此错误的信息,请参阅http://datatables.net/tn/7

这是我

中的代码

datatables_actions.blade.php

{!! Form::open(['route' => ['applicant.applications.destroy', $application_number], 'method' => 'delete']) !!}
<div class='btn-group'>
    <a href="{{ route('applicant.applications.show', $application_number) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-eye-open"></i>
    </a>
    @if ($application->created_at->gt(\Carbon\Carbon::now()->addYear()))
        <a href="{{ route('applicant.applications.renew', $application_number) }}" class="btn btn-primary btn-xs">
        </a>
    @endif
   <!--  <a href="{{ route('applicant.applications.edit', $application_number) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-edit"></i>
    </a> -->
   <!--  {!! Form::button('<i class="glyphicon glyphicon-trash"></i>', [
        'type' => 'submit',
        'class' => 'btn btn-danger btn-xs',
        'onclick' => "return confirm('Are you sure?')"
    ]) !!} -->
</div>
{!! Form::close() !!}

1 个答案:

答案 0 :(得分:0)

您缺少</a>结束标记

尝试不同的比较:

{!! Form::open(['route' => ['applicant.applications.destroy', $application_number], 'method' => 'delete']) !!}
<div class='btn-group'>
    <a href="{{ route('applicant.applications.show', $application_number) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-eye-open"></i>
    </a>
    @if ($application->created_at->diffInYears(\Carbon\Carbon::now())>=1)
        <a href="{{ route('applicant.applications.renew', $application_number) }}" class="btn btn-primary btn-xs"></a>
        </a>
    @endif
   <!--  <a href="{{ route('applicant.applications.edit', $application_number) }}" class='btn btn-default btn-xs'>
        <i class="glyphicon glyphicon-edit"></i>
    </a> -->
   <!--  {!! Form::button('<i class="glyphicon glyphicon-trash"></i>', [
        'type' => 'submit',
        'class' => 'btn btn-danger btn-xs',
        'onclick' => "return confirm('Are you sure?')"
    ]) !!} -->
</div>
{!! Form::close() !!}