JSON in Laravel
Laravel Eloquent supports JSON column querying with whereJsonContains() and arrow notation in migrations.
Laravel Eloquent supports JSON column querying with whereJsonContains() and arrow notation in migrations.
// Migration
$table->json('attributes');
// Eloquent queries
Product::whereJsonContains('attributes->tags', 'php')->get();
Product::where('attributes->ram', 16)->get();
// Updating JSON fields
$product->forceFill(['attributes->ram' => 32])->save();
Cast JSON columns as arrays in your model: protected $casts = ["attributes" => "array"].