refactor: code style changes

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
2023-01-15 00:04:00 +00:00
parent 25155bff2e
commit 3727c84f3e
146 changed files with 1013 additions and 1341 deletions

View File

@@ -21,18 +21,10 @@
namespace App;
use App\Services\AccountSuspensionService;
use App\Traits\HandlesAccountTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\View;
use Mpociot\Teamwork\Traits\UserHasTeams;
use Spatie\Permission\Traits\HasRoles;
@@ -58,7 +50,7 @@ class User extends Authenticatable implements MustVerifyEmail
'currentIp',
'discord_user_id',
'discord_token',
'discord_refresh_token'
'discord_refresh_token',
];
/**
@@ -67,7 +59,7 @@ class User extends Authenticatable implements MustVerifyEmail
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'discord_token', 'discord_refresh_token'
'password', 'remember_token', 'discord_token', 'discord_refresh_token',
];
/**
@@ -78,7 +70,7 @@ class User extends Authenticatable implements MustVerifyEmail
protected $casts = [
'email_verified_at' => 'datetime',
'discord_token' => 'encrypted',
'discord_refresh_token' => 'encrypted'
'discord_refresh_token' => 'encrypted',
];
// RELATIONSHIPS
@@ -91,7 +83,6 @@ class User extends Authenticatable implements MustVerifyEmail
public function votes()
{
return $this->hasMany('App\Vote', 'userID', 'id');
}
public function profile()
@@ -119,8 +110,8 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->hasMany('App\Absence', 'requesterID');
}
public function isEligible(): bool {
public function isEligible(): bool
{
$lastApplication = Application::where('applicantUserID', $this->getAttribute('id'))->latest()->first();
if (is_null($lastApplication)) {
@@ -134,15 +125,16 @@ class User extends Authenticatable implements MustVerifyEmail
return false;
}
public function isVerified(): bool {
return !is_null($this->email_verified_at);
public function isVerified(): bool
{
return ! is_null($this->email_verified_at);
}
/**
* Checks if user is staff
*
* @deprecated This method is being replaced by a better way of checking permissions, rather than checking for group name.
*
* @return bool
*/
public function isStaffMember(): bool
@@ -168,12 +160,9 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function hasTeam($team): bool
{
if ($team instanceof Team || is_int($team))
{
if ($team instanceof Team || is_int($team)) {
return $this->teams->contains($team);
}
else
{
} else {
/**
* In PHP 8, we can just use union types and let PHP enforce this for us.
*/
@@ -186,18 +175,18 @@ class User extends Authenticatable implements MustVerifyEmail
*
* @return bool
*/
public function hasDiscordConnection(): bool {
return !is_null($this->discord_token) && !is_null($this->discord_refresh_token);
public function hasDiscordConnection(): bool
{
return ! is_null($this->discord_token) && ! is_null($this->discord_refresh_token);
}
/**
* Check if user has a password
*
* @return bool
*/
public function hasPassword(): bool {
return !is_null($this->password);
public function hasPassword(): bool
{
return ! is_null($this->password);
}
}