samedi 25 avril 2020

laravel foreach and if else loop errors both in count and variables something

code of 1st error :

@extends('layouts.app')

@section('content')
<h1> posts</h1>
@if(count($posts)>1)

@foreach($posts as $post)

<div class="well">
    <h3></h3>
</div>
@endforeach

@else
<p> no posts found</p>
@endif
@endsection

and image also attached . [enter image description here][1] after i follow the instructions of the chrome this occurs and code will be .. even i have removed the @ and try if() like this .. code 2 ; @extends('layouts.app')

@section('content')
<h1> posts</h1>
@if(count($posts ?? '')>1)

@foreach($posts ?? '' as $post)

<div class="well">
    <h3></h3>
</div>
@endforeach

@else
<p> no posts found</p>
@endif
@endsection

enter image description here

[1]: https://i.stack.imenter code heregur.com/21weC.png



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire