本文整理汇总了PHP中File::directories方法的典型用法代码示例。如果您正苦于以下问题:PHP File::directories方法的具体用法?PHP File::directories怎么用?PHP File::directories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::directories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
$folderpath = base_path() . '/database/seeds/templates/';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", str_replace('\\', '/', $value));
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$filePath = $folderpath . $latest . '/Masterfile.xlsx';
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$reader->open($filePath);
DB::table('channel_items')->truncate();
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'MKL Mapping') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if ($row[0] != '') {
if ($cnt > 0) {
// dd($row);
if (!ctype_digit(trim($row[4])) || !ctype_digit(trim($row[5])) || !ctype_digit(trim($row[6]))) {
InvalidMapping::create(['premise_code' => trim($row[0]), 'customer_code' => trim($row[1]), 'store_code' => trim($row[2]), 'sku_code' => trim($row[3]), 'ig' => trim($row[4]), 'multiplier' => trim($row[5]), 'minstock' => trim($row[6]), 'type' => 'MKL Mapping', 'remarks' => 'Invalid mapping']);
} else {
$channel = '';
if (trim($row[0]) != '') {
$channel = Channel::where('channel_code', trim($row[0]))->first();
}
$item = Item::where('sku_code', trim($row[3]))->first();
if (!empty($item)) {
$item_type = ItemType::where('type', "MKL")->first();
$osa_tagging = 0;
if (isset($row[7])) {
$osa_tagging = trim($row[7]);
}
$npi_tagging = 0;
if (isset($row[8])) {
$npi_tagging = trim($row[8]);
}
ChannelItem::firstOrCreate(['channel_id' => $channel->id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => $osa_tagging, 'npi_tagged' => $npi_tagging]);
}
}
}
$cnt++;
}
}
}
}
$reader->close();
}
示例2: run
public function run()
{
$folderpath = 'database/seeds/seed_files';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", $value);
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$file_path = $folderpath . "/" . $latest . "/Secondary Display.xlsx";
echo (string) $file_path, "\n";
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('secondary_display_lookups')->truncate();
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$filePath = $file_path;
$reader->open($filePath);
// Accessing the sheet name when reading
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Sheet1') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if ($cnt > 0) {
// dd($row);
$store = Store::where('store_code', trim($row[1]))->first();
$brands = array();
if (!empty($store)) {
$x = 1;
for ($i = 3; $i < 29; $i++) {
if ($row[$i] == "1.0") {
$brands[] = $x;
}
$x++;
}
foreach ($brands as $value) {
SecondaryDisplayLookup::create(['store_id' => $store->id, 'secondary_display_id' => $value]);
}
}
}
$cnt++;
}
} else {
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例3: run
public function run()
{
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
$folderpath = base_path() . '/database/seeds/seed_files/';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", str_replace('\\', '/', $value));
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$filePath = $folderpath . $latest . '/Masterfile.xlsx';
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$reader->open($filePath);
echo 'Seeding ' . $filePath . PHP_EOL;
// DB::table('other_barcodes')->truncate();
Item::where('active', 1)->update(['cleared' => 0]);
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Other Codes') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if (!is_null($row[0]) && trim($row[0]) != '') {
if ($cnt > 0) {
$item = Item::where('sku_code', trim($row[0]))->first();
if (!empty($item)) {
if ($item->cleared == 0) {
OtherBarcode::where('item_id', $item->id)->delete();
$item->cleared = 1;
$item->save();
}
$area = Area::where('area', strtoupper($row[1]))->first();
if (!empty($item) && !empty($area)) {
OtherBarcode::firstOrCreate(['item_id' => $item->id, 'area_id' => $area->id, 'other_barcode' => trim($row[2])]);
}
} else {
// dd($row);
}
}
$cnt++;
}
}
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例4: run
public function run()
{
$folderpath = 'database/seeds/seed_files';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", $value);
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$file_path = $folderpath . "/" . $latest . "/Store SOS.xlsx";
echo (string) $file_path, "\n";
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('store_sos_tags')->truncate();
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$filePath = $file_path;
$reader->open($filePath);
// Accessing the sheet name when reading
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Sheet1') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if (!empty($row[0])) {
// dd($row);
if ($cnt > 0) {
// dd($row);
$store = Store::where('store_code', $row[0])->first();
// dd($store);
$category = FormCategory::where('category', strtoupper($row[2]))->first();
// dd($category);
$sos = SosTagging::where('sos_tag', strtoupper($row[3]))->first();
// dd($sos);
StoreSosTag::insert(array('store_id' => $store->id, 'form_category_id' => $category->id, 'sos_tag_id' => $sos->id));
// echo (string)$row[0], "\n";
}
$cnt++;
}
}
} else {
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例5: run
public function run()
{
$folderpath = 'database/seeds/seed_files';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", $value);
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$file_path = $folderpath . "/" . $latest . "/Secondary Display.xlsx";
echo (string) $file_path, "\n";
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('secondary_displays')->truncate();
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$filePath = $file_path;
$reader->open($filePath);
// Accessing the sheet name when reading
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Sheet2') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if (!is_null($row[0])) {
if ($cnt > 0) {
$category = FormCategory::firstOrCreate(['category' => strtoupper($row[0])]);
$category->secondary_display = 1;
$category->update();
if (!empty($category)) {
SecondaryDisplay::create(array('category_id' => $category->id, 'brand' => $row[1]));
}
}
$cnt++;
}
}
} else {
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例6: run
public function run()
{
$folderpath = 'database/seeds/seed_files';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", $value);
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$file_path = $folderpath . "/" . $latest . "/Sub Form.xlsx";
echo (string) $file_path, "\n";
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('temp_forms')->truncate();
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$filePath = $file_path;
$reader->open($filePath);
// Accessing the sheet name when reading
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Sheet1') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if ($cnt > 0) {
if (!is_null($row[2])) {
$prompt = addslashes($row[1]);
DB::statement('INSERT INTO temp_forms (code, prompt, required, type, choices, expected_answer) VALUES ("' . $row[0] . '","' . $prompt . '","' . $row[2] . '","' . $row[3] . '","' . $row[4] . '","' . $row[6] . '");');
}
}
$cnt++;
}
} else {
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例7: run
public function run()
{
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
$folderpath = base_path() . '/database/seeds/seed_files/';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", str_replace('\\', '/', $value));
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$filePath = $folderpath . $latest . '/Masterfile.xlsx';
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$reader->open($filePath);
// DB::table('store_items');
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Assortment Mapping') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if ($row[0] != '') {
if ($cnt > 0) {
if (!ctype_digit(trim($row[4]))) {
InvalidMapping::create(['premise_code' => trim($row[0]), 'customer_code' => trim($row[1]), 'store_code' => trim($row[2]), 'sku_code' => trim($row[3]), 'ig' => trim($row[4]), 'multiplier' => trim($row[5]), 'minstock' => trim($row[6]), 'type' => 'Assortment Mapping', 'remarks' => 'Invalid mapping']);
} else {
$channel = '';
$customer = '';
$store = '';
if (trim($row[0]) != '') {
$channel = Channel::where('channel_code', trim($row[0]))->get();
}
if (trim($row[1]) != '') {
$customer = Customer::where('customer_code', trim($row[1]))->get();
}
if (trim($row[2]) != '') {
$store = Store::where('store_code', trim($row[2]))->first();
}
// dd($store);
$stores = Store::where(function ($query) use($channel) {
if (!empty($channel)) {
$channel_id = [];
foreach ($channel as $value) {
$channel_id[] = $value->id;
}
$query->whereIn('channel_id', $channel_id);
}
})->where(function ($query) use($customer) {
if (!empty($customer)) {
$customer_id = [];
foreach ($customer as $value) {
$customer_id[] = $value->id;
}
$query->whereIn('customer_id', $customer_id);
}
})->where(function ($query) use($store) {
if (!empty($store)) {
$query->where('store', $store->id);
}
})->get();
// dd($stores);
$item = Item::where('sku_code', trim($row[3]))->first();
if (!empty($item)) {
$item_type = ItemType::where('type', "ASSORTMENT")->first();
foreach ($stores as $store) {
$w_mkl = StoreItem::where('store_id', $store->id)->where('item_id', $item->id)->get();
$cw_mkl = ChannelItem::where('channel_id', $store->channel_id)->where('item_id', $item->id)->get();
if (count($w_mkl) == 0) {
StoreItem::firstOrCreate(['store_id' => $store->id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => 0, 'npi_tagged' => 0]);
}
if (count($cw_mkl) == 0) {
ChannelItem::firstOrCreate(['channel_id' => $store->channel_id, 'item_id' => $item->id, 'item_type_id' => $item_type->id, 'ig' => trim($row[4]), 'fso_multiplier' => trim($row[5]), 'min_stock' => trim($row[6]), 'osa_tagged' => 0, 'npi_tagged' => 0]);
}
}
}
}
}
$cnt++;
}
}
}
}
$reader->close();
$hash = UpdateHash::find(1);
if (empty($hash)) {
UpdateHash::create(['hash' => \Hash::make(date('Y-m-d H:i:s'))]);
} else {
$hash->hash = md5(date('Y-m-d H:i:s'));
$hash->update();
}
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例8: run
public function run()
{
$folderpath = 'database/seeds/seed_files';
$folders = File::directories($folderpath);
$latest = '11232015';
foreach ($folders as $value) {
$_dir = explode("/", $value);
$cnt = count($_dir);
$name = $_dir[$cnt - 1];
$latest_date = DateTime::createFromFormat('mdY', $latest);
$now = DateTime::createFromFormat('mdY', $name);
if ($now > $latest_date) {
$latest = $name;
}
}
$file_path = $folderpath . "/" . $latest . "/OSA Target.xlsx";
echo (string) $file_path, "\n";
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('osa_lookups')->truncate();
DB::table('osa_lookup_targets')->truncate();
$reader = ReaderFactory::create(Type::XLSX);
// for XLSX files
$filePath = $file_path;
$reader->open($filePath);
// Accessing the sheet name when reading
foreach ($reader->getSheetIterator() as $sheet) {
if ($sheet->getName() == 'Sheet1') {
$cnt = 0;
foreach ($sheet->getRowIterator() as $row) {
if (!is_null($row[0])) {
if ($cnt > 0) {
// dd($row);
$customer_id = 0;
$customer = Customer::where('customer_code', $row[0])->first();
if (!empty($customer)) {
$customer_id = $customer->id;
}
$region_id = 0;
$region = Region::where('region_code', $row[1])->first();
if (!empty($region)) {
$region_id = $region->id;
}
$distributor_id = 0;
$distributor = Distributor::where('distributor_code', $row[2])->first();
if (!empty($distributor)) {
$distributor_id = $distributor->id;
}
$store_id = 0;
$store = Store::where('store_code', $row[3])->first();
if (!empty($store)) {
$store_id = $store->id;
}
$template_id = 0;
$template = AuditTemplate::where('template_code', $row[4])->first();
if (!empty($template)) {
$template_id = $template->id;
}
$category = FormCategory::where('category', $row[5])->first();
if (!empty($category)) {
$osalookup_id = 0;
$osalookup = OsaLookup::where('customer_id', $customer_id)->where('region_id', $region_id)->where('distributor_id', $distributor_id)->where('store_id', $store_id)->where('template_id', $template_id)->first();
if (empty($osalookup)) {
$osalookup = new OsaLookup();
$osalookup->customer_id = $customer_id;
$osalookup->region_id = $region_id;
$osalookup->distributor_id = $distributor_id;
$osalookup->store_id = $store_id;
$osalookup->template_id = $template_id;
$osalookup->save();
}
$osalookup_id = $osalookup->id;
OsaLookupTarget::create(array('osa_lookup_id' => $osalookup_id, 'category_id' => $category->id, 'target' => $row[8], 'total' => $row[9]));
}
}
$cnt++;
}
}
} else {
}
}
$reader->close();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
Model::reguard();
}
示例9: find
public static function find()
{
self::$dir = app_path() . '/plugins/';
$plugins = array_merge(File::directories(self::$dir), glob(self::$dir . '*.php'));
foreach ($plugins as $key => $val) {
$plugins[$key] = self::_strip($val);
}
return $plugins;
}
示例10: _getLangPacks
private function _getLangPacks()
{
$langFiles = array();
$langs = \File::directories(mkny_lang_path());
foreach ($langs as $lang) {
$langFiles[] = class_basename($lang);
}
return $langFiles;
}
示例11: cleanup
private function cleanup($requestId)
{
$dirs = \File::directories(self::DIR);
foreach ($dirs as $dir) {
if (strpos($dir, $requestId) !== false) {
continue;
}
\File::deleteDirectory($dir);
}
}
示例12: makeupBlocks
function makeupBlocks()
{
$blocks_path = HelperFile::normalizeFilePath(Manager::getPath('blocks'));
if (file_exists($blocks_path)) {
foreach (\File::directories($blocks_path) as $path) {
$path = HelperFile::normalizeFilePath($path);
Manager::block(trim(str_replace($blocks_path, '', $path), '/'));
}
}
}
示例13: copyDirectories
protected function copyDirectories()
{
$directories = \File::directories(base_path());
foreach ($directories as $directory) {
if (!strpos($directory, 'vendor') && !strpos($directory, 'backup')) {
$folder = str_replace(base_path(), '', $directory);
\File::copyDirectory($directory, base_path() . '/backup/' . $this->timestamp . $folder);
}
}
}
示例14: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = base_path('vendor');
$vendor_paths = \File::directories($path);
$path = rtrim(rtrim($path, '\\'), '/');
$this->info('Сканируем установленные пакеты на наличие папок .git и .svn');
$check_directories = [];
foreach ($vendor_paths as $vendor_path) {
$package_paths = File::directories($vendor_path);
foreach ($package_paths as $package_path) {
$check_directories[] = (string) $package_path;
}
}
$progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($check_directories));
$progress->setFormat('debug');
$progress->start();
foreach ($check_directories as $directory) {
$progress->advance();
$is_git = $this->checkGit($directory);
if (!$is_git) {
$this->checkSvn($directory);
}
}
$progress->finish();
$this->info('');
$this->info('Сканирование завершено.');
$table = [];
$separator = ['-', '-', '-', '-'];
if ($this->touched_git) {
$this->info('Имеются изменные файлы GIT: ');
foreach ($this->touched_git as $package_path => $files) {
$package = larasafepath($package_path);
foreach ($files as $file => $type) {
$table[] = ['GIT', $package, larasafepath($file), \Illuminate\Support\Arr::get($this->git_types, $type, $type)];
}
$table[] = $separator;
}
}
if ($this->touched_svn) {
$this->info('Имеются изменные файлы SVN: ');
foreach ($this->touched_svn as $package_path => $files) {
$package = larasafepath($package_path);
foreach ($files as $file => $type) {
$table[] = ['SVN', $package, trim(str_replace($package, '', larasafepath($file)), '/'), \Illuminate\Support\Arr::get($this->svn_types, $type, $type)];
}
$table[] = $separator;
}
}
if ($table) {
unset($table[sizeof($table) - 1]);
$this->info('');
$this->table(['VCS', 'package', 'file', 'type'], $table);
}
}
示例15: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$now = time();
foreach (File::directories('public/uploads') as $dir) {
$dirtime = filemtime($dir);
if ($now - $dirtime > 3600) {
File::deleteDirectory($dir);
$this->info('Directory ' . $dir . ' was deleted');
}
}
}