我在我的应用程序中使用 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;
}
Run Code Online (Sandbox Code Playgroud)