mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
Add avatar handling to user model.
This commit is contained in:
13
src/Core/Events/UserAvatarWasChanged.php
Normal file
13
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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user