Код: Выделить всё
Route::get('/', function () {
$path = public_path('images\products');
$allfiles = scandir($path);
$allfiles = array_diff(scandir($path), array('.', '..'));
$files = array();
foreach ($allfiles as $filename) {
$file= File::get(public_path('images/products/'.$filename));
$files[] = [
"file_name"=>$filename];
}
// return $filename;
foreach($files as $file){
$exists[] = DB::table('tw_products')
// ->where('image', '=', $file['file_name'])
->where('status', '=', 1)
->get('image', '=', $file['file_name']);
// return $exists;
if($exists[] = 'images/products/'.$file['file_name']){
File::copy('images/products/'.$file['file_name'],'images/ActiveProducts/'.$file['file_name']);
echo "File Moved from (images/products/".$file['file_name'] . ")
";
}
}
});
Я хочу сравнить элементы БД (изображение и статус), если статус изображения = 1 это изображение будет перенесено в другой каталог...
Подробнее здесь: https://stackoverflow.com/questions/735 ... mage-is-1a