mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
Add avatar handling to user model.
This commit is contained in:
parent
1619f84bc8
commit
755461f56f
|
@ -23,6 +23,7 @@ class CreateUsersTable extends Migration {
|
|||
$table->string('password');
|
||||
$table->text('bio')->nullable();
|
||||
$table->text('bio_html')->nullable();
|
||||
$table->string('avatar')->nullable();
|
||||
$table->dateTime('join_time')->nullable();
|
||||
$table->dateTime('last_seen_time')->nullable();
|
||||
$table->dateTime('read_time')->nullable();
|
||||
|
|
13
framework/core/src/Core/Events/UserAvatarWasChanged.php
Normal file
13
framework/core/src/Core/Events/UserAvatarWasChanged.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserAvatarWasChanged
|
||||
{
|
||||
public $user;
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use Flarum\Core\Events\UserWasRenamed;
|
|||
use Flarum\Core\Events\UserEmailWasChanged;
|
||||
use Flarum\Core\Events\UserPasswordWasChanged;
|
||||
use Flarum\Core\Events\UserBioWasChanged;
|
||||
use Flarum\Core\Events\UserAvatarWasChanged;
|
||||
use Flarum\Core\Events\UserWasActivated;
|
||||
use Flarum\Core\Events\UserEmailWasConfirmed;
|
||||
|
||||
|
@ -210,6 +211,15 @@ class User extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function changeAvatarUrl($url)
|
||||
{
|
||||
$this->avatar = $url;
|
||||
|
||||
$this->raise(new UserAvatarWasChanged($this));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given password matches the user's password.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user