我在我的应用程序中使用 laravel spatie。我有个问题。当用户更新他的图像列表时。管理员必须批准用户刚刚更新的图像列表。如果用户添加图像,我只是添加更多。但是,当用户更改他拥有的图像时,该怎么做呢?我无法更改 collection_name,因为如果我更改,此图像不会出现在用户配置文件中。你对我有什么理想吗?我有一个理想:我在 custom_properties 列中添加一个 value {'change' => 'false'}
。当用户更改此图像时,我会将 custom_properties 更改为{'change' => 'true'}
. 当管理员批准更改时,我必须将 custom_properties 更新为{'change' => 'false'}
. 但我无法访问 custom_properties 列的值。(如你所知,laravel spatie 给了我们一个媒体表,它有一个 custom_properties 列,里面有 json 数据)。因此,请帮助我访问此列并更新其中的数据。
很抱歉,因为我的英语不好。
$mediaOld = Media::where(['model_id' => $doctor_id, 'collection_name' => 'doctor_achieved'])->get();
if (isset($mediaOld[$index])) {
$mediaOld[$index]->update(['custom_properties->change' => 'true']);
$mediaOld[$index]->save(); // Its not working
return $mediaOld[$index]->custom_properties;
}