/** * @return \Illuminate\Support\Collection */ private function resetIndexes() { $storagePath = str_finish(realpath(storage_path()), DIRECTORY_SEPARATOR) . '*.index'; return collect(\File::glob($storagePath))->each(function ($index) { unlink($index); }); }
public function viewProduct($id) { $product = Product::find($id); $files = File::glob(public_path() . '/product_images/product_' . $product->id . '_*.jpg', GLOB_MARK); $imagesNames = array(); $imageNames = []; foreach ($files as $file) { $imageFile = explode('product_images/', $file); $imageNames[] = $imageFile[1]; } if ($product->users()->count() > 0) { $highest_bid = $product->users()->max('bid'); } else { $highest_bid = $product->start_price; } return View::make('products/view-product', array('product' => $product, 'files' => $imageNames, 'highest_bid' => $highest_bid)); }
/** * Setup runs before each individual test */ public function setUp() { parent::setUp(); // Set test name in globals $GLOBALS['PHPUNIT_TEST'] = $this->getName(); // Set skip magma permission //$GLOBALS['MAGMA_SKIP_ACCESS'] = true; $models = []; $files = File::glob(app_path() . '/models/*.php'); foreach ($files as $file) { $class = basename($file, '.php'); // Reset event listeners and re-register them call_user_func(array($class, 'flushEventListeners')); call_user_func(array($class, 'boot')); } // Migrate the database Artisan::call('migrate'); // Set the mailer to pretend Mail::pretend(true); }
public function testWithoutMocks() { GCCompiler::cleanup(); $first = \File::glob(GCCompiler::storagePath(DIRECTORY_SEPARATOR . '*')); $this->assertEquals(0, count($first)); $gcc = new GCCompiler($this->app['config']); $this->assertTrue($gcc->compile('file1.js')); $second = \File::glob(GCCompiler::storagePath(DIRECTORY_SEPARATOR . '*')); $this->assertEquals(1, count($second)); }
/** * Go find all the custom models in the app * @return array * Models */ public static function getModels() { $files = \File::glob(app_path() . '/models/*.php'); $models = []; foreach ($files as $file) { preg_match('~/([^/]*).php~', $file, $match); $models[] = $match[1]; } return $models; }
public function index() { $updateDirs = File::glob($this->getUpdatesDirPath() . '/update-*', GLOB_ONLYDIR); include $updateDirs[0] . '/update.php'; }
/** * List of available AWstats files * Ordered by (sub)Domain->Year->Month * * @return array */ public function AWlist() { $patterns = $this->aw_path . '*.txt'; $awfiles = \File::glob($patterns); if (sizeof($awfiles) === 0) { return null; } foreach ($awfiles as $awfile) { // remove path $awfile = str_replace($this->aw_path, '', $awfile); // remove extension $awfile = str_replace('.txt', '', $awfile); // split awstats cleared filename $parts = explode('.', $awfile); $partNo = sizeof($parts); // set domain $domain = $partNo === 3 ? $parts[$partNo - 2] . '.' . $parts[$partNo - 1] : $parts[$partNo - 3] . '.' . $parts[$partNo - 2] . '.' . $parts[$partNo - 1]; // set date mmyyyy $file_date = str_replace('awstats', '', $parts[0]); $month = date("F", mktime(0, 0, 0, substr($file_date, 0, 2), 10)); $year = substr($file_date, 2, 4); // fill array !isset($flist[$domain]) ? !isset($flist[$domain][$year]) ? !isset($flist[$domain][$month]) ? $flist[$domain][$year][$month] = $awfile : null : ($flist[$domain][$year][$month] = $awfile) : ($flist[$domain][$year][$month] = $awfile); } return $flist; }
/** * Remove all compiled bundles */ public static function cleanup() { foreach (\File::glob(static::storagePath(DIRECTORY_SEPARATOR . '*')) as $file) { \File::delete($file); } }