title: Data can not be appears, database relation one to one Laravel
body: <blockquote>
  <p>ErrorException<br>
  <strong>Trying to get property 'category_name' of non-object (View: D:\xampp\htdocs\e-catalog\resources\views\backend\pages\gmproducts.blade.php)</strong></p>
  </blockquote>
  <p>This is my blade code below.</p>
  <pre><code>&lt;tbody&gt;
   @foreach($gmproducts as $no =&gt; $gm)
   &lt;tr&gt;
    &lt;td&gt;{{$no+1}}&lt;/td&gt;
    &lt;td&gt;{{$gm-&gt;type}}&lt;/td&gt;
    &lt;td&gt;{{$gm-&gt;gmcategories-&gt;category_name}}&lt;/td&gt;
    &lt;td&gt;{{$gm-&gt;gram}}&lt;/td&gt;
    &lt;td&gt;{{$gm-&gt;carat}}&lt;/td&gt;
    &lt;td&gt;@currency($gm-&gt;price)&lt;/td&gt;
    &lt;td&gt;&lt;a class=&quot;test-popup-link&quot; href=&quot;{{url('p_goldmart/'.$gm-&gt;file)}}&quot;&gt;Preview&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;
     &lt;a href=&quot;/gmproducts/update/{{$gm-&gt;id}}&quot; class=&quot;text-primary&quot;&gt;&lt;i class=&quot;fa fa-edit&quot;&gt;&lt;/i&gt;&lt;/a&gt;
     &lt;a href=&quot;/gmproducts/delete/{{$gm-&gt;id}}&quot; class=&quot;text-danger&quot;&gt;&lt;i class=&quot;fa fa-trash-o&quot;&gt;&lt;/i&gt;&lt;/a&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
   @endforeach
  &lt;/tbody&gt;
  </code></pre>
  <p>This is my model Gmcategories &amp; Gmproducts.</p>
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Gmcategories extends Model
  {
      protected $table = &quot;gmcategories&quot;;
      protected $fillable = ['category_name'];
  
      public function gmproducts()
      {
          return $this-&gt;hasOne('App\Gmproducts');
      }
  }
  </code></pre>
  <br>
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use Illuminate\Database\Eloquent\SoftDeletes;
  
  class Gmproducts extends Model
  {
      use SoftDeletes;
  
      protected $table = &quot;gmproducts&quot;;
      protected $fillable = ['type', 'category_id', 'gram', 'carat', 'price', 'file'];
      protected $dates = ['deleted_at'];
  
      public function gmcategories()
      {
          return $this-&gt;belongsTo('App\Gmcategories');
      }
  }
  </code></pre>
  <p>This is my controller.</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Gmproducts;
  use App\Gmcategories;
  use File;
  
  class GmproductsController extends Controller
  {
      public function index()
      {
          $gmproducts   = Gmproducts::orderBy('id', 'desc')-&gt;get();
          $trash      = Gmproducts::orderBy('deleted_at', 'desc')-&gt;onlyTrashed()-&gt;count();
          return view('backend.pages.gmproducts', compact('gmproducts', 'trash'));
      }
  
      public function create()
      {
          $gmcategories   = Gmcategories::all();
          return view('backend.pages.create', compact('gmcategories'));
      }
  </code></pre>
  <p>Just info, I just rename my model and controller. Does it have any effect? Thanks.</p>