<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\SoftDeletes;


/**
 * Class Address
 * @package App\Models
 * @version August 4, 2020, 4:36 am
 *
 * @property \App\Models\Company company
 * @property string street_one
 * @property string street_two
 * @property string city
 * @property string state
 * @property string post_code
 * @property string country
 */
class Order extends AbstractModel
{

    use SoftDeletes;

    protected $table = 'orders';

    protected $dates = ['deleted_at'];

    /**
     * @return belongsToMany
     */
    public function warehouses(): belongsToMany
    {
        return $this->belongsToMany(Company::class, (new OrderWarehouse())->getTable(), 'order_id','warehouse_id');
    }

    /**
     * @return belongsTo
     */
    public function importer(): belongsTo
    {
        return $this->belongsTo(Company::class, 'company_id','id');
    }

    /**
     * @return belongsTo
     */
    public function address(): belongsTo
    {
        return $this->belongsTo(Address::class, 'address_id','id');
    }




}
