title: Attempt to read property "name" on null
body: <p>Category Model</p>
  <pre><code>class Category extends Model
  {
  use HasFactory;
  
  protected $fillable= ['name','number'];
  
   public function news(){
  
      return $this-&gt;hasMany(News::class);
  }
  </code></pre>
  <p>News Model</p>
  <pre><code>class News extends Model
  {
  use HasFactory;
  
  protected $fillable= ['cat_id','title','photo','description','author_id','status'];
  
   public function category(){
          return $this-&gt;belongsTo(Category::class);
      }
  
    public function author(){
    return $this-&gt;belongsTo(Author::class);
      }
  </code></pre>
  <p>Author Model</p>
  <pre><code>class Author extends Model
  {
  use HasFactory;
  
  protected $fillable= ['name','status'];
  
  public function news(){
      return $this-&gt;hasMany(News::class);
  }
  </code></pre>
  <p>There is a relationship between the 3 models. And I want to display category name instead of category_id in <code>news-list.blade.php</code>. I am getting a this error.</p>
  <p>This is my controller function</p>
  <pre><code>  public function news_index(){
      $news= News::with('category')-&gt;get();
      return view('News.list',compact('news'));
  }
  </code></pre>
  <p>This is my blade page. I got an error when I typed <code>$new-&gt;category-&gt;name</code> instead of <code>cat_id</code>.</p>
  <pre><code>@foreach($news as $new)
              &lt;tr&gt;
                  &lt;th scope=&quot;row&quot;&gt;{{$loop-&gt;iteration}}&lt;/th&gt;
                  &lt;td&gt; {{$new-&gt;category-&gt;name}}&lt;/td&gt;
                  &lt;td&gt;  {{$new-&gt;title}}&lt;/td&gt;
                  &lt;td&gt; @if($new-&gt;photo)
                          &lt;a href=&quot;{{url('storage/images/'.$new-&gt;photo)}}&quot; target=&quot;_blank&quot; class=&quot;btn btn-sm btn-secondary&quot;&gt;Görüntüle&lt;/a&gt;&lt;/td&gt;
                  @endif
                  &lt;/td&gt;
                  &lt;td&gt;  {{$new-&gt;author_id}}&lt;/td&gt;
                  &lt;td&gt;  {{$new-&gt;description}}&lt;/td&gt;
                  &lt;td&gt;  {{$new-&gt;status}}&lt;/td&gt;
  
                  &lt;td&gt;
                      &lt;a class=&quot;btn btn-danger&quot; onclick=&quot;return confirm('Silmek istediğinize emin 
         misiniz?')&quot; href=&quot;{{route('news_delete', $new-&gt;id)}}&quot;&gt;&lt;i class=&quot;fa fa-trash&quot;&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;a class=&quot;btn btn-primary&quot; href=&quot;{{route('news_update',$new-&gt;id)}}&quot;&gt;&lt;i class=&quot;fa 
        fa-pen&quot;&gt;&lt;/i&gt;&lt;/a&gt;
  
                  &lt;/td&gt;
              &lt;/tr&gt;
          @endforeach
   
  </code></pre>
  <p>Here is my news migration table</p>
  <pre><code>public function up()
      {
          Schema::create('news', function (Blueprint $table) {
              $table-&gt;id();
              $table-&gt;unsignedBigInteger('cat_id');
              $table-&gt;string('title');
              $table-&gt;string('photo');
              $table-&gt;longText('description');
              $table-&gt;unsignedBigInteger('author_id');
              $table-&gt;boolean('status')-&gt;default('1');
  $table-&gt;foreign('cat_id')-&gt;references('id')-&gt;on('categories')-&gt;onDelete('cascade');
              $table-&gt;foreign('author_id')-&gt;references('id')-&gt;on('authors')-&gt;onDelete('cascade');
              $table-&gt;timestamps();
          });
      }
  </code></pre>