Laravel Fzaninotto Faker Seed文件:[ErrorException] copy():copy()函数的第一个参数不能是目录

时间:2015-04-09 19:14:37

标签: php laravel faker

我想使用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

如何正确构建种子文件,以便能够生成一些虚拟文件?

1 个答案:

答案 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'
]);