community-forum
community-forum copied to clipboard
[Bug] Items with a HasMany relationship cannot be deleted in the relationship field
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
Hello @tringuyenduc2903
To test this on my side, are you using MySQL or MariaDB driver?
Thanks.
Hello @tringuyenduc2903
To test this on my side, are you using MySQL or MariaDB driver?
Thanks.
Im using MariaDB
ping @jcastroa87
Hello @tringuyenduc2903
I just test this using these versions
### PHP VERSION:
8.2.24
### PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, hash, iconv, json, mbstring, SPL, session, PDO, pdo_sqlite, standard, posix, random, readline, Reflection, Phar, SimpleXML, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, bcmath, exif, gd, pcntl, pdo_mysql, sodium, zip, xdebug
### LARAVEL VERSION:
11.36.1.0
### BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.45
backpack/generators: v4.0.7
backpack/pro: 2.2.29
backpack/theme-tabler: 1.2.16
Everything look works as expected. Can you try again?
Cheers.