gpt4 book ai didi

php - Laravel - 意外的 ':' 期待 '('

转载 作者:行者123 更新时间:2023-11-29 04:05:46 30 4
gpt4 key购买 nike

今天我正在尝试检查计数以确保在未找到任何内容时我可以显示友好的消息,但我一直从 Laravel 收到此错误?

Parse error: syntax error, unexpected ':', expecting '(' (View: C:\Users\User\workspace\websites\website\resources\views\frontend\community\government.blade.php)

当我添加时发生:

 @if ($governmentRole->stats->count() < 1)

一旦我删除了 if 语句,它就可以正常工作。

这是 government.blade.php 中的 foreach:

<div class="panel panel-info">
<div class="panel panel-body">
@if ($juniorGovernment->count() < 1)
We couldn't find any government roles for this category.
@else
@foreach($juniorGovernment as $governmentRole)
@if ($governmentRole->stats->count() < 1)
There are currently no candigates working in this category.
@elseif
@foreach($governmentRole->stats as $governmentMember)
<div class="col-md-10">
<div class="col-md-12" style="margin-left:-40px;">
<div class="col-md-1" style="margin-top:-16px;"><img src="http://mywebsite.com/avatar.php?figure=ch-3030-92.hr-681-34.hd-209-8.lg-3116-106-1408&size=b&direction=3&head_direction=3"></div>
<div class="col-md-9" style="margin-left:40px;">
<h4>{{ $governmentMember->user->username }} <small>{{ $governmentRole->government_title }}</small></h4>
<p><font color="#aaa">{{ $governmentRole->government_department }}</font></p><br>
</div>
</div>
</div>
@endforeach
@endif
@endforeach
@endif
</div>
</div>

Government.blade.php Controller :

<?php

namespace App\Http\Controllers\Frontend\User;

use Auth;
use Cache;
use Illuminate\Http\Request;
use App\Database\Website\User\Roleplay;
use App\Database\Website\Roleplay\GovernmentRole;
use App\Database\Website\Roleplay\Life\LifeEvents;

class GovernmentController
{
public function getView()
{
$royalty = GovernmentRole::where('government_type', 'royalty');

$higherGovernment = GovernmentRole::where('government_type', 'higher_government')->get();

$seniorGovernment = GovernmentRole::where('government_type', 'senior_ministers')->get();

$juniorGovernment = GovernmentRole::where('government_type', 'junior_ministers')->get();

return view('frontend.community.government', compact('juniorGovernment', 'seniorGovernment', 'higherGovernment', 'royalty'));
}
}

最佳答案

@elseif should contain conditional , 但你的是空的。

关于php - Laravel - 意外的 ':' 期待 '(',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41532144/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com