<commit_before><?php namespace Octommerce\Octommerce\Models;

use Model;
use Carbon\Carbon;
use Octommerce\Octommerce\Models\City;
use Rainlab\Location\Models\State;
use Responsiv\Pay\Models\Invoice;

/**
 * Order Model
 */
class Order extends Model
{
    use \October\Rain\Database\Traits\SoftDeleting;
    use \October\Rain\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'octommerce_octommerce_orders';

    /**
     * Validation rules
     */
    public $rules = [
        'name' => 'required|between:6,255',
        'email' => 'required|between:6,255|email',
        'phone' => 'required',
    ];

    /**
     * @var array The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'email',
        'phone',
        'postcode',
        'city_id',
        'state_id',
        'address',
        'company',
        'is_same_address',
        'shipping_name',
        'shipping_phone',
        'shipping_company',
        'shipping_address',
        'shipping_city_id',
        'shipping_state_id',
        'shipping_postcode',
        'message',
        'subtotal',
    ];

    protected $dates = ['status_updated_at', 'expired_at', 'deleted_at'];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [
        'status_logs' => 'Octommerce\Octommerce\Models\OrderStatusLog',
    ];
    public $belongsTo = [
        'user' => 'RainLab\User\Models\User',
        'status' => [
            'Octommerce\Octommerce\Models\OrderStatus',
            'key' => 'status_code',
        ],
        'city' => 'Octommerce\Octommerce\Models\City',
        'state' => 'RainLab\Location\Models\State',
        'shipping_city' => 'Octommerce\Octommerce\Models\City',
        'shipping_state' => 'RainLab\Location\Models\State',
    ];
    public $belongsToMany = [
        'products' => [
            'Octommerce\Octommerce\Models\Product',
            'table' => 'octommerce_octommerce_order_product',
            'pivot' => ['qty', 'price', 'discount', 'name'],
        ],
    ];
    public $morphTo = [];
    public $morphOne = [
        'invoice' => [
            'Responsiv\Pay\Models\Invoice',
            'name' => 'related',
        ],
    ];
    public $morphMany = [
        'invoices' => [
            'Responsiv\Pay\Models\Invoice',
            'name' => 'related'
        ],
    ];
    public $attachOne = [];<commit_msg>Add payment confirmation relation on order<commit_after><?php namespace Octommerce\Octommerce\Models;

use Model;
use Carbon\Carbon;
use Octommerce\Octommerce\Models\City;
use Rainlab\Location\Models\State;
use Responsiv\Pay\Models\Invoice;

/**
 * Order Model
 */
class Order extends Model
{
    use \October\Rain\Database\Traits\SoftDeleting;
    use \October\Rain\Database\Traits\Validation;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'octommerce_octommerce_orders';

    /**
     * Validation rules
     */
    public $rules = [
        'name' => 'required|between:6,255',
        'email' => 'required|between:6,255|email',
        'phone' => 'required',
    ];

    /**
     * @var array The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'email',
        'phone',
        'postcode',
        'city_id',
        'state_id',
        'address',
        'company',
        'is_same_address',
        'shipping_name',
        'shipping_phone',
        'shipping_company',
        'shipping_address',
        'shipping_city_id',
        'shipping_state_id',
        'shipping_postcode',
        'message',
        'subtotal',
    ];

    protected $dates = ['status_updated_at', 'expired_at', 'deleted_at'];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [
        'status_logs' => 'Octommerce\Octommerce\Models\OrderStatusLog',
    ];
    public $belongsTo = [
        'user' => 'RainLab\User\Models\User',
        'status' => [
            'Octommerce\Octommerce\Models\OrderStatus',
            'key' => 'status_code',
        ],
        'city' => 'Octommerce\Octommerce\Models\City',
        'state' => 'RainLab\Location\Models\State',
        'shipping_city' => 'Octommerce\Octommerce\Models\City',
        'shipping_state' => 'RainLab\Location\Models\State',
        'payment_confirmation' => ['Marthatilaar\Payment\Models\PaymentConfirmation',
            'key'      => 'order_no',
            'otherKey' => 'order_no'
        ],
    ];
    public $belongsToMany = [
        'products' => [
            'Octommerce\Octommerce\Models\Product',
            'table' => 'octommerce_octommerce_order_product',
            'pivot' => ['qty', 'price', 'discount', 'name'],
        ],
    ];
    public $morphTo = [];
    public $morphOne = [
        'invoice' => [
            'Responsiv\Pay\Models\Invoice',
            'name' => 'related',
        ],
    ];
    public $morphMany = [
        'invoices' => [
            'Responsiv\Pay\Models\Invoice',
            'name' => 'related'
        ],
    ];
    public $attachOne = [];
{'fraction_non_alphanumeric': 0.15175625849019989, 'fraction_numerical': 0.0031049873859887445, 'mean_word_length': 2.0936374549819927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4963171', 'n_tokens_mistral': 1667, 'n_tokens_neox': 1631, 'n_words': 271}