Laravel-Backpack / community-forum

A workspace to discuss improvement and feature ideas, before they're actually implemented.
28 stars 0 forks source link

[Bug] Items with a HasMany relationship cannot be deleted in the relationship field #932

Open tringuyenduc2903 opened 2 months ago

tringuyenduc2903 commented 2 months ago

Bug report

What I did

In migration file

    Schema::create('lessons', function (Blueprint $table) {
    ...
    $table->foreignId('course_id')
        ->nullable()
        ->constrained()
        ->nullOnDelete()
        ->cascadeOnUpdate();
    ...
    });

In Course model

    use StudyTrait;

    /**
     * @return HasMany
     */
    public function lesson(): HasMany
    {
        return $this->hasMany(Lesson::class);
    }

In CourseCrudController controller

    CRUD::field('lesson')
        ->label(ucfirst(trans('validation.attributes.lesson')))
        ->inline_create(true)
        ->tab(trans('Detail'));

Delete 1 lesson from the course

What I expected to happen

Will be deleted successfully

What happened

Quay phim màn hình từ 13-04-2024 08:08:19.webm

What I've already tried to fix it

Is it a bug in the latest version of Backpack?

After I run backpack composer update backpack/crud the error it still persists

Backpack, Laravel, PHP, DB version

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

### PHP VERSION:
8.3.4

### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, igbinary, imagick, imap, intl, ldap, exif, msgpack, mysqli, pcov, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, swoole, Zend OPcache, xdebug

### LARAVEL VERSION:
11.3.1.0

### BACKPACK PACKAGE VERSIONS:
backpack/activity-log: 2.0.3
backpack/backupmanager: v5.0.2
backpack/basset: 1.3.1
backpack/crud: 6.7.6
backpack/filemanager: 3.0.7
backpack/generators: v4.0.5
backpack/language-switcher: 2.0.0
backpack/logmanager: v5.0.1
backpack/medialibrary-uploaders: 1.2.0
backpack/permissionmanager: 7.2.0
backpack/pro: 2.1.12
backpack/revise-operation: 2.0.0
backpack/theme-tabler: 1.2.8
backpack/translation-manager: 1.0.2
jcastroa87 commented 2 months ago

Hello @tringuyenduc2903

To test this on my side, are you using MySQL or MariaDB driver?

Thanks.

tringuyenduc2903 commented 2 months ago

Hello @tringuyenduc2903

To test this on my side, are you using MySQL or MariaDB driver?

Thanks.

Im using MariaDB

pxpm commented 1 month ago

ping @jcastroa87