public function store(ContractRequest $request,$operatorId)
{
//dd($request->all());
$contractData = $request->all();
$contractData['operator_id'] = $operatorId;
if ($this->contract->create($contractData)) {
return redirect()->route('admin.operator.{id}.contracts.index',[$operatorId])->with('success', 'Contract
successfully
created.');
}
return redirect()->route('admin.contracts.index')->with('error', 'Contract could not be created.');
}
我的观点:
<div class="form-group">
{!! Form::label('title', 'Start Date:', ['class'=>'col-sm-2 control-label'])!!}
<div class="col-sm-7">
{!! Form::date('start_date',null, ["class"=>"form-control",'required'])!!}
</div>
</div>
<div class="form-group">
{!! Form::label('title', 'End Date:', ['class'=>'col-sm-2 control-label'])!!}
<div class="col-sm-7">
{!! Form::date('end_date',null, ["class"=>"form-control"])!!}
</div>
</div>
<div class="form-group">
{!! Form::label('title', 'Remarks:', ['class'=>'col-sm-2 control-label'])!!}
<div class="col-sm-7">
{!! Form::textarea('remark',null, ["class"=>"form-control",'cols'=>'10','rows'=>'5'])!!}
</div>
</div>
我的问题:这是合同形式,通常是contract
开始日期01
每月30,29 or 31
天结束。
如果用户选择2016-2-4
为start date
和2017-05-31
as end date
,则开始日期应保存为2016-2 - 1
。如何进行此操作,开始日期日期应始终为一个,即1
开始数据2016-o2-o4 should be saved as
2016-02-01,即1
在日结束时
答案 0 :(得分:0)
解决这个问题的正确方法是首先将其作为Carbon对象进行实例化(我说的是Carbon,因为它使得这更容易,并且已经与Laravel一起发布)。完成后,您只需在该对象上设置In some cases you might want to preserve an order you put the elements in the Set,
In such scenario you can use, This
Set<Integer> alldocsId = new HashSet<>();
for (int i=0;i<normalized.length;i++)
{
String sql = "SELECT DISTINCT movieID FROM postingtbl WHERE term=?";
PreparedStatement prepstm = conn.prepareStatement(sql);
prepstm.setString(1,normalized[i]);
ResultSet rs = prepstm.executeQuery();
while (rs.next())
{
alldocsId.add(rs.getInt("MovieID"));
}
prepstm.close();
}
List<Integer> alldocIDlst = new ArrayList<>();
Iterator it = alldocsId.iterator();
while (it.hasNext())
{
alldocIDlst.add(Integer.valueOf(it.next().toString()));
}
就可以了。请注意,Laravel会自动处理Carbon / DateTime对象,因此您可以直接将其保存到数据库中,Laravel将处理将其转换为格式正确的字符串。它看起来像这样:
day
这会将当天设置为本月的第一天,剩下的就是原样。