laravel-learn-bbs/app/Models/User.php
2018-01-15 23:24:11 +08:00

50 lines
918 B
PHP

<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'introduction', 'avatar '
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getHeaderAttribute()
{
return asset($this->avatar);
}
public function isAuthorOf($model)
{
return $this->id == $model->user_id;
}
public function replies()
{
return $this->hasMany(Reply::class, 'user_id');
}
public function topics()
{
return $this->hasMany(Topic::class);
}
}