laravel eloquent json field array code example
Example 1: laravel where json array column
->whereJsonContains('user_id', 3)
Example 2: laravel eloquent json type
<?php
//Array & JSON Casting
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'options' => 'array',
];
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'options' => 'array',
];
}