<?php
namespace Moto\Database\Models; use Moto; use Illuminate; class User extends Moto\Database\BaseModel { const CREATED_AT = 'created'; const UPDATED_AT = 'modified'; protected $table = 'users'; protected $morphClass = '@User'; protected $_legacyModel = Moto\Application\Users\UserModel::class; protected $fillable = [ 'email', 'name', 'role_id', 'language_id', 'enabled', ]; protected $casts = [ 'id' => 'int', 'email' => 'string', 'name' => 'string', 'role_id' => 'int', 'language_id' => 'int', 'enabled' => 'boolean', ]; protected $attributes = [ 'email' => '', 'name' => '', 'role_id' => 1, 'language_id' => 1, 'enabled' => true, ]; protected $visible = [ ]; protected $hidden = [ 'login', 'password', 'salt', 'del', ]; protected $dates = [ ]; protected $appends = [ 'role_name', 'language_name', 'language_code', 'language_locale', ]; public function role() { return $this->belongsTo(Moto\Database\Models\Role::class, 'role_id', 'id'); } public function language() { return $this->belongsTo(Moto\Database\Models\Language::class, 'language_id', 'id'); } public function getRoleNameAttribute($value = null) { if ($this->role) { return $this->role->name; } return null; } public function getLanguageNameAttribute($value = null) { if ($this->language) { return $this->language->name; } return null; } public function getLanguageCodeAttribute($value = null) { if ($this->language) { return $this->language->code; } return null; } public function getLanguageLocaleAttribute($value = null) { if ($this->language) { return $this->language->locale; } return null; } public function isValidPassword($password) { return Moto\Authentication\Security::verify($password, $this->password); } public function setPassword($openPassword) { $this->password = Moto\Authentication\Security::hashPassword($openPassword, Moto\Authentication\Security::generateSalt()); } } 