<?php namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\Models\Log;

class Employee extends Model {

    protected $fillable = ['cin','first_name','last_name','date_birth' , 'email', 'state',
                            'image','mobile' , 'date_recrutment' ,'date_resignation' ,'password','api_token','expires_on'];
    protected  $guarded =['id'];
    public function getDates()
    {
        return ['created_at', 'updated_at', 'date_birth', 'date_recrutment', 'date_resignation'];
    }

    public function logs(){
        return $this->hasMany('App\Models\Log');
    }
    public function scopeTokenValid()
    {
        return !Carbon::createFromTimeStamp(strtotime($this->expires_on))->isPast();
    }

}
