Good morning, could anyone help me with this formatting? Well, I have the following form:
<div class="form-group col-md-12 col-sm-12 col-xs-12">
<div class="col-md-2 col-sm-2 col-xs-2 form-label">
{{Form::label('date', 'Data')}}
</div>
<div class="col-md-3 col-sm-10 col-xs-10">
{{Form::date('date', null, ['class' => 'form-control'])}}
</div>
</div>
I have a query with a select picking the date field:
$query = DB::table('empenho as emp')
->select('emp.date as a')->orderby('emp.nrEmpenho');
So I validate the information on my form:
if ($request->date) $query->where('emp.date', $request->date);
Everything works perfectly, but it returns the field in this format:
I would like to return the field in Day / Month / Year, I thought that using Carbon :: parse in the model would solve, but it did not work, I tried to do so in my Model:<?php
namespace Portal\Entity\Contabilidade;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Empenho extends Model
{
protected $table = 'empenho';
public $timestamps = false;
public static $snakeAttributes = false;
protected $dates = ['date'];
public function getdateAttribute($value)
{
return Carbon::parse($value)->format('d/m/Y');
}
}
It does not work and I do not know what to do, could anyone help me please? Anything that is not clear in the code inform me that I post any other necessary information, thank you!