2020-06-27 23:45:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\LaravelNami;
|
|
|
|
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2021-06-19 00:44:56 +02:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2020-06-27 23:45:49 +02:00
|
|
|
|
2021-06-19 00:44:56 +02:00
|
|
|
class NamiUser extends Model implements Authenticatable {
|
2020-06-27 23:45:49 +02:00
|
|
|
|
2021-06-18 19:29:21 +02:00
|
|
|
public $mglnr;
|
2021-06-18 23:26:21 +02:00
|
|
|
public $password;
|
2020-06-27 23:45:49 +02:00
|
|
|
|
2021-06-18 23:26:21 +02:00
|
|
|
public function __construct($payload) {
|
|
|
|
$this->mglnr = data_get($payload, 'credentials.mglnr');
|
|
|
|
$this->password = data_get($payload, 'credentials.password');
|
2020-06-27 23:45:49 +02:00
|
|
|
}
|
|
|
|
|
2021-06-19 00:44:56 +02:00
|
|
|
public function api() {
|
|
|
|
return Nami::login($this->mglnr, $this->password);
|
2020-06-27 23:45:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getNamiGroupId() {
|
|
|
|
return $this->groupid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthIdentifierName() {
|
|
|
|
return 'mglnr';
|
|
|
|
}
|
|
|
|
|
2021-06-19 00:44:56 +02:00
|
|
|
public function getFirstnameAttribute() {
|
|
|
|
return $this->api()->findNr($this->mglnr)->vorname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastnameAttribute() {
|
|
|
|
return $this->api()->findNr($this->mglnr)->nachname;
|
|
|
|
}
|
|
|
|
|
2020-06-27 23:45:49 +02:00
|
|
|
public function getAuthIdentifier() {
|
|
|
|
return $this->{$this->getAuthIdentifierName()}.'-'.$this->groupid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthPassword() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRememberToken() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRememberToken($value) {}
|
|
|
|
|
|
|
|
public function getRememberTokenName() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|