title: Decoding JSON array laravel
body: <p>Hello i am having slight trouble with arrays in my application.  I have a table in my database called "contacts" inside that table i have a column "info" of datatype 'TEXT' where i store a json encoded array.  This is my function:</p>
  
  <pre><code>/**
   * Store a newly created resource in storage.
   *
   * @return Response
   */
  public function store(Request $request)
  {
      $contact = new Contacts;
      $contact-&gt;type = $request-&gt;type;
      $contact-&gt;name = str_replace('  ', ' ', $request-&gt;type == 'person' ? $request-&gt;first_name . ' ' . $request-&gt;other_name . ' ' . $request-&gt;last_name : $request-&gt;description);
      $contact-&gt;email = $request-&gt;email;
      $contact-&gt;info = json_encode($request-&gt;info);
  
      if ($contact-&gt;save())
      {
          return [
              'success' =&gt; 'Data was saved successfully!'
          ];
      }
  }
  </code></pre>
  
  <p>Now this saves perfectly however the issues is when i retrieving the data from the database it returns that column as a "string" and as such i am unable to access that array from my front-end javascript (i use angular).</p>
  
  <p>I have tried decoding the entire returned result but that did not work, still had the same problem:</p>
  
  <pre><code>/**
       * Display a listing of the resource.
       *
       * @return Response
       */
      public function index()
      {
          $type = Input::get('type');
          $contacts = "";
  
          if (empty($type))
          {
              $contacts = Contacts::get();
          }
          elseif ($type == 'persons')
          {
              $contacts = Contacts::where('type', 'person')-&gt;get();
          }
          elseif ($type == 'companies')
          {
              $contacts = Contacts::where('type', 'company')-&gt;get();
          }
  
          return [
              'contacts' =&gt; json_decode($contacts)
          ];
      }
  </code></pre>