title: Laravel customer API resource with relationships
body: <blockquote>
    <p>Controller function:</p>
  </blockquote>
  
  <pre><code>public function index () {
      // TESTED
      // The getAllActiveSuppliers() function just return Supplier::pagniate(10)
      $suppliers = $this -&gt; model -&gt; getAllActiveSuppliers();
      return new SupplierResource($suppliers);
  }
  </code></pre>
  
  <blockquote>
    <p>Returned Json:</p>
  </blockquote>
  
  <pre><code>    {
      "current_page": 1,
      "data": [
          {
              "id": 23,
              "name": "Test Name",
              "description": "Test Description",
              "created_by": {
                  "id": 1,
                  "name": "Test 1",
                  "email": "admin@admin.com",
                  "email_verified_at": null,
                  "active": 1,
                  "created_at": "2018-10-12 14:17:38",
                  "updated_at": "2018-10-12 14:17:38"
              },
              "updated_by": {
                  "id": 1,
                  "name": "Test 1",
                  "email": "admin@admin.com",
                  "email_verified_at": null,
                  "active": 1,
                  "created_at": "2018-10-12 14:17:38",
                  "updated_at": "2018-10-12 14:17:38"
              },
              "deleted_at": null,
              "created_at": "2018-10-31 01:46:11",
              "updated_at": "2018-11-02 22:05:14",
  
          }
      ],
      ...
  }
  </code></pre>
  
  <blockquote>
    <p>What I am trying to do:</p>
  </blockquote>
  
  <p>In the <strong>created_by and updated_by</strong> I just want to show <code>name, email</code> nothing else.</p>
  
  <blockquote>
    <p>What I have tried to do:</p>
  </blockquote>
  
  <p>I have tried to create an API resource collection</p>
  
  <p><strong>Supplier.php API Resource Collection :</strong></p>
  
  <pre><code>public function toArray($request)
  {
      return parent::toArray($request);
  }
  </code></pre>