Add avatar handling to user model.

This commit is contained in:
Franz Liedke 2015-03-25 14:21:50 +01:00
parent 901b6b0839
commit 7f66a77ede
3 changed files with 24 additions and 0 deletions

View File

@ -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();

View 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;
}
}

View File

@ -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.
*