laravel Json包含在laravel审核中

时间:2019-03-14 06:31:38

标签: json laravel laravel-auditing

auditable_id=2239的新值列中,new_values{"video_status_ids":"[4,10]"},我得到了

的正确数据

修补匠

App\Video::find(2239)->audits()->get()

收藏包含

OwenIt\Auditing\Models\Audit {#3140
         id: 322113,
         user_type: "App\User",
         user_id: 3,
         event: "updated",
         auditable_type: "App\Video",
         auditable_id: 2239,
         old_values: "{"video_status_ids":"[4, 8]"}",
         new_values: "{"video_status_ids":"[4,10]"}",
         url: "http://example.com?",
         ip_address: "ipaddr",
         user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.
36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36",
         tags: null,
         created_at: "2019-03-04 13:30:57",
         updated_at: "2019-03-04 13:30:57",
       },

1。App\Video::find(2239)->audits()->whereJsonContains('new_values->video_status_ids', 10)->get()

2。App\Video::find(2239)->audits()->where('new_values->video_status_id', 10)->get()

3。App\Video::find(2239)->audits()->where('new_values->video_status_ids', "[10]")->get()

我得到了

=> Illuminate\Database\Eloquent\Collection {#138
     all: [],
   }

但是我应该得到以上记录。

变通

App\Video::find(2239)->audits()->where('new_values', 'like','\{"video_status_ids"%10%')->get()

App\Video::find(2239)->audits()->where('new_values->video_status_ids', 'like',"%10%")->get();

但是如果有类似101、100之类的值,则将无法使用。仅出于我的要求,就可以了。

0 个答案:

没有答案