I have a laravel5.7 function that save data in database, it have 1 longtext field, and that saves the data to database very well. Now i have created a new table with the name of history, it is almost the copy of other table with a text field with type longtext. The issue is that main table stores the longtext properly and have no issue. But when i try to save same data to history table, it truncate the dat`a.
Note I have copy pasted the same data using mysql, to history table manually. it works fine.
I have enable debug query log and have seen that it even truncated when it creates the object before save.
$selectedModel = MxModel::where('id', $request['model_id']);
$selectedModel = $selectedModel->first();
$selectedModel->contents_xml = $request['contents_xml']; ////longtext inside
$selectedModel->name = $request['name'];
$selectedModel->save();
the above work fine. but in same function i have historyTable save
$newRow =MxModelHistory::Create([
'model_id' => $selectedModel->id,
'name' => $selectedModel->name,
'contents_xml' => $selectedModel->contents_xml, /// longtext
'map_table_id' => $selectedModel->map_table_id,
'table_id' => $selectedModel->table_id,
'user_id' => $selectedModel->user_id,
'is_show' => $selectedModel->is_show
]);
$newRow->save();
in the above history query it truncate data. Do not know why. In database table field is longtext and also collation is ‘utf8_general_ci’. so seems no problem in database.