|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
fix: add return type declarations to Eloquent relation methods
Larastan 3.x requires explicit return types on relation methods to
verify relation existence when using with(), has(), etc. This adds
the appropriate return type declarations to all relation methods
flagged by the larastan.relationExistence rule.
Models fixed:
- Profile (avatar, statuses)
- User (profile)
- Status (profile, media, hashtags)
- DirectMessage (status, author, recipient)
- Report (reporter, status, reportedUser)
- Like (actor, status)
- Media (status)
- Notification (item)
- HashtagFollow (hashtag)
- OauthClient (user)
- Story (profile)
- StatusHashtag (status, hashtag, profile, media)
- AccountInterstitial (user)
- Hashtag (posts)
- CustomFilter (keywords)
- CustomFilterKeyword (customFilter)
- AdminShadowFilter (profile)
- ImportPost (status)
4 weeks ago
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @property int $id
|
|
|
|
|
* @property int $profile_id
|
|
|
|
|
* @property int|null $actor_id
|
|
|
|
|
* @property int|null $item_id
|
|
|
|
|
* @property string|null $item_type
|
|
|
|
|
* @property string|null $action
|
|
|
|
|
* @property string|null $read_at
|
|
|
|
|
* @property Carbon|null $created_at
|
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
|
* @property Carbon|null $deleted_at
|
|
|
|
|
* @property-read Profile|null $actor
|
|
|
|
|
* @property-read Model|\Eloquent|null $item
|
|
|
|
|
* @property-read Profile|null $profile
|
|
|
|
|
* @property-read Status|null $status
|
|
|
|
|
* @property-read MediaTag|null $tag
|
|
|
|
|
*
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newModelQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification newQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification onlyTrashed()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification query()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereAction($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereActorId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereCreatedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereDeletedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereItemId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereItemType($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereProfileId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereReadAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification whereUpdatedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withTrashed(bool $withTrashed = true)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Notification withoutTrashed()
|
|
|
|
|
*
|
|
|
|
|
* @mixin \Eloquent
|
|
|
|
|
*/
|
|
|
|
|
class Notification extends Model
|
|
|
|
|
{
|
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $guarded = [];
|
|
|
|
|
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'deleted_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function actor()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Profile::class, 'actor_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function profile()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Profile::class, 'profile_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
fix: add return type declarations to Eloquent relation methods
Larastan 3.x requires explicit return types on relation methods to
verify relation existence when using with(), has(), etc. This adds
the appropriate return type declarations to all relation methods
flagged by the larastan.relationExistence rule.
Models fixed:
- Profile (avatar, statuses)
- User (profile)
- Status (profile, media, hashtags)
- DirectMessage (status, author, recipient)
- Report (reporter, status, reportedUser)
- Like (actor, status)
- Media (status)
- Notification (item)
- HashtagFollow (hashtag)
- OauthClient (user)
- Story (profile)
- StatusHashtag (status, hashtag, profile, media)
- AccountInterstitial (user)
- Hashtag (posts)
- CustomFilter (keywords)
- CustomFilterKeyword (customFilter)
- AdminShadowFilter (profile)
- ImportPost (status)
4 weeks ago
|
|
|
public function item(): MorphTo
|
|
|
|
|
{
|
|
|
|
|
return $this->morphTo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function status()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Status::class, 'item_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function tag()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(MediaTag::class, 'item_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
}
|