I have 2 methods to save and another to consult and I have them as follows:
public function store(Request $request)
{
$comment = new Comment();
$comment->user_id = $request->user_id;
$comment->factura_id = $request->factura_id;
$comment->comment = $request->comment;
$comment->save();
if ( $request->ajax() ){
return $comment;
}
}
public function show($id)
{
$comments = Comment::select('*')->where('factura_id', $id)->with('user:id,name')->get();
return $comments;
}
Everything worked fine but today 13-01-2017 when wanting to save it gives me an error it tells me:
SQLSTATE [22007]: [Microsoft] [ODBC Driver 13 for SQL Server] [SQL Server] The conversion of nvarchar data type into datetime produced a value out of range. (SQL: insert into [comments] ([user_id], [invoice_id], [comment], [updated_at], [created_at]) values (1, 554, commeny, 2018-01-13 14: 25: 44.015, 2018-01-13 14: 25: 44.015))
It does not let me save by the methods of created_at and updated_at, the easy solution is to remove them but I do not want them because I need them, and I do not know how to solve them. try to do it by adding a my model
protected $dateFormat = 'Ymd h:i:s';
and it works for me, I can save it but when I ask it, it says:
Unexpected data found. Unexpected data found. Trailing data
Some colleagues solution ???