<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DeviceReturn extends Model
{
    protected $guarded = [];

    protected $casts = [
        'returned_at' => 'datetime',
        'received_at' => 'datetime',
    ];

    /*
    |--------------------------------------------------------------------------
    | Relationships
    |--------------------------------------------------------------------------
    */

    public function device()
    {
        return $this->belongsTo(
            Device::class
        );
    }

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

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

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