Laravel 5.5文件目录由数据库数据组成

时间:2018-01-15 03:06:45

标签: laravel

这是我的控制器

$directory = config('app.filesDestinationPath').'/'.'a'.'/'.'b'.'/'.'c'.'/';

它不能正常工作。我认为它不需要$ project->部门和用户并在。

创建
$project = Project::find($project->id);
$diviz = Project::find($project->division);
$user = Project::find($project->user);
$create = Project::find($project->created_at);
$comments = $project->comments;
$directory = config('app.filesDestinationPath').'/'.$diviz.'/'.$user.'/'.$create.'/';
$files = Storage::files($directory);
return view('projects.show', ['project'=>$project, 'comments'=> $comments ])->with(array('files' => $files));

这是我的模特

protected $fillable = [
    'description',
    'division',
    'who',
    'whom',
    'content',
    'user',
    'filename'
];

这是我的迁移

Schema::create('projects', function (Blueprint $table) {
        $table->increments('id');
        $table->string('description')->nullable();
        $table->string('division')->nullable();
        $table->string('who')->nullable();
        $table->string('whom')->nullable();
        $table->string('content')->nullable();
        $table->text('user');
        $table->text('filename');
        $table->timestamps();
    });

1 个答案:

答案 0 :(得分:0)

如果你的问题与这行代码有关

$directory = config('app.filesDestinationPath').'/'.$diviz.'/'.$user.'/'.$create.'/';
然后你用错了。 $ diviz,$ user,$ create是 Model Class ,你试图将这些类与一个字符串连接起来,这会产生不同的输出。

相关问题