<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "system_tracker".
 *
 * @property int $id
 * @property string|null $arrival_date
 * @property string|null $cn_number
 * @property int|null $date_paid
 * @property int|null $mode_shipment_id
 * @property string|null $name
 * @property resource|null $receipt_number
 * @property int|null $carrier_id
 * @property resource|null $document_number
 * @property string|null $number_of_pieces
 * @property string|null $description_of_cargo_received
 * @property int|null $broker_id
 * @property string|null $date_dropped_to_broker
 * @property string|null $shipment_delivery_date
 * @property int|null $delivered_by_id
 * @property int|null $customs_officer_id
 * @property string|null $quickbooks_number
 * @property string|null $shipment_notes
 * @property int|null $status_id
 * @property string|null $created_at
 * @property int|null $created_by
 * @property string|null $updated_at
 * @property int|null $updated_by
 *
 * @property Broker $broker
 * @property Carrier $carrier
 * @property CustomsOfficer $customsOfficer
 * @property DeliveryType $deliveredBy
 * @property ShipmentMode $modeShipment
 * @property Status $status
 */
class SystemTracker extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'system_tracker';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['arrival_date', 'date_dropped_to_broker', 'shipment_delivery_date', 'created_at', 'updated_at'], 'safe'],
            [['date_paid', 'mode_shipment_id', 'carrier_id', 'broker_id', 'delivered_by_id', 'customs_officer_id', 'status_id', 'created_by', 'updated_by'], 'integer'],
            [['description_of_cargo_received', 'shipment_notes'], 'string'],
            [['cn_number', 'name', 'receipt_number', 'document_number', 'number_of_pieces', 'quickbooks_number'], 'string', 'max' => 255],
            [['carrier_id'], 'exist', 'skipOnError' => true, 'targetClass' => Carrier::class, 'targetAttribute' => ['carrier_id' => 'id']],
            [['broker_id'], 'exist', 'skipOnError' => true, 'targetClass' => Broker::class, 'targetAttribute' => ['broker_id' => 'id']],
            [['delivered_by_id'], 'exist', 'skipOnError' => true, 'targetClass' => DeliveryType::class, 'targetAttribute' => ['delivered_by_id' => 'id']],
            [['status_id'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status_id' => 'id']],
            [['mode_shipment_id'], 'exist', 'skipOnError' => true, 'targetClass' => ShipmentMode::class, 'targetAttribute' => ['mode_shipment_id' => 'id']],
            [['customs_officer_id'], 'exist', 'skipOnError' => true, 'targetClass' => CustomsOfficer::class, 'targetAttribute' => ['customs_officer_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'arrival_date' => 'Arrival Date',
            'cn_number' => 'Cn Number',
            'date_paid' => 'Date Paid',
            'mode_shipment_id' => 'Mode Shipment ID',
            'name' => 'Name',
            'receipt_number' => 'Receipt Number',
            'carrier_id' => 'Carrier ID',
            'document_number' => 'Document Number',
            'number_of_pieces' => 'Number Of Pieces',
            'description_of_cargo_received' => 'Description Of Cargo Received',
            'broker_id' => 'Broker ID',
            'date_dropped_to_broker' => 'Date Dropped To Broker',
            'shipment_delivery_date' => 'Shipment Delivery Date',
            'delivered_by_id' => 'Delivered By ID',
            'customs_officer_id' => 'Customs Officer ID',
            'quickbooks_number' => 'Quickbooks Number',
            'shipment_notes' => 'Shipment Notes',
            'status_id' => 'Status ID',
            'created_at' => 'Created At',
            'created_by' => 'Created By',
            'updated_at' => 'Updated At',
            'updated_by' => 'Updated By',
        ];
    }

    /**
     * Gets query for [[Broker]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getBroker()
    {
        return $this->hasOne(Broker::class, ['id' => 'broker_id']);
    }

    /**
     * Gets query for [[Carrier]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getCarrier()
    {
        return $this->hasOne(Carrier::class, ['id' => 'carrier_id']);
    }

    /**
     * Gets query for [[CustomsOfficer]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getCustomsOfficer()
    {
        return $this->hasOne(CustomsOfficer::class, ['id' => 'customs_officer_id']);
    }

    /**
     * Gets query for [[DeliveredBy]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getDeliveredBy()
    {
        return $this->hasOne(DeliveryType::class, ['id' => 'delivered_by_id']);
    }

    /**
     * Gets query for [[ModeShipment]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getModeShipment()
    {
        return $this->hasOne(ShipmentMode::class, ['id' => 'mode_shipment_id']);
    }

    /**
     * Gets query for [[Status]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getStatus()
    {
        return $this->hasOne(Status::class, ['id' => 'status_id']);
    }
}
