2018-10-06 14:15:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Models\User;
|
|
|
|
|
2019-11-06 13:43:57 +01:00
|
|
|
use Carbon\Carbon;
|
2018-10-06 14:15:54 +02:00
|
|
|
use Engelsystem\Models\BaseModel;
|
2019-11-10 21:30:26 +01:00
|
|
|
use Engelsystem\Models\News;
|
2019-10-31 20:02:34 +01:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2018-10-06 14:15:54 +02:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2019-11-06 13:43:57 +01:00
|
|
|
use Illuminate\Database\Query\Builder as QueryBuilder;
|
2018-10-06 14:15:54 +02:00
|
|
|
|
|
|
|
/**
|
2019-11-06 13:43:57 +01:00
|
|
|
* @property integer $id
|
|
|
|
* @property string $name
|
|
|
|
* @property string $email
|
|
|
|
* @property string $password
|
|
|
|
* @property string $api_key
|
|
|
|
* @property Carbon|null $last_login_at
|
|
|
|
* @property Carbon $created_at
|
|
|
|
* @property Carbon $updated_at
|
2018-10-06 14:15:54 +02:00
|
|
|
*
|
2019-11-06 13:43:57 +01:00
|
|
|
* @property-read QueryBuilder|Contact $contact
|
|
|
|
* @property-read QueryBuilder|PersonalData $personalData
|
|
|
|
* @property-read QueryBuilder|Settings $settings
|
|
|
|
* @property-read QueryBuilder|State $state
|
2018-10-06 14:15:54 +02:00
|
|
|
*
|
2019-11-06 13:43:57 +01:00
|
|
|
* @method static QueryBuilder|User whereId($value)
|
|
|
|
* @method static QueryBuilder|User[] whereName($value)
|
|
|
|
* @method static QueryBuilder|User[] whereEmail($value)
|
|
|
|
* @method static QueryBuilder|User[] wherePassword($value)
|
|
|
|
* @method static QueryBuilder|User[] whereApiKey($value)
|
|
|
|
* @method static QueryBuilder|User[] whereLastLoginAt($value)
|
|
|
|
* @method static QueryBuilder|User[] whereCreatedAt($value)
|
|
|
|
* @method static QueryBuilder|User[] whereUpdatedAt($value)
|
2018-10-06 14:15:54 +02:00
|
|
|
*/
|
|
|
|
class User extends BaseModel
|
|
|
|
{
|
|
|
|
/** @var bool enable timestamps */
|
|
|
|
public $timestamps = true;
|
|
|
|
|
|
|
|
/** The attributes that are mass assignable */
|
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'password',
|
|
|
|
'email',
|
|
|
|
'api_key',
|
|
|
|
'last_login_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
/** @var array The attributes that should be hidden for serialization */
|
|
|
|
protected $hidden = [
|
|
|
|
'api_key',
|
|
|
|
'password',
|
|
|
|
];
|
|
|
|
|
|
|
|
/** @var array The attributes that should be mutated to dates */
|
|
|
|
protected $dates = [
|
|
|
|
'last_login_at',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return HasOne
|
|
|
|
*/
|
|
|
|
public function contact()
|
|
|
|
{
|
|
|
|
return $this
|
|
|
|
->hasOne(Contact::class)
|
|
|
|
->withDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return HasOne
|
|
|
|
*/
|
|
|
|
public function personalData()
|
|
|
|
{
|
|
|
|
return $this
|
|
|
|
->hasOne(PersonalData::class)
|
|
|
|
->withDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return HasOne
|
|
|
|
*/
|
|
|
|
public function settings()
|
|
|
|
{
|
|
|
|
return $this
|
|
|
|
->hasOne(Settings::class)
|
|
|
|
->withDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return HasOne
|
|
|
|
*/
|
|
|
|
public function state()
|
|
|
|
{
|
|
|
|
return $this
|
|
|
|
->hasOne(State::class)
|
|
|
|
->withDefault();
|
|
|
|
}
|
2019-10-31 20:02:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return HasMany
|
|
|
|
*/
|
|
|
|
public function news(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(News::class);
|
|
|
|
}
|
2018-10-06 14:15:54 +02:00
|
|
|
}
|