小编Dew*_*agg的帖子

Laravel 雄辩地添加到 JSON

首先,抱歉我的英语不好。我有专栏:

$table->json('images')->nullable();
Run Code Online (Sandbox Code Playgroud)

表称为相册。在图像中,我想存储一个包含图像名称的数组,但如何每​​次都添加到该 json 中?我现在的代码:

$album = Album::where('hash', $request->album_hash)->firstOrFail();
$album->update([
    'images' => $request->image->name <= tried to do something.. My uploader everytime calls this function, so I need to get current IMAGES column value, and add new. Like ['first image name', 'second image name'], after update this must be ['first image name', 'second image name', 'third image name'] not just ['third image name']
]);
$album->save();
Run Code Online (Sandbox Code Playgroud)

我需要像 Laravel 增量函数一样,但它只适用于 int 看起来像。我怎样才能做到这一点?提前致谢!

mysql laravel eloquent

4
推荐指数
2
解决办法
9754
查看次数

标签 统计

eloquent ×1

laravel ×1

mysql ×1