Browse Source

Merge pull request #1356 from helmut/patch-1

Update laravel/file.php
Taylor Otwell 12 years ago
parent
commit
205cc4869d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      laravel/file.php

+ 7 - 1
laravel/file.php

@@ -331,6 +331,8 @@ class File {
 	 */
 	 */
 	public static function latest($directory, $options = fIterator::SKIP_DOTS)
 	public static function latest($directory, $options = fIterator::SKIP_DOTS)
 	{
 	{
+		$latest = null;
+
 		$time = 0;
 		$time = 0;
 
 
 		$items = new fIterator($directory, $options);
 		$items = new fIterator($directory, $options);
@@ -340,7 +342,11 @@ class File {
 		// with a UNIX timestamp greater than the latest one.
 		// with a UNIX timestamp greater than the latest one.
 		foreach ($items as $item)
 		foreach ($items as $item)
 		{
 		{
-			if ($item->getMTime() > $time) $latest = $item;
+			if ($item->getMTime() > $time) 
+			{
+				$latest = $item;
+				$time = $item->getMTime();
+			}
 		}
 		}
 
 
 		return $latest;
 		return $latest;