PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Models / OrderTaxRate.php

OrderTaxRate.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Models/OrderTaxRate.php

69 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Models;
4
5 /**
6 * Meta Model - DB Model for Meta table
7 *
8 * Database Model
9 *
10 *
11 * @version 1.0.0
12 */
13 class OrderTaxRate extends Model
14 {
15 protected $table = 'fct_order_tax_rate';
16
17 protected $primaryKey = 'id';
18
19 protected $guarded = ['id'];
20
21 protected $fillable = [
22 'order_id',
23 'tax_rate_id',
24 'shipping_tax',
25 'order_tax',
26 'total_tax',
27 'meta',
28 'filed_at',
29 ];
30
31 public function setMetaAttribute($value)
32 {
33 if ($value) {
34 $decoded = \json_encode($value, true);
35 if (!($decoded)) {
36 $decoded = '[]';
37 }
38 } else {
39 $decoded = '[]';
40 }
41
42 $this->attributes['meta'] = $decoded;
43 }
44
45 public function getMetaAttribute($value)
46 {
47 if (!$value) {
48 return [];
49 }
50
51 return \json_decode($value, true);
52 }
53
54 public function order()
55 {
56 return $this->belongsTo(Order::class, 'order_id', 'id');
57 }
58
59 public function tax_rate()
60 {
61 return $this->belongsTo(TaxRate::class, 'tax_rate_id', 'id');
62 }
63
64 public function scopeValidOrder($query)
65 {
66 return $query->whereHas('order', fn ($o) => $o->whereIn('payment_status', ['paid', 'partially_paid']));
67 }
68 }
69