Laravel 8 过滤属性
你可以使用 filter 方法过滤属性。如果你想在属性包中保留属性,这个方法接受一个应该返回 true 的闭包:
{{ $attributes->filter(fn ($value, $key) => $key == 'foo') }}为了方便,你也可以使用 whereStartsWith 方法来检索所有以特定字符串开头的键所对应的属性:
{{ $attributes->whereStartsWith('wire:model') }}使用 first 方法,你可以渲染一个属性包中的第一个属性:
{{ $attributes->whereStartsWith('wire:model')->first() }}