Loop data into json?
<p>I wanna loop  every appointment and put it in json like this :</p>

<pre><code>[
   {
      "id":"1",
      "title":"Test 1",
      "start":"2016-09-16 12:00:00",
      "end":"2016-09-16 14:00:00",
      "allDay":false
   },

   {
       "id":"2",
       "title":"Test 2",
       "start":"2016-09-15 12:00:00",
       "end":"2016-09-15 14:00:00",
       "allDay":false
   }
]   
</code></pre>

<p>I have a table <code>appointments</code> in the database.</p>

<pre><code>id | title  | appointment_date_start | appointment_date_end |
-------------------------------------------------------------
1  | Test 1 | 2016-09-16 12:00:00    | 2016-09-16 14:00:00  |
2  | Test 2 | 2016-09-15 12:00:00    | 2016-09-15 14:00:00  |
</code></pre>

<p>In my <code>feed.blade.php</code> I get all the data.
So i can do:</p>

<pre><code>@foreach ($appointments as $appointments)

    {{ $appointment-&gt;id }}
    {{ $appointment-&gt;title }}
    {{ $appointment-&gt;appointment_date_start }}
    {{ $appointment-&gt;appointment_date_end }}

@endforeach
</code></pre>

<p>This outputs the data from the database. But how do I foreach it in a array?</p>

<p>Like</p>

<pre><code>$event_array[] = array(
    'id' =&gt; {{ $appointment-&gt;id }},
    'title' =&gt; {{ $appointment-&gt;gender }},
    'start' =&gt; {{ $appointment-&gt;appointment_date_start }},
    'end' =&gt; {{ $appointment-&gt;appointment_date_end }},
    'allDay' =&gt; false
);
</code></pre>

<p><strong>Edit</strong></p>

<p>I tried this in my public function</p>

<pre><code>public function feed()
{   
    $feed = Appointment::all();
    return $feed-&gt;toJson();
    return view('appointments/feed');
}
</code></pre>

<p>This is what I get </p>

<pre><code>{
    id: 35,
    user_id: 1,
    gender: "men",
    appointment_date_start: "2016-09-14 20:00:00",
    appointment_date_end: "2016-09-14 20:40:00",
    created_at: "2016-09-16 08:16:16",
    updated_at: "2016-09-16 08:16:16"
}
</code></pre>

<p>I need to remove <code>gender, created_at and updated_at</code> and appointment_date_start should be start and appointment_date_end should be end? Is this possible?</p>