<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Code extends Model
{
    protected $table = 'codes';

    protected $fillable = [
        'file_id',
        'activationcode',
        'status',
        'activationdate',
        'mac_address',
        'created_by',
    ];


    public function file()
    {
        return $this->belongsTo(File::class, 'file_id');
    }

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

    public function devices()
    {
        return $this->hasMany(DeviceList::class, 'code_id');
    }
}
