Reputation: 9701
In new values column for auditable_id=2239
, new_values
is {"video_status_ids":"[4,10]"}
I am getting correct data for
In tinker
App\Video::find(2239)->audits()->get()
Collection contains
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",
},
but for
1.App\Video::find(2239)->audits()->whereJsonContains('new_values->video_status_ids', 10)->get()
and
2.App\Video::find(2239)->audits()->where('new_values->video_status_id', 10)->get()
and
3.App\Video::find(2239)->audits()->where('new_values->video_status_ids', "[10]")->get()
I am getting
=> Illuminate\Database\Eloquent\Collection {#138
all: [],
}
but I should get the above records.
Work around
App\Video::find(2239)->audits()->where('new_values', 'like','\{"video_status_ids"%10%')->get()
and
App\Video::find(2239)->audits()->where('new_values->video_status_ids', 'like',"%10%")->get();
but if there is something like 101, 100 etc, this will not work. for only my requirement, it will be fine.
Upvotes: 0
Views: 558