I use laravel and in my view I have an input datepicker like this :
{!! Form::text('DESMES_Date_Analyses',null ,['class' => 'form-control datepicker']) !!}
With this code :
$('.datepicker').datepicker({
format: 'yyyy-mm-dd',
todayHighlight: true,
language : 'fr'
});
And I get the value with something like this :
var date_analyses = $(this).find("input[name=DESMES_Date_Analyses]").val();
After that I insert in Database the value with Ajax request :
$.ajax({
url: './register',
headers: {'X-CSRF-TOKEN': token},
data: {
DESMES_Date_Analyses : date_analyses
},
type: 'POST',
datatype: 'JSON'
)};
And in my controller I do :
public function register(Request $request) {
if($request->ajax()) {
Mesures::create($request->all());
}
}
But if the value is empty, in my database I have 1900-01-01 and I just want NULL instead of this default date. How can I do this?
I tried to set date_analyses to null in javascript before sending it to my controller but it doesn't work... Thank you!