Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.17k stars 896 forks source link

[Bug] - ```upload``` column throws error if column is null #5609

Closed susanu closed 3 months ago

susanu commented 3 months ago

Bug report

I have a nullable attribute that stores files into s3.

CRUD::column('file')
    ->type('upload')
    ->disk('s3')
    ->temporary(60)
    ->limit(255);

When displaying the link, it gives the below error if the column is null.

League\Flysystem\PathPrefixer::prefixPath(): Argument #1 ($path) must be of type string, null given, called in /var/www/html/site/vendor/laravel/framework/src/Illuminate/Filesystem/AwsS3V3Adapter.php on line 81

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

### PHP VERSION:
8.2.6

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gettext, json, iconv, SPL, intl, session, mbstring, standard, mysqlnd, pcntl, exif, mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, posix, random, Reflection, imap, SimpleXML, soap, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, igbinary, imagick, redis, Zend OPcache

### LARAVEL VERSION:
10.48.20.0

### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.5
backpack/crud: 6.7.26
backpack/logmanager: v5.0.2
backpack/medialibrary-uploaders: 1.2.0
backpack/permissionmanager: 7.2.1
backpack/pro: 2.1.7
backpack/revise-operation: 2.0.0
backpack/theme-tabler: 1.2.11
susanu commented 3 months ago

Since we are on the topic, the values for this type of column (in my case) are very long in length. Any way we can control the display value for upload column type?

EDIT: Something like this, code before @endphp:

if (isset($column['display_value'])) {
    if ($column['display_value'] instanceof \Closure) {
        $column['display_value'] = $column['display_value']($entry);
    }

    $column['value'] = $column['display_value'];
}