Laravel комментарии к посту

Пытаюсь с помощью Laravel добавить комментарии к статье, но почему-то не выходит ничего и получается ошибка ErrorException

Illegal string offset 'articles' (View: W:\domains\localhost\resources\views\articles\show.blade.php)

Проблему самостоятельно так и не удалось найти. Ниже пракладываю код

//Comment controller 

 public function show($id)
   {
       $articles = Articles::find($id);

       $comments = Comment::where('com_id', $id)->get();
       $data = ['articles' => $articles, 'comments' => $comments];
       return view('articles.show')->with('data', $data);
   }



//ArticlesController 


  if($request->input('com_id') > 0) {
                     
                      $comment = new Comment();
                      $comment->com_id = $request->input('com_id');
                      $comment->comment = $request->input('comment');
                      $comment->save();
                      return redirect('/articles/'.$request->input('com_id'))->with('success', 'Комментарий добавлен');
                  }


//show.blade.php


  <h1>Форма комментариев</h1>
    {!! Form::open(['action' => 'ArticlesController@store', 'method' => 'POST']) !!}
    <div class="form-group">
    {{ Form::label('comment', 'Комментарий') }}
    {{ Form::textarea('comment', '', ['class' => 'form-control', 'placeholder' => 'Введите текст']) }}
    </div>
    {{ Form::hidden('com_id', $data ?? ''['articles']->id) }}
    {{ Form::submit('Добавить', ['class' => 'btn btn-success']) }}
    {!! Form::close() !!}



//Comment.php


    public function articles(){
      return $this->belongsTo('App\Models\Articles');
    }


//Articles.php


public function comment(){
      return $this->hasMany('App\Models\Comment');
    }

Ответы (0 шт):