I'm new on Laravel and some little trick escape me.
i have a controller where i need to list pictures in a public folder ( ex: public/images/album/Ecosse), but i don't known how to acceed it. i have always the no directory error. Can you explain me how it's working ?
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Repositories\AlbumsRepository;
use File;
class AlbumController extends Controller
{
protected $albumsRepository;
public function __construct(AlbumsRepository $albumsRepository)
{
$this->albumsRepository = $albumsRepository;
}
public function show($n)
{
$album = $this->albumsRepository->getById($n);
$files1 = File::allFiles(asset('images/albums/'.$album->titre));
foreach ($files1 as $key => $value)
{
if (!in_array($value,array(".","..")))
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
else
{
$result[] = $value;
}
}
}
return view('album')->with('album', $album);
}
}
Thank for your help. Maxime