I have a checkbox with multiple values to be selected. So far I got it working and the data is inserting into the database but it's in this format,
My issue is that I want the data to be in this format ["value1","value2","value3"]. I'm using Laravel and this is the code in my controller:
public function store(NewsRequest $request) //ive removed most of the unnecessary code like the image upload and all to make this clean.
{
$news = new News($request->except('files', 'image'));
$serialize = implode(",", $news->majors); //this is my focus to change the format to ["value1","value2","value3"]
//ready data for insertion
$data = array(
"name" => $news->name,
"article_type_id" => $request->category,
"majors" => $serialize,
"content" => $news->content
);
DB::table('articles')->insert($data); //insert into database
}
Currently I'm only able to insert the data with a comma separating them but I want the data to be inserted like the following:
I tried looking around the internet but I couldn't find anything that could help besides JSON.stringify. I'm hoping to get the format in my controller itself. I'm hoping to get some insight for this. Thank you in advance.


implode('","', $news->majors);and concatenate same quotation marks at beginning and end of the produced string.'['.implode('","', $news->majors).']'json_encode($news->majors)?