Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-意外的';:';期待';(';_Php_Mysql_Laravel - Fatal编程技术网

Php Laravel-意外的';:';期待';(';

Php Laravel-意外的';:';期待';(';,php,mysql,laravel,Php,Mysql,Laravel,今天我试图检查计数,以确保在没有发现任何东西的情况下可以显示友好消息,但我一直从Laravel收到这个错误 Parse error: syntax error, unexpected ':', expecting '(' (View: C:\Users\User\workspace\websites\website\resources\views\frontend\community\government.blade.php) 当我添加以下内容时发生: @if ($governmentRol

今天我试图检查计数,以确保在没有发现任何东西的情况下可以显示友好消息,但我一直从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($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>

@如果($juniorGovernment->count()<1)
我们找不到此类别的任何政府角色。
@否则
@foreach($juniorGovernment作为$governmentRole)
@如果($governmentRole->stats->count()<1)
目前在这一类别中没有工作的candigates。
@埃尔塞夫
@foreach($governmentRole->stats as$governmentMember)
{{$governmentMember->user->username}{{{$governmentRole->government_title}}
{{$governmentRole->government\u department}


@endforeach @恩迪夫 @endforeach @恩迪夫
Government.blade.php控制器:

<?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'));
    }
}

,但您的是空的。

,但您的是空的。

我认为您的代码需要更新
,如果语句
部分如下:

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

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


希望这对您有用!

我认为您的代码需要更新
if语句
部分,如:

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

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

希望这项工作为你