Created
July 28, 2022 18:43
-
-
Save NandoKstroNet/4bde521468938b5d83b58e3f83fe99a3 to your computer and use it in GitHub Desktop.
ShippintOption model - Single Database MultiTenancy com Laravel em https://codeexperts.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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