lundi 13 avril 2020

how to pass data to a view without using if statement and foreach in blade file?

when I watched youtube Laravel From Scratch [Part 6] - Fetching Data With Eloquent , and I saw him pass data to view without using if statement and foreach, I has been tried but not working

public function show(todo $todo)
{
 $todo=todo::find($todo);
 return view('demo')->with('todo',$todo);
}

my view without if statement and foreach

    @extends('layouts.app')
@section('content')
    
@endsection

my view when using if statement and foreach

@extends('layouts.app')
@section('content')
@if (count($todo) > 0)
    @foreach ($todo as $item)
        
    @endforeach
@endif

@endsection

and I recievied an error

Property [note] does not exist on this collection instance

https://www.youtube.com/watch?v=emyIlJPxZr4&list=PLillGF-RfqbYhQsN5WMXy6VsDMKGadrJ-&index=6



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire