<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use Jenssegers\Mongodb\Auth\User as Authenticatable;

class Staff extends Authenticatable 
{
    //
    use SoftDeletes;
    use Notifiable;
    
    protected $connection = 'mongodb';
    protected $collection = 'staff';

    // protected $guarded = ['_id'];
    protected $fillable = ['_id', 'email', 'password', 'roles_access', 'last_login_at', 'last_login_ip'];
    
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function staffdetail() {
        return $this->hasOne('App\Model\StaffDetail','_id','_id')->withTrashed();
    }

    public function company() {
        return $this->belongsTo('App\Model\Company','company_id','_id');
    }

    public function form() {
        return $this->hasMany('App\Model\Form','dealer_id','_id');
    }

    public function workorder() {
        return $this->hasMany('App\Model\WorkOrder','installer_id','_id')->withTrashed();
    }
}
