Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Created July 28, 2022 18:43
Show Gist options
  • Save NandoKstroNet/4bde521468938b5d83b58e3f83fe99a3 to your computer and use it in GitHub Desktop.
Save NandoKstroNet/4bde521468938b5d83b58e3f83fe99a3 to your computer and use it in GitHub Desktop.
ShippintOption model - Single Database MultiTenancy com Laravel em https://codeexperts.com.br
<?php
namespace App\Models;
use App\Traits\BelongsTenantScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ShippingOption extends Model
{
use HasFactory, BelongsTenantScope;
protected $fillable = ['name', 'price'];
public function setPriceAttribute($prop)
{
$price = str_replace(['.', ','], ['', '.'], $prop);
$this->attributes['price'] = $price * 100;
}
public function getPriceAttribute()
{
return $this->attributes['price'] / 100;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment