title: Foreach not working in controller in Laravel
body: <p>I want to export to excel datas from my table. So that i need to use foreach loop to get all the datas to form excel.</p>
  
  <p>But foreach is not working in my controller but its working in view when i pass the variable and loop it.</p>
  
  <p>My controller is: </p>
  
  <pre><code>$getAppProcess = ApplicationProcess::with('partner')-&gt;with('admin');
      $search = $request-&gt;q;
      if(isset($search)) {
          $getAppProcess-&gt;where(function ($query) use ($search){
              $query-&gt;where("application_id", "LIKE","%$search%")
              -&gt;orWhere("applicant_name", "LIKE", "%$search%")
              -&gt;orWhere("pan", "LIKE", "%$search%")
              -&gt;orWhere("mobile", "LIKE", "%$search%");
          });
      }
      $getAppProcess-&gt;orderBy('id', 'DESC')-&gt;get();
  
      foreach ($getAppProcess as $value) {
          echo $value-&gt;pan;
      }
  </code></pre>