title: How to display user name inside product table ? API laravel 8 use eloquent
body: <p>I have 2 tables:</p>
  <p>Table <code>User</code>:</p>
  <p><a href="https://i.stack.imgur.com/pRseS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pRseS.jpg" alt="table user" /></a></p>
  <p>Table <code>Product</code>:</p>
  <p><a href="https://i.stack.imgur.com/RL8Hc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RL8Hc.jpg" alt="table product" /></a></p>
  <p>And I have the model relationship:</p>
  <p><code>User</code> model:</p>
  <pre><code>public function product() { 
      return $this-&gt;hasMany(Product::class); 
  }
  </code></pre>
  <p><code>Product</code> model:</p>
  <pre><code>protected $fillable = [
      'user_id',
      'nama',
      'harga',
      'deskripsi',
      'kategori_id',
      'gambar',
  ];
  
  public function user()
  {
      return $this-&gt;belongsTo(User::class);
  }
  </code></pre>
  <p>This is my controller:</p>
  <pre><code>class GetProductController extends Controller
  {
      public function index() {
          $product = Product::with(['user'])-&gt;get();
  
          if($product) {
              return response()-&gt;json([
                  'success' =&gt; 1,
                  'message' =&gt; 'success get  data',
                  'products' =&gt; collect($product)
              ]);
          } else {
              return response()-&gt;json([
                  'success' =&gt; 0,
                  'message' =&gt; 'failed get data'
              ]);
          }
      }
  }
  </code></pre>
  <p>This is my route Api :</p>
  <pre><code>Route::get('getproduct', [GetProductController::class, 'index']);
  </code></pre>
  <p>I want use the API for mobile app.. not Api web..</p>
  <p>The question is: how to display only column <code>name</code> in table user inside table product?</p>
  <p>The output I got is :</p>
  <p><a href="https://i.stack.imgur.com/Tk2Fo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tk2Fo.jpg" alt="the problem" /></a></p>
  <p>What should I change in my controller? Thanks in advance... :) I am new in laravel</p>