当我观看 youtube Laravel From Scratch [第 6 部分] - 使用 Eloquent 获取数据时,我看到他在不使用 if 语句和 foreach 的情况下传递数据以查看,我已经尝试过但没有工作
public function show(todo $todo)
{
$todo=todo::find($todo);
return view('demo')->with('todo',$todo);
}
我的观点没有 if 语句和 foreach
@extends('layouts.app')
@section('content')
{{$todo->note}}
@endsection
我在使用 if 语句和 foreach 时的看法
@extends('layouts.app')
@section('content')
@if (count($todo) > 0)
@foreach ($todo as $item)
{{$item->note}}
@endforeach
@endif
@endsection
我收到一个错误
Property [note] does not exist on this collection instance
https://www.youtube.com/watch?v=emyIlJPxZr4&list=PLillGF-RfqbYhQsN5WMXy6VsDMKGadrJ-&index=6
慕的地6264312
智慧大石