<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Device extends Model
{
    //
    protected $fillable = [
        'serial_number',
        'device_type',
        'model_name',
        'sim_card_no',
        'imei',
        'status',
        'created_by',
        'updated_by',
        'sales_user_id',
        'border_station_id',
        'current_lease_id'
    ];



    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }

    public function movements()
    {
        return $this->hasMany(StockMovement::class);
    }

    public function salesUser()
    {
        return $this->belongsTo(User::class, 'sales_user_id');
    }

    public function borderStation()
    {
        return $this->belongsTo(
            BorderStation::class,
            'border_station_id'
        );
    }


    public function currentLease()
{
    return $this->belongsTo(
        Lease::class,
        'current_lease_id'
    );
}


}
