2018-07-24 11:11:32 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Webkul\Core\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2019-02-18 07:30:40 +00:00
|
|
|
use Webkul\Core\Contracts\Currency as CurrencyContract;
|
2018-07-24 11:11:32 +00:00
|
|
|
|
2019-02-18 07:30:40 +00:00
|
|
|
class Currency extends Model implements CurrencyContract
|
2018-07-24 11:11:32 +00:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2020-03-04 06:32:53 +00:00
|
|
|
protected $fillable = [
|
|
|
|
|
'code',
|
|
|
|
|
'name',
|
|
|
|
|
'symbol',
|
|
|
|
|
];
|
2018-12-07 05:25:33 +00:00
|
|
|
|
2019-03-29 11:18:00 +00:00
|
|
|
/**
|
|
|
|
|
* Set currency code in capital
|
|
|
|
|
*
|
|
|
|
|
* @param string $value
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setCodeAttribute($code)
|
|
|
|
|
{
|
|
|
|
|
$this->attributes['code'] = strtoupper($code);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-07 05:25:33 +00:00
|
|
|
/**
|
|
|
|
|
* Get the currency_exchange associated with the currency.
|
|
|
|
|
*/
|
|
|
|
|
public function CurrencyExchangeRate()
|
|
|
|
|
{
|
2019-02-18 07:30:40 +00:00
|
|
|
return $this->hasOne(CurrencyExchangeRateProxy::modelClass(), 'target_currency');
|
2018-12-07 05:25:33 +00:00
|
|
|
}
|
2018-07-24 11:11:32 +00:00
|
|
|
}
|