<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Asset extends Model
{
    protected $table = 'pc_owner';
    protected $primaryKey = 'pcid';

    const CREATED_AT = 'created_date';
    const UPDATED_AT = 'modified_date';

    public function getPcextraAttribute($value) {
        return unserialize($value);
    }

    public function setPcextraAttribute($value) {
        $this->attributes['pcextra'] = serialize($value);
    }

    public function workOrders()
    {
        return $this->hasMany('App\WorkOrder');
    }

    public function group()
    {
        return $this->belongsTo('App\Group', 'pcgroupid');
    }

    public function credentials()
    {
        return $this->hasMany('App\Credential', 'pcid', 'pcid');
    }
}
