title: How to change the response in API
body: <p>I want to change my response in an API. I get the user object in response but i want there the object of join like that here is the code of my Activity Profile Controller in which I get user object.</p>
  
  <p>Currently i get this response.</p>
  
  <pre><code>"user": {
  
      "id": 1,
  
      "facebook_id": null,
  
      "name": "umar",
  
      "surname": "javed",
  
      "email": "uj1@gmail.com",
  
      "username": null,
  
      "date_of_birth": "1993-01-18",
  
      "profile_picture": null,
  
      "occupation": null,
  
      "gender": null,
  
      "city": "lahore",
  
      "country": null,
  
      "course": null,
  
      "university": null,
  
      "discription": null,
  
      "visible_on_feeds": 1,
  
      "visible_on_guestlists": 1,
  
      "created_at": "2018-05-02 10:35:03",
  
      "updated_at": "2019-01-15 14:32:54"
  
  }
  </code></pre>
  
  <p>public function joinActivity(Activity $activity)</p>
  
  <pre><code>{
  
      $authUser = JWTAuth::parseToken()-&gt;toUser();
  
      $userAge = Carbon::parse($authUser-&gt;date_of_birth)-&gt;age;
  
      if($activity-&gt;age_from &lt;= $userAge &amp;&amp; $activity-&gt;age_to &gt;= $userAge)
      {
          $authUser-&gt;joinActivity($activity, $authUser);
  
          if ($activity-&gt;user_id != $authUser-&gt;id) {
              $user = User::where('id', $activity-&gt;user_id)-&gt;first();
              $user-&gt;notify(new JoinedTheActivity($authUser, $activity));
          }
  
          $userFriendIds = $authUser-&gt;friendslist()-&gt;pluck('id')-&gt;toArray();
          $joinedIds = $activity-&gt;joins()-&gt;pluck('user_id')-&gt;toArray();
  
          $joinedUsers = User::whereIn('id', $joinedIds)-&gt;whereIn('id', $userFriendIds)
              -&gt;where('id', '!=', $authUser-&gt;id)-&gt;get();
  
          foreach ($joinedUsers as $joinedUser) {
              $joinedUser-&gt;notify(new FriendJoinedSameActivity($authUser, $activity));
          }
  
          return response()-&gt;json(['user'=&gt; $authUser], 200);
      } else {
  
          return response()-&gt;json(['message'=&gt; 'Your are not under the age limit of this Activity']);
      }
  }
  </code></pre>
  
  <p>And Here is the code of my ActivityInterest trait:</p>
  
  <p>public function joinActivity(Activity $activity, User $user)</p>
  
  <pre><code>{
  
      if ( $this-&gt;isJoiningActivity($activity, $user))
  
      {
  
          $activity-&gt;interests()-&gt;update(['status'=&gt; Status::JOINED]); 
  
      } else {
  
          $joining = $activity-&gt;interests()-&gt;create([
  
          'user_id' =&gt; $user-&gt;id,
  
          'activity_id' =&gt; $activity-&gt;id,
  
          'status' =&gt; Status::JOINED,
  
          ]); 
  
      return $joining-&gt;save();
  
      }
  
  }
  </code></pre>
  
  <p>But I want this response How i can do that Please help Me. Thanks in advance.</p>
  
  <p>"joins": [</p>
  
  <pre><code>            {
  
                  "id": 71,
  
                  "user_id": 1,
  
                  "activity_id": 7,
  
                  "status": 1,
  
                  "created_at": "2018-12-21 07:05:30",
  
                  "updated_at": "2018-12-21 07:05:30",
  
                  "user": {
  
                      "id": 1,
  
                      "facebook_id": null,
  
                      "name": "umar",
  
                      "surname": "javed",
  
                      "email": "uj1@gmail.com",
  
                      "username": null,
  
                      "date_of_birth": "1993-01-18",
  
                      "profile_picture": null,
  
                      "occupation": null,
  
                      "gender": null,
  
                      "city": "lahore",
  
                      "country": null,
  
                      "course": null,
  
                      "university": null,
  
                      "discription": null,
  
                      "visible_on_feeds": 1,
  
                      "visible_on_guestlists": 1,
  
                      "created_at": "2018-05-02 10:35:03",
  
                      "updated_at": "2019-01-15 14:32:54"
  
                  },
  
                  "activity": {
  
                      "id": 7,
  
                      "activity_type": "event",
  
                      "user_id": 1,
  
                      "category_id": 2,
  
                      "subcategory_id": 3,
  
                      "activity_privacy": "open",
  
                      "activity_privacy_visible": 1,
  
                      "activity_datetime_from": "2018-07-28 13:35:00",
  
                      "activity_datetime_to": "2018-12-12 04:10:12",
  
                      "activity_address": "lahore",
  
                      "company_id": 3,
  
                      "latitude": null,
  
                      "longitude": null,
  
                      "age_from": 16,
  
                      "age_to": 30,
  
                      "people_limit": "4",
  
                      "activity_picture": null,
  
                      "activity_title": "party",
  
                      "activity_description": "party bla bla",
  
                      "created_at": "2018-05-03 10:49:48",
  
                      "updated_at": "2018-09-29 07:57:10",
  
                      "user": {
  
                          "id": 1,
  
                          "facebook_id": null,
  
                          "name": "umar",
  
                          "surname": "javed",
  
                          "email": "uj1@gmail.com",
  
                          "username": null,
  
                          "date_of_birth": "1993-01-18",
  
                          "profile_picture": null,
  
                          "occupation": null,
  
                          "gender": null,
  
                          "city": "lahore",
  
                          "country": null,
  
                          "course": null,
  
                          "university": null,
  
                          "discription": null,
  
                          "visible_on_feeds": 1,
  
                          "visible_on_guestlists": 1,
  
                          "created_at": "2018-05-02 10:35:03",
  
                          "updated_at": "2019-01-15 14:32:54"
  
                      },
  
                      "subcategory": {
  
                          "id": 3,
  
                          "category_id": 2,
  
                          "subcategory_name": "party",
  
                          "subcategory_picture": "dds",
  
                          "created_at": null,
  
                          "updated_at": null,
  
                          "category": {
  
                              "id": 2,
  
                              "category_name": "nightlife",
  
                              "category_picture": "knk",
  
                              "category_color": "#992233",
  
                              "created_at": null,
  
                              "updated_at": "2018-08-09 11:21:23"
  
                          }
  
                      }
  
                  }
  
              }
  
          ] 
  </code></pre>