我想使用fzaninotto / faker为我的种子文件创建一些文件。
file($sourceDir = '/tmp', $targetDir = '/tmp') // '/path/to/targetDir/13b73edae8443990be1aa8f1a483bc27.jpg'
file($sourceDir, $targetDir, false) // '13b73edae8443990be1aa8f1a483bc27.jpg'
我的文件种子文件如下所示:
$factory('App\File', [
'order_id' => 'factory:App\Order',
'originalFilename' => $faker->file(public_path('files/uploads'), public_path('files/uploads/tmp'), false),
'filename' => $faker->randomNumber($nbDigits = NULL),
'filepath' => 'files/uploads'
]);
我目前有一个公共文件夹结构,如下所示:
public
-files
-uploads
-tmp <- Here are some dummy files of mine that can be used by fzaninotto fakers dummy creation class
如何正确构建种子文件,以便能够生成一些虚拟文件?
答案 0 :(得分:0)
无意中将源目录作为目标目录。这现在有效:
$factory('App\File', [
'order_id' => 'factory:App\Order',
'originalFilename' => $faker->randomNumber($nbDigits = NULL),
'filename' => $faker->file(public_path('files/uploads/tmp'), public_path('files/uploads'), false),
'filepath' => 'files/uploads'
]);