Remove Laravolt dependency. Closes #3376

This commit is contained in:
James Brooks
2019-06-23 16:08:03 +01:00
parent 066837fa71
commit 8f91f6d92f
7 changed files with 89 additions and 344 deletions

View File

@@ -12,21 +12,19 @@
namespace CachetHQ\Cachet\Models;
use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\UserPresenter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use McCool\LaravelAutoPresenter\HasPresenter;
/**
* This is the user model.
*
* @author James Brooks <james@alt-three.com>
*/
class User extends Authenticatable implements HasPresenter
class User extends Authenticatable
{
use Notifiable, ValidatingTrait;
@@ -211,14 +209,4 @@ class User extends Authenticatable implements HasPresenter
{
return trim($this->google_2fa_secret) !== '';
}
/**
* Get the presenter class.
*
* @return string
*/
public function getPresenterClass()
{
return UserPresenter::class;
}
}

View File

@@ -1,51 +0,0 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Presenters;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Config;
use Laravolt\Avatar\Facade as Avatar;
use McCool\LaravelAutoPresenter\BasePresenter;
/**
* This is the user presenter class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserPresenter extends BasePresenter implements Arrayable
{
/**
* Returns the users avatar.
*
* @return string
*/
public function avatar()
{
if (Config::get('setting.enable_external_dependencies')) {
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5(strtolower($this->email)), 200);
}
return Avatar::create($this->username)->toBase64();
}
/**
* Convert the presenter instance to an array.
*
* @return string[]
*/
public function toArray()
{
return array_merge($this->wrappedObject->toArray(), [
'avatar' => $this->avatar(),
]);
}
}