Get all images name from folder using link in controller for JSON response laravel 5.1
<p>Database have link of folder and folder contain many images. I want to get all images name but glob() (function) is not working.. </p>

<pre><code>function index($data){
        $users = DB::select('select * from `title` INNER JOIN `title_img` on `title`.title_no = `title_img`.title_no AND `title`.title_name = ?', [$data]);
        $ab = array();
        foreach ($users as $user) {
            $name = $user-&gt;img_folder;
            $nam = 'http://127.0.0.1/shaadi/public/data/'.$name;
            $ab[] = glob($name);
        }
    var_dump($ab);
    var_dump($nam);
        return response()-&gt;json($users);
    }
</code></pre>

<p>output</p>

<pre><code>   &lt;pre class='xdebug-var-dump' dir='ltr'&gt;
&lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=3)&lt;/i&gt;
  0 &lt;font color='#888a85'&gt;=&amp;gt;&lt;/font&gt; 
    &lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=0)&lt;/i&gt;
      &lt;i&gt;&lt;font color='#888a85'&gt;empty&lt;/font&gt;&lt;/i&gt;
  1 &lt;font color='#888a85'&gt;=&amp;gt;&lt;/font&gt; 
    &lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=0)&lt;/i&gt;
      &lt;i&gt;&lt;font color='#888a85'&gt;empty&lt;/font&gt;&lt;/i&gt;
  2 &lt;font color='#888a85'&gt;=&amp;gt;&lt;/font&gt; 
    &lt;b&gt;array&lt;/b&gt; &lt;i&gt;(size=0)&lt;/i&gt;
      &lt;i&gt;&lt;font color='#888a85'&gt;empty&lt;/font&gt;&lt;/i&gt;
&lt;/pre&gt;&lt;pre class='xdebug-var-dump' dir='ltr'&gt;&lt;small&gt;string&lt;/small&gt; &lt;font color='#cc0000'&gt;'http://127.0.0.1/shaadi/public/data/image/caterer/standard/'&lt;/font&gt; &lt;i&gt;(length=59)&lt;/i&gt;
&lt;/pre&gt;[{"title_no":1,"title_name":"Catering","title_description":"Let your taste buds loose!&lt;br\/&gt;We promise delicious high quality and hygienic delicious for you.","img_folder":"image\/caterer\/luxury\/"},{"title_no":1,"title_name":"Catering","title_description":"Let your taste buds loose!&lt;br\/&gt;We promise delicious high quality and hygienic delicious for you.","img_folder":"image\/caterer\/premium\/"},{"title_no":1,"title_name":"Catering","title_description":"Let your taste buds loose!&lt;br\/&gt;We promise delicious high quality and hygienic delicious for you.","img_folder":"image\/caterer\/standard\/"}]
</code></pre>