laravel - FilesystemManager.php 第 121 行中的 InvalidArgumentException : Driver [] is not supported

标签 laravel laravel-backpack

我见过几个线程有这个错误,但没有一个对我来说是正确的解决方法。

当我尝试删除 Laravel Backpack CRUD 表中的条目时出现此错误:

InvalidArgumentException in FilesystemManager.php line 121: Driver [] is not supported.



估计跟我的有关 filesystems.php
'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),
    ],

    'uploads' => [
        'driver' => 'local',
        'root' => public_path('uploads'),
    ],

    ...

    'hero' => [
        'driver' => 'local',
        'root' => storage_path('app/content/img/heroes/'),
    ],

    ...

或者我的 型号
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
use Glide;

class HeroImages extends Model {
use CrudTrait;

protected $primaryKey = 'id';
protected $fillable = [
    'hero_id',
    'image',
    'title',
    'sub_title',
    'link_label',
    'link_value',
    'order',
    'status',
];

protected $table = "hero_images";

/*
* ADMIN: Store image on server
*/
public function setImageAttribute($value)
{
    $attribute_name = "image";
    $disk = "hero";
    $destination_path = "";

    // if the image was erased
    if ($value==null) {
        // delete the image from disk
        \Storage::disk($disk)->delete($this->{$attribute_name});

        // set null in the database column
        $this->attributes[$attribute_name] = null;
    }

    // if a base64 was sent, store it in the db
    if (starts_with($value, 'data:image'))
    {
        // 0. Make the image
        $image = \Image::make($value);
        // 1. Generate a filename.
        $filename = md5($value.time()).'.jpg';
        // 2. Store the image on disk.
        \Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
        // 3. Save the path to the database
        $this->attributes[$attribute_name] = $destination_path.'/'.$filename;
    }
}

/*
* ADMIN: Delete image from database (https://laravel-backpack.readme.io/v3.0/docs/crud-fields#section-image)
*/
public static function boot()
{
    parent::boot();
    static::deleting(function($obj) {
        \Storage::disk('public_folder')->delete($obj->image);
    });
}

}

最佳答案

没关系,我只是在发布代码时看到了错误。在

Storage::disk('public_folder')->delete($obj->image);

public_folder 不是正确的属性,我需要我正在处理的列的磁盘名称。在这种情况下,“英雄”

关于laravel - FilesystemManager.php 第 121 行中的 InvalidArgumentException : Driver [] is not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47061341/

相关文章:

javascript - 使用 foreach 在数据库 laravel javascript 中双重输入每个输入类型文本

charts - Laravel 中的 phpChart

php - Laravel 5 : How to create a custom attribute for a collection, 然后用它排序

php - addClause 始终返回空集合

设置中的 Laravel-Backpack/Settings 表字段

mysql - 使用背包包的 laravel 中表之间的关系

javascript - html 只需单击即可选择多个选项,而无需按 CTRL 按钮

php - 如何在软删除模型上使用资源 Controller 的 show 方法?

laravel - 如何添加数据库中没有的字段?