<?php

namespace App\Modules\Stock;

use App\Models\ValidationModel;
use App\Modules\Stock\StockPurchaseOrderItem;
use App\Traits\SetCreatorAndUpdatorTrait;

class StockPurchaseOrderItemSerial extends ValidationModel
{
    use SetCreatorAndUpdatorTrait;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'stock_purchase_order_items_serials';

    /**
     * The attributes that should be mutated to dates.
     *
     * @var array
     */
    protected $dates = ['deleted_at'];

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    // protected $appends = array();


    /**
     *	The attributes that won't be assigned during
     *	a mass assignment.
     */
    protected $fillable = ['order_item_id','serial_number'];

    /**
     * Array of validation rules.
     *
     * @var  array
     */
    protected static $rules = [
        'serial_number'        => 'unique:stock_purchase_order_items_serials',
        'order_item_id'        => 'required',
    ];

    // ==================================================================
    //
    // Relationships
    //
    // ------------------------------------------------------------------


    /**
     *	Inverse one to many relationship.
     *	Return the stock that made this order.
     */
    public function order_item()
    {
        return $this->belongsTo(StockPurchaseOrderItem::class);
    }
}
