in my posts
table have extra_category
column with saved mutiple value(json) same ["12","15","23"]
now I want use this value in DB query for get category name for each value .
my Controller:
$excatname = DB::table('categories')
->where('id', '=', $post->extra_category)->get();
view()->share('excatname', $excatname);
and my view:
@foreach($excatname as $excatnamez)
{{ $excatnamez->name }}
@endforeach
but get error:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens (SQL: select * from `categories` where `id` = 12)
Note: when extra_categoy
have single value for ex : 15
worked as well.
cast is defined on the model
protected $casts = ['extra_category' => 'array',]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…