<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Class FcmToken
 *
 * @package App\Models
 */
class FcmToken extends Model
{
    /**
     * The table field that stores the primary key.
     *
     * @var string
     */
    protected $primaryKey = 'oid';

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

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = true;

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'useroid' => 'integer'
    ];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['device_id', 'token'];

    /**
     * The user associated to this token
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user()
    {
        return $this->hasOne('App\Models\User', 'oid', 'useroid');
    }
}