0
<tbody> 
@if(count($articles) > 0)
 @foreach(@articles->all() as $article)

<tr class="table-active">
  <th ></th>
  <td></td>
  <td></td>
  <td>
      <a herf="{{ url('')}}" ><button class="label label-primary">Read |</button></a>
      <a herf="{{ url('')}}" ><button class="label label-success"> Update |</button></a>
      <a herf="{{ url('')}}" ><button class="label label-danger">Delete |</button></a>
  </td>
</tr>
@endforeach
@endif

Contoller:

class CreatesController extends Controller
{
    public function home()
    {
        $articles =Article::all();
        return view('home',['article'=>$articles]);
    }
}

Getting the following error.

syntax error, unexpected '->' (T_OBJECT_OPERATOR) (View: C:\xampp\htdocs\laravelcrud\resources\views\home.blade.php)

2 Answers 2

1

Return to the view using the following syntax

return view('home', compact('articles'));

and use the following for foreach

@foreach ( $articles as $article ) //your code here @endforeach

Sign up to request clarification or add additional context in comments.

Comments

0

Replace

 @foreach(@articles->all() as $article)

with

 @foreach($articles as $article)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.