I am using laravel and I want to insert an array to a column but it gives me this error I do not why
here is my query
DB::table('cart_product')->insert([
['product_id' => $request->product_id,'quantity' => $request->quantity, 'cart_id' => \Auth::user()->cart()->get()->first()->id, 'color_id' => $request->color, 'total_price' => $productPrice, 'specification' => $request->specification]
, ]);
and here is model
class CartProduct extends Model
{
use SoftDeletes;
protected $guarded = ['id'];
protected $dates = ['deleted_at'];
protected $table = 'cart_product';
protected $casts = ['specification' => 'array'];
}
}
and error is for this
$request->specification
here is a dd of this
array:4 [▼
0 => "4"
1 => "7"
2 => "8"
3 => "9"
]
gives me this error
Array to string conversion