You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first thing is that I can't tell it to log ['colors.id'] which I would like to, I then get an error saying id attribute does not exist on collection. But also the old colors array and the attribute colors array are always the same. And I found that if I sync the colors first the arrays will have the new value, and if I save the item before syncing the colors it will have the old value
$item->save(); // in this log the arrays are both the old colors$item->colors()->sync($request->input('colors'));
$item->save(); // in this log the arrays are both the new colors
To Reproduce
Schema::create('items', function (Blueprint$table) {
$table->id();
$table->string('name')->nullable();
$table->softDeletes();
$table->timestamps();
});
Schema::create('colors', function (Blueprint$table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->string('hex_code');
$table->timestamps();
});
Schema::create('item_color', function (Blueprint$table) {
$table->foreignIdFor(Item::class)->constrained('items')->onUpdate('cascade')->onDelete('cascade');
$table->foreignIdFor(Color::class)->constrained('colors')->onUpdate('cascade')->onDelete('cascade');
$table->primary(['item_id', 'color_id']);
});
Expected behavior
First off I would expect the arrays to be different, but I would also like to be able to specify what attribute of the related model I would like to be in the array
Versions (please complete the following information)
PHP: 8.3
Database: mysql8
Laravel: 11.19.0
Package: 4.8.0
The text was updated successfully, but these errors were encountered:
Describe the bug
Basically the same as #1081 but that got closed, so thought I'd create a new one.
We have an
Item
class that has a many-to-many relationship toColor
through the colors():And then our
getActivitylogOptions
is set up as following:The first thing is that I can't tell it to log
['colors.id']
which I would like to, I then get an error sayingid
attribute does not exist on collection. But also theold
colors array and theattribute
colors array are always the same. And I found that if I sync the colors first the arrays will have the new value, and if I save the item before syncing the colors it will have the old valueTo Reproduce
Expected behavior
First off I would expect the arrays to be different, but I would also like to be able to specify what attribute of the related model I would like to be in the array
Versions (please complete the following information)
The text was updated successfully, but these errors were encountered: