Laravel:FatalErrorException(语法错误,意外' - >')

时间:2017-05-19 02:11:21

标签: php laravel

我在Laravel遇到了问题。有人可以帮忙吗?

以下是代码片段:

public function filterMessages($messages)
{
    $collection = collect(Message::all());

    $keys = [];
    foreach ($messages as $m) {
        $keys[] = $m->id;
    }

    return ($collection->whereNotIn('id', $keys))->all();
}

2 个答案:

答案 0 :(得分:1)

尝试这样做:

public function filterMessages($messages) { 
    $keys = [];
    foreach ($messages as $m) {
        $keys[] = $m->id;
    }

    return Message::whereNotIn('id', $keys)->get();
}

答案 1 :(得分:0)

您已将右括号放在错误的位置

<StackPanel>
    <StackPanel.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Command" Value="{Binding ActionCommand}"/>
            <Setter Property="CommandParameter" Value="{Binding Path=Text}"/>
        </Style>
    </StackPanel.Resources>
    <Button>
        <StackPanel>
            <Image Source="/Resources/ToolBar/open.png"/>
            <TextBlock Text="Open"/>
        </StackPanel>
    </Button>
    <Button>
        <StackPanel>
            <Image Source="/Resources/ToolBar/save.png"/>
            <TextBlock Text="Save"/>
        </StackPanel>
    </Button>
</StackPanel>

会给你一个错误..而且all()函数会全部返回,所以它应该是

public ICommand ActionCommand { get { return new RelayCommand(_onActionCommand); } }

private void _onActionCommand(object parameter)
{
    if (parameter == null)
    {
        return;
    }

    string buttonContent = parameter as string;
    switch (buttonContent)
    {
        case "Open":
            new OpenWindow().ShowDialog();
            break;
        case "Open":
            new Save();
            break;
    }
}