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 / SubscriptionMeta.php

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

45 lines 1.1 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 * Order Meta Model - DB Model for Order Meta table
7 *
8 * Database Model
9 *
10 * @package FluentCart\App\Models
11 *
12 * @version 1.0.0
13 */
14 class SubscriptionMeta extends Model
15 {
16 protected $table = 'fct_subscription_meta';
17
18 protected $fillable = [
19 'subscription_id',
20 'meta_key',
21 'meta_value',
22 ];
23
24 public function setMetaValueAttribute( $value ) {
25 //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
26 if (is_array( $value ) || is_object( $value ) ) {
27 $value = json_encode( $value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
28 }
29 //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
30 $this->attributes['meta_value'] = $value;
31 }
32
33 public function getMetaValueAttribute( $value ) {
34 if (is_string( $value )) {
35 $decoded = json_decode($value, true);
36 return $decoded ?: $value;
37 }
38 return $value;
39 }
40
41 public function product_detail() {
42 return $this->belongsTo( Subscription::class, 'subscription_id', 'id' );
43 }
44 }
45