<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Uzytkownik extends Authenticatable
{
    //

    const CREATED_AT = 'CreationDate';
    const UPDATED_AT = 'ChangeDate';

    protected $primaryKey = 'ID';
    protected $table = 'User';
    protected $fillable = array(
        'login',
        'password',
        'name',
        'surname',
        'PESEL',
        'phoneNumber',
        'email',
        'fireStationID',
        'functionID',
        'degreeID',
        'number',
        'statusId',
        'deleted',
        'creatorId',
        'creationDate',
        'changingId',
        'changeDate'
    );

    protected $casts = [
        'CreationDate' => 'datetime',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];

    public function setPasswordAttribute($password)
    {
        $this->attributes['password'] = bcrypt($password);
    }
}
