seeInDatabase for JSON columns

Submitted by MrAtiebatie - 7 years ago

When I was testing some code I wanted to check if some variable in a JSON column was updated. I was thinking about a LIKE query but when I digged into Laravel's code I saw the following possibility. After all it was pretty obvious because you can do this with normal queries as well, but I still wanted to share this solution.

// Where `settings` would be a JSON column in the MySQL database
$this->seeInDatabase('posts', [
    'settings->css_filename' => 'filename.css'
]);