| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Models; |
| 4 |
|
| 5 |
use FluentCart\App\Helpers\AddressHelper; |
| 6 |
|
| 7 |
/** |
| 8 |
* Meta Model - DB Model for Meta table |
| 9 |
* |
| 10 |
* Database Model |
| 11 |
* |
| 12 |
* @package FluentCart\App\Models |
| 13 |
* |
| 14 |
* @version 1.0.0 |
| 15 |
*/ |
| 16 |
class TaxRate extends Model |
| 17 |
{ |
| 18 |
protected $table = 'fct_tax_rates'; |
| 19 |
|
| 20 |
public $timestamps = false; |
| 21 |
|
| 22 |
protected $primaryKey = 'id'; |
| 23 |
|
| 24 |
protected $guarded = [ 'id' ]; |
| 25 |
|
| 26 |
protected $fillable = [ |
| 27 |
'class_id', |
| 28 |
'country', |
| 29 |
'state', |
| 30 |
'postcode', |
| 31 |
'city', |
| 32 |
'rate', |
| 33 |
'name', |
| 34 |
'group', |
| 35 |
'priority', |
| 36 |
'is_compound', |
| 37 |
'for_shipping', |
| 38 |
'for_order', |
| 39 |
'class_id' |
| 40 |
]; |
| 41 |
|
| 42 |
protected $appends = ['formatted_state']; |
| 43 |
|
| 44 |
public function tax_class() { |
| 45 |
return $this->belongsTo( TaxClass::class, 'class_id', 'id' ); |
| 46 |
} |
| 47 |
|
| 48 |
public function getFormattedStateAttribute() |
| 49 |
{ |
| 50 |
if (!empty($this->state)) { |
| 51 |
return AddressHelper::getStateNameByCode($this->state, $this->country); |
| 52 |
} |
| 53 |
return ''; |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
|