Changeset View
Changeset View
Standalone View
Standalone View
src/app/UserAlias.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
/** | /** | ||||
* A email address alias for a User. | * A email address alias for a User. | ||||
* | * | ||||
* @property string $alias | * @property string $alias | ||||
* @property int $id | * @property int $id | ||||
* @property int $user_id | * @property int $user_id | ||||
*/ | */ | ||||
class UserAlias extends Model | class UserAlias extends Model | ||||
{ | { | ||||
protected $fillable = [ | /** @var array<int, string> The attributes that are mass assignable */ | ||||
'user_id', 'alias' | protected $fillable = ['user_id', 'alias']; | ||||
]; | |||||
/** | /** | ||||
* Ensure the email address is appropriately cased. | * Ensure the email address is appropriately cased. | ||||
* | * | ||||
* @param string $alias Email address | * @param string $alias Email address | ||||
*/ | */ | ||||
public function setAliasAttribute(string $alias) | public function setAliasAttribute(string $alias) | ||||
{ | { | ||||
$this->attributes['alias'] = \strtolower($alias); | $this->attributes['alias'] = \strtolower($alias); | ||||
} | } | ||||
/** | /** | ||||
* The user to which this alias belongs. | * The user to which this alias belongs. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function user() | public function user() | ||||
{ | { | ||||
return $this->belongsTo('\App\User', 'user_id', 'id'); | return $this->belongsTo(User::class, 'user_id', 'id'); | ||||
} | } | ||||
} | } |