Laravel only informs current date

0

Hello, I am reporting in the construct of my entity the date as follows:

Entity :

public function __construct($fornecedor, $emissao, $vencimento)
{
    $this->fornecedor = $fornecedor;
    $this->emissao = new \DateTime();
    $this->vencimento = new \DateTime();
}

Form :

{!! Form::open(['url'=>'contas/salvar']) !!}

    {!! Form::label('fornecedor','Fornecedor') !!}
    {!! Form::input('number','fornecedor', null, ['class' => 'form-control','placeholder'=>'Fornecedor']) !!}<br />

    {!! Form::label('emissao','Data de Emissão') !!}
    {!! Form::input('date','emissao', null, ['class' => 'form-control']) !!}<br />

    {!! Form::label('vencimento','Data de Vencimento') !!}
    {!! Form::input('date','vencimento', null, ['class' => 'form-control']) !!}<br />

    {!! Form::submit('Salvar',['class'=>'btn btn-primary']) !!}

{!! Form::close() !!}

Controller :

public function salvar(Request $request, EM $em)
{
    $Controle = new Controle(
        $request->get('fornecedor'),
        $request->get('emissao'),
        $request->get("vencimento")
    );

    $em->persist($Controle );
    $em->flush();

    return redirect('controle');
}

But if I enter any date in my Form it ignores and records the current date. I have tried to put it inside the construct $this->emissao = date_create(date('Y m d')); but it does not work. I just want to report month and year.

EDITION :

I put $request->all() and Print_r , I returned the following:

ModuloFinanceiro\Entities\Controle Object(

[fornecedor:ModuloFinanceiro\Entities\Controle:private] => Array
    (
        [_token] => IP5GwnGzUJW6TNsFeIyubFCNfKK7xoKhvgJuoIt1
        [fornecedor] => 1
        [emissao] => 2017-05-06
        [vencimento] => 2017-04-26
    )

[emissao:ModuloFinanceiro\Entities\Controle:private] => DateTime Object
    (
        [date] => 2017-04-20 14:47:27
        [timezone_type] => 3
        [timezone] => UTC
    )

[vencimento:ModuloFinanceiro\Entities\Controle:private] => DateTime Object
    (
        [date] => 2017-04-20 14:47:27
        [timezone_type] => 3
        [timezone] => UTC
    )
)
1

Is he under writing?

    
asked by anonymous 20.04.2017 / 15:53

1 answer

0

Resolution :

Passed as parameter $emissao and $vencimento within new \DateTime();

public function __construct($fornecedor, $emissao, $vencimento)
{
    $this->fornecedor = $fornecedor;
    $this->emissao = new \DateTime($emissao);
    $this->vencimento = new \DateTime($vencimento);
}

Positive result.

    
20.04.2017 / 19:26