I'm new to laravel and i encountered an array to string conversion error while trying to send tags select form data to sync with my blogs table.
Below is blade snippet that retrieves tags from the database
<div class="form-group">
<label for="tag" class="control-label">Tags</label>
{!! Form::select('tag[]', $tags, old('tag'), ['class' => 'form-control select2', 'multiple' => 'multiple', 'id' => 'add-tag' ]) !!}
</div>
The BlogsController
$blog_data = request()->validate([
'tag.*' => 'required'
]);
blogs = Blog::create( $blog_data );
$blogs->tags()->sync((array)request()->input('tag'));
when i perform a dd on request()->tag
array:2 [▼
0 => "1"
1 => "2"
]