Skip to content

Instantly share code, notes, and snippets.

@viniciusalonso
Created July 20, 2019 15:15
Show Gist options
  • Save viniciusalonso/4fcdfceedc1810797014b5f2c4814650 to your computer and use it in GitHub Desktop.
Save viniciusalonso/4fcdfceedc1810797014b5f2c4814650 to your computer and use it in GitHub Desktop.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Money;
class Product extends Model
{
protected $fillable => [
'name',
'price',
'currency'
]
public function setPriceAttribute($price)
{
$this->attributes['price'] = new Money($price, $this->currency);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment