You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/app/User.php

135 lines
3.0 KiB
PHTML

<?php
namespace App;
use App\Services\AvatarService;
use App\Util\RateLimit\User as UserRateLimit;
Staging (#6264) * StatusPipeline defensive checks * HomeFeedPipeline defensive checks * DeletePipeline defensive checks * InboxPipeline defensive checks * MediaPipeline defensive checks * PushNotificationPipeline defensive checks * LikePipeline defensive checks * FollowPipeline defensive checks * ImageOptimizePipeline defensive checks * Misc pipelines defensive checks * Update CommentPipeline.php * Update FollowPushNotifyPipeline.php * Update LikePushNotifyPipeline.php * Update FollowPushNotifyPipeline.php * Update MentionPushNotifyPipeline.php * Update MoveSendUndoFollowPipeline.php * Update RemoteFollowPipeline.php * Update FollowPushNotifyPipeline.php * Update LikePushNotifyPipeline.php * Update MentionPushNotifyPipeline.php * Update Site/Config.php - config_cache only has 1 arg. No fallback. * Update Bouncer.php - Called 'count' on Laravel collection, but could have been retrieved as a query. 🪪 larastan.noUnnecessaryCollectionCall * Update Status.php - Missing use App\Models\Conversation; * Larastan: Update UndoSharePipeline.php (Undefined variable: $status) * Update ResilientMediaStorageService.php * Update ImageS3UploadPipeline.php * Larastan: Update Profile.php missing "use App\Avatar;" * Larastan: Update MediaStorageService.php * Larastan: Update MediaPathService.php * Update MediaPathService.php * Update MediaStorageService.php * Update ImageS3UploadPipeline.php * Larastan: Update AddUserDomainBlock.php ``` ------ ------------------------------------------------------------- Line Console/Commands/AddUserDomainBlock.php ------ ------------------------------------------------------------- 37 Variable $domain in empty() always exists and is not falsy. 🪪 empty.variable ------ ------------------------------------------------------------- ``` * Larastan: Update CatchUnoptimizedMedia.php ``` ------ ------------------------------------------------------------------------------------------------- Line Console/Commands/CatchUnoptimizedMedia.php ------ ------------------------------------------------------------------------------------------------- 31 Constructor of class App\Console\Commands\CatchUnoptimizedMedia has an unused parameter $media. 🪪 constructor.unusedParameter ------ ------------------------------------------------------------------------------------------------- ``` * Update DeleteUserDomainBlock.php * Update StatusHashtag.php * Update FixLikes.php * Update User.php * Update Installer.php * Update SeedFollows.php * Update DiscoverCategory.php * Update FollowRequest.php * Update Follower.php * Update AccountController.php * Update CustomFilterKeyword.php * Update FederationController.php * Update Inbox.php * Update HttpSignature.php --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: Shlee <github@shl.ee>
2 weeks ago
use App\Profile;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use NotificationChannels\WebPush\HasPushSubscriptions;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, HasPushSubscriptions, Notifiable, SoftDeletes, UserRateLimit;
8 years ago
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected function casts(): array
{
return [
'deleted_at' => 'datetime',
'email_verified_at' => 'datetime',
'2fa_setup_at' => 'datetime',
'last_active_at' => 'datetime',
];
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'username',
'email',
'password',
'app_register_ip',
'email_verified_at',
'last_active_at',
'register_source',
'expo_token',
'notify_enabled',
'notify_like',
'notify_follow',
'notify_mention',
'notify_comment',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'email', 'password', 'is_admin', 'remember_token',
'email_verified_at', '2fa_enabled', '2fa_secret',
'2fa_backup_codes', '2fa_setup_at', 'deleted_at',
'updated_at',
];
public function profile()
{
return $this->hasOne(Profile::class);
}
public function url()
{
return url(config('app.url').'/'.$this->username);
}
public function settings()
{
return $this->hasOne(UserSetting::class);
}
public function statuses()
{
return $this->hasManyThrough(
Status::class,
Profile::class
);
}
public function filters()
{
return $this->hasMany(UserFilter::class, 'user_id', 'profile_id');
}
public function receivesBroadcastNotificationsOn()
{
return 'App.User.'.$this->id;
}
public function devices()
{
return $this->hasMany(UserDevice::class);
}
public function storageUsedKey()
{
return 'profile:storage:used:'.$this->id;
}
public function accountLog()
{
return $this->hasMany(AccountLog::class);
}
public function interstitials()
{
return $this->hasMany(AccountInterstitial::class);
}
public function avatarUrl()
{
if (! $this->profile_id || $this->status) {
return config('app.url').'/storage/avatars/default.jpg';
}
return AvatarService::get($this->profile_id);
}
public function routeNotificationForExpo()
{
return $this->expo_token;
}
}