Skip to content

Instantly share code, notes, and snippets.

@W3SS
Forked from ricardobarantini/Model.php
Created October 11, 2017 17:53
Show Gist options
  • Save W3SS/a113dc16cfd3a9327c0f295c75af3a2d to your computer and use it in GitHub Desktop.
Save W3SS/a113dc16cfd3a9327c0f295c75af3a2d to your computer and use it in GitHub Desktop.
Modifica o formato da data usando Carbon no Laravel
<?php
public function setDataAttribute($value)
{
$this->attributes['data'] = Carbon::createFromFormat('d/m/Y', $value)->toDateString();
}
public function getDataAttribute($value)
{
return Carbon::parse($value)->format('d/m/Y');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment