Description
i'm having this issue as well, least i think they are related. i have the following model:
class products extends syncableBase
{
protected $with=['attributes'];
public function __construct()
{
}
public function attributes()
{
return $this->belongsToMany('App\attributes',"productattributes","products_id","attribute_id")->withPivot(["isGroup","visibilityFormula"]);
}
}
syncableBase overrides hasMany but not belongsTo and uses cacheable.
if i save an existing object (one acquired via get) there is no problems, if i save a new object without any relationships, no problems, the only problem is when i create a new object, save, sync the ids, and then save again (i don't think the separate saves are part of the issue, but if i don't do the first save it never does the sync, because there is no id for the product)
it seems the save should invalidate the cache, and given there were two saves that should doubly so
relevant part of that:
$itemsArr=[];
$groupsArr=[];
if(isset($input["item_attributes"]))
{
$itemsArr=$input["item_attributes"];
}
if(isset($input["group_attributes"]))
{
$groupsArr=$input["group_attributes"];
}
$ids=$itemsArr+$groupsArr;
$obj->save();//seems laravel can't handle the sync if the object is new and doesn't have a pk, as it doesn't in the case of auto_incrementing primary keys, so i have to save, then it will have a key then i can sync and save again...
$obj->attributes()->sync($ids);
so after doing this, i go to a list of products as follows:
$data = \App\products::orderBy('product_name', 'asc')->limit(100)->get();
and the product i just created isn't in the list, if i clear the cache it shows up, if i save the product i just created again (from the product edit screen) the product will show in the list also, don't let that limit bother you, you there are only 4 products in the database right now.
it's quite perplexing.
i don't THINK i'm using nova, here are my requires:
"require": {
"php": "^7.1.3",
"ckfinder/ckfinder-laravel-package": "v3.4.5.1",
"fideloper/proxy": "^4.0",
"genealabs/laravel-model-caching": "^0.6.1",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"predis/predis": "^1.1",
"watson/rememberable": "^3.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
so my problem MIGHT not be related to his or both of our problems may be unrelated to nova.
Originally posted by @tuseroni in #278 (comment)