Friend
extends Model
in package
Uses
SoftDelete, Timezonable
Clake\Userextended\Models\Friend
Tags
Table of Contents
- $accepted : int
- $attachMany : mixed
- $attachOne : mixed
- $belongsTo : mixed
- $belongsToMany : mixed
- $created_at : Carbon|null
- $deleted_at : Carbon|null
- $hasMany : mixed
- $hasOne : array<string|int, mixed>
- $id : int
- $morphMany : mixed
- $morphOne : mixed
- $morphTo : mixed
- $relation : int
- $table : string
- $updated_at : Carbon|null
- $user_that_accepted_request : int
- $user_that_sent_request : int
- $dates : mixed
- $fillable : array<string|int, mixed>
- $forceDeleting : bool
- Indicates if the model is currently force deleting.
- $guarded : array<string|int, mixed>
- $timezonable : mixed
- addUsers() : $this
- Easy method for adding sender and receiver or either or to the model Also handles resetting these fields if need be by leaving params blank
- all() :
- beforeCreate() : bool
- Checks whether a relation exists, if it does, don't create another
- blocked() :
- blocks() :
- bootSoftDelete() : void
- Boot the soft deleting trait for a model.
- bootTimezonable() : mixed
- Called by the system on runtime, Binds an event to the model to adjust timezones
- declined() :
- flushBonds() : mixed
- Flushes all bonds Removes any relation between two users
- follow() :
- followers() :
- following() :
- forceDelete() : void
- Force a hard delete on a soft deleted model.
- friend() :
- friendRequests() :
- friends() :
- get() :
- getAllRelations() : array<string|int, mixed>
- Returns a collection of all the relations a user has with another user
- getBondStates() : array<string|int, mixed>
- Returns all of the bond states which exist in the project
- getDeletedAtColumn() : string
- Get the name of the "deleted at" column.
- getHighestRelation() : array<string|int, mixed>|int
- Returns the highest priority set relation, this is useful in cases where we need to utilize overrides
- getQualifiedDeletedAtColumn() : string
- Get the fully qualified "deleted at" column.
- getTime() : mixed
- Returns a timestamp adjusted by the logged in users Timezone
- getTimezonableAttributes() : array<string|int, mixed>
- Returns a collection of fields that will be encrypted.
- hasBond() : bool
- Determines whether a bond exists between two users
- isBlocked() : bool
- Returns whether or not two users are blocked from each other
- isBond() : bool
- Returns whether or not two users share a specific bond between them
- isDeclined() : bool
- Returns whether or not two users have a declined friend request between them.
- isFriends() : bool
- Returns whether or not two users are friends
- isRelationExists() : bool
- Returns whether or not two users share a relation or bond
- isRequested() : bool
- Returns whether or not two users have a friend request between them
- isSoftDelete() : bool
- Helper method to check if the model is currently being hard or soft deleted, useful in events.
- newModelQuery() :
- newQuery() :
- notMe() :
- onlyTrashed() : Builder|static
- Get a new query builder that only includes soft deletes.
- otherUser() : mixed
- Returns the other user ID in a row
- pluckReceiver() :
- pluckSender() :
- query() :
- receivedRelations() :
- receiver() :
- relation() :
- relations() :
- removeBond() : mixed
- Removes a bond between two users
- request() :
- restore() : bool|null
- Restore a soft-deleted model instance.
- restored() : void
- Register a restored model event with the dispatcher.
- restoring() : void
- Register a restoring model event with the dispatcher.
- scopeBlocked() : mixed
- Scopes to the relation where two users are blocked
- scopeBlocks() : mixed
- Scopes to users who are 'blocked' from each other
- scopeDeclined() : mixed
- Checks whether or not a friend request between users was declined. Run count on result, if >0 then they are.
- scopeFollow() : array<string|int, mixed>|mixed
- Scopes to the relation where a user is following another
- scopeFollowers() : array<string|int, mixed>
- Scopes to a users followers
- scopeFollowing() : array<string|int, mixed>
- Scopes to a collection of users a user is following
- scopeFriend() : mixed
- Determines whether or not two users are friends. Run count on the result. If >0 then they are.
- scopeFriendRequests() : mixed
- Scopes to friend requests received by the passed in user. Takes logged in user if none are passed.
- scopeFriends() : mixed
- Scopes to the friends the passed in user has. Takes logged in user if none are passed.
- scopeNotMe() : mixed
- Returns the other user ID in a row
- scopePluckReceiver() : mixed
- Will retrieve only the receiver
- scopePluckSender() : mixed
- Will retrieve only the sender
- scopeReceivedRelations() : mixed
- Scopes to all relaitons where a user received the relation
- scopeReceiver() : mixed
- Checks whether the receiver is the user specified
- scopeRelation() : mixed
- Scopes to the relation between two users
- scopeRelations() : mixed
- Scopes to all relations with a user involved
- scopeRequest() : mixed
- Checks whether or not a friend request between two users exists Can find sender and acceptor by examining the returned object using ->get() on the result
- scopeSender() : mixed
- Checks whether the sender is the user specified
- scopeSentRelations() : mixed
- Scopes to all relations where a user initiated the relation
- scopeSentRequests() : mixed
- Scopes to friend requests sent by the passed in user. Takes logged in user if none are passed.
- scopeSubscribers() : array<string|int, mixed>
- Scopes to a collection of a users subscribers
- scopeSubscription() : array<string|int, mixed>|mixed
- Scopes to the relation where a user is subscribed to another
- scopeSubscriptions() : array<string|int, mixed>
- Scopes to a collection of a users subscriptions
- sender() :
- sentRelations() :
- sentRequests() :
- setBond() : mixed
- Sets bonds between two users
- setExclusiveBond() : mixed
- Flushes all bonds and then sets the bonds passed in
- setStatus() : mixed
- Sets the accepted field in the model.
- subscribers() :
- subscription() :
- subscriptions() :
- swapUsers() : Friends
- Swaps the sender and receiver fields of the model
- timezonify() : mixed
- Returns a timestamp adjusted by the logged in users Timezone Alias for getTime()
- trashed() : bool
- Determine if the model instance has been soft-deleted.
- whereAccepted() :
- whereCreatedAt() :
- whereDeletedAt() :
- whereId() :
- whereRelation() :
- whereUpdatedAt() :
- whereUserThatAcceptedRequest() :
- whereUserThatSentRequest() :
- withTrashed() : Builder|static
- Get a new query builder that includes soft deletes.
- performDeleteOnModel() : mixed
- Perform the actual delete query on this model instance.
- performRestoreOnRelations() : void
- Locates relations with softDelete flag and cascades the restore event.
- performSoftDeleteOnRelations() : void
- Locates relations with softDelete flag and cascades the delete event.
- runSoftDelete() : void
- Perform the actual delete query on this model instance.
- filterRelation() : array<string|int, mixed>|mixed
- Returns a relation model that has been filtered via a passed in closure function
- filterRelations() : array<string|int, mixed>
- Returns a collection of relation models which have been filtered via a passed in closure function
Properties
$accepted
public
int
$accepted
$attachMany
public
mixed
$attachMany
= []
$attachOne
public
mixed
$attachOne
= []
$belongsTo
public
mixed
$belongsTo
= ['sender' => ['Clake\UserExtended\Models\UserExtended', 'key' => 'user_that_sent_request', 'otherKey' => 'id'], 'acceptor' => ['Clake\UserExtended\Models\UserExtended', 'key' => 'user_that_accepted_request', 'otherKey' => 'id']]
$belongsToMany
public
mixed
$belongsToMany
= []
$created_at
public
Carbon|null
$created_at
$deleted_at
public
Carbon|null
$deleted_at
$hasMany
public
mixed
$hasMany
= []
$hasOne
public
array<string|int, mixed>
$hasOne
= []
Relations
$id
public
int
$id
$morphMany
public
mixed
$morphMany
= []
$morphOne
public
mixed
$morphOne
= []
$morphTo
public
mixed
$morphTo
= []
$relation
public
int
$relation
$table
public
string
$table
= 'clake_userextended_friends'
The database table used by the model.
$updated_at
public
Carbon|null
$updated_at
$user_that_accepted_request
public
int
$user_that_accepted_request
$user_that_sent_request
public
int
$user_that_sent_request
$dates
protected
mixed
$dates
= ['deleted_at']
$fillable
protected
array<string|int, mixed>
$fillable
= ['user_that_sent_request', 'user_that_accepted_request', 'accepted']
Fillable fields
$forceDeleting
Indicates if the model is currently force deleting.
protected
bool
$forceDeleting
= false
$guarded
protected
array<string|int, mixed>
$guarded
= ['*']
Guarded fields
$timezonable
protected
mixed
$timezonable
= ['created_at', 'updated_at']
Methods
addUsers()
Easy method for adding sender and receiver or either or to the model Also handles resetting these fields if need be by leaving params blank
public
addUsers([null $sender = null ][, null $receiver = null ]) : $this
Parameters
- $sender : null = null
- $receiver : null = null
Return values
$this —all()
public
static all(mixed $columns) :
Parameters
- $columns : mixed
Return values
—beforeCreate()
Checks whether a relation exists, if it does, don't create another
public
beforeCreate() : bool
Return values
bool —blocked()
public
static blocked(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—blocks()
public
static blocks(mixed $userId) :
Parameters
- $userId : mixed
Return values
—bootSoftDelete()
Boot the soft deleting trait for a model.
public
static bootSoftDelete() : void
Return values
void —bootTimezonable()
Called by the system on runtime, Binds an event to the model to adjust timezones
public
static bootTimezonable() : mixed
Tags
Return values
mixed —declined()
public
static declined(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—flushBonds()
Flushes all bonds Removes any relation between two users
public
flushBonds() : mixed
Return values
mixed —follow()
public
static follow(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—followers()
public
static followers(mixed $userId) :
Parameters
- $userId : mixed
Return values
—following()
public
static following(mixed $userId) :
Parameters
- $userId : mixed
Return values
—forceDelete()
Force a hard delete on a soft deleted model.
public
forceDelete() : void
Return values
void —friend()
public
static friend(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—friendRequests()
public
static friendRequests(mixed $userId) :
Parameters
- $userId : mixed
Return values
—friends()
public
static friends(mixed $userId) :
Parameters
- $userId : mixed
Return values
—get()
public
static get(mixed $columns) :
Parameters
- $columns : mixed
Return values
—getAllRelations()
Returns a collection of all the relations a user has with another user
public
static getAllRelations( $userIdA[, null $userIdB = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —getBondStates()
Returns all of the bond states which exist in the project
public
getBondStates() : array<string|int, mixed>
Return values
array<string|int, mixed> —getDeletedAtColumn()
Get the name of the "deleted at" column.
public
getDeletedAtColumn() : string
Return values
string —getHighestRelation()
Returns the highest priority set relation, this is useful in cases where we need to utilize overrides
public
static getHighestRelation( $userIdA[, null $userIdB = null ]) : array<string|int, mixed>|int
Parameters
Return values
array<string|int, mixed>|int —getQualifiedDeletedAtColumn()
Get the fully qualified "deleted at" column.
public
getQualifiedDeletedAtColumn() : string
Return values
string —getTime()
Returns a timestamp adjusted by the logged in users Timezone
public
getTime( $timestamp[, UserExtended|null $user = null ]) : mixed
Parameters
- $timestamp :
- $user : UserExtended|null = null
Return values
mixed —getTimezonableAttributes()
Returns a collection of fields that will be encrypted.
public
getTimezonableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —hasBond()
Determines whether a bond exists between two users
public
hasBond( $relation_state) : bool
Parameters
Return values
bool —isBlocked()
Returns whether or not two users are blocked from each other
public
static isBlocked( $userIdA[, null $userIdB = null ]) : bool
Parameters
Return values
bool —isBond()
Returns whether or not two users share a specific bond between them
public
static isBond( $bondType, $userIdA[, null $userIdB = null ]) : bool
Parameters
Return values
bool —isDeclined()
Returns whether or not two users have a declined friend request between them.
public
static isDeclined( $userIdA[, null $userIdB = null ]) : bool
Parameters
Return values
bool —isFriends()
Returns whether or not two users are friends
public
static isFriends( $userIdA[, $userIdB = null ]) : bool
Parameters
Return values
bool —isRelationExists()
Returns whether or not two users share a relation or bond
public
static isRelationExists( $userIdA[, null $userIdB = null ]) : bool
Parameters
Return values
bool —isRequested()
Returns whether or not two users have a friend request between them
public
static isRequested( $userIdA[, null $userIdB = null ]) : bool
Parameters
Return values
bool —isSoftDelete()
Helper method to check if the model is currently being hard or soft deleted, useful in events.
public
isSoftDelete() : bool
Return values
bool —newModelQuery()
public
static newModelQuery() :
Return values
—newQuery()
public
static newQuery() :
Return values
—notMe()
public
static notMe(mixed $userId) :
Parameters
- $userId : mixed
Return values
—onlyTrashed()
Get a new query builder that only includes soft deletes.
public
static onlyTrashed() : Builder|static
Return values
Builder|static —otherUser()
Returns the other user ID in a row
public
otherUser([null $userId = null ]) : mixed
Parameters
- $userId : null = null
Return values
mixed —pluckReceiver()
public
static pluckReceiver() :
Return values
—pluckSender()
public
static pluckSender() :
Return values
—query()
public
static query() :
Return values
—receivedRelations()
public
static receivedRelations(mixed $userId) :
Parameters
- $userId : mixed
Return values
—receiver()
public
static receiver(mixed $userId) :
Parameters
- $userId : mixed
Return values
—relation()
public
static relation(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—relations()
public
static relations(mixed $userId) :
Parameters
- $userId : mixed
Return values
—removeBond()
Removes a bond between two users
public
removeBond( $relation_states) : mixed
Parameters
Return values
mixed —request()
public
static request(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—restore()
Restore a soft-deleted model instance.
public
restore() : bool|null
Return values
bool|null —restored()
Register a restored model event with the dispatcher.
public
static restored(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —restoring()
Register a restoring model event with the dispatcher.
public
static restoring(Closure|string $callback) : void
Parameters
- $callback : Closure|string
Return values
void —scopeBlocked()
Scopes to the relation where two users are blocked
public
scopeBlocked( $query, $userIdA[, null $userIdB = null ]) : mixed
Parameters
Return values
mixed —scopeBlocks()
Scopes to users who are 'blocked' from each other
public
scopeBlocks( $query[, null $userId = null ]) : mixed
Parameters
Return values
mixed —scopeDeclined()
Checks whether or not a friend request between users was declined. Run count on result, if >0 then they are.
public
scopeDeclined( $query, $userIdA[, null $userIdB = null ]) : mixed
Can find sender and acceptor by examining the returned object using ->get() on the result
Parameters
Return values
mixed —scopeFollow()
Scopes to the relation where a user is following another
public
scopeFollow( $query, $userIdA[, null $userIdB = null ]) : array<string|int, mixed>|mixed
Parameters
Return values
array<string|int, mixed>|mixed —scopeFollowers()
Scopes to a users followers
public
scopeFollowers( $query[, null $userId = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —scopeFollowing()
Scopes to a collection of users a user is following
public
scopeFollowing( $query[, null $userId = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —scopeFriend()
Determines whether or not two users are friends. Run count on the result. If >0 then they are.
public
scopeFriend( $query, $userIdA[, $userIdB = null ]) : mixed
Can find sender and acceptor by examining the returned object using ->get() on the result
Parameters
Return values
mixed —scopeFriendRequests()
Scopes to friend requests received by the passed in user. Takes logged in user if none are passed.
public
scopeFriendRequests( $query[, null $userId = null ]) : mixed
Parameters
Return values
mixed —scopeFriends()
Scopes to the friends the passed in user has. Takes logged in user if none are passed.
public
scopeFriends( $query[, null $userId = null ]) : mixed
Parameters
Return values
mixed —scopeNotMe()
Returns the other user ID in a row
public
scopeNotMe( $query[, null $userId = null ]) : mixed
Parameters
Return values
mixed —scopePluckReceiver()
Will retrieve only the receiver
public
scopePluckReceiver( $query) : mixed
Parameters
Return values
mixed —scopePluckSender()
Will retrieve only the sender
public
scopePluckSender( $query) : mixed
Parameters
Return values
mixed —scopeReceivedRelations()
Scopes to all relaitons where a user received the relation
public
scopeReceivedRelations( $query, $userId) : mixed
Parameters
Return values
mixed —scopeReceiver()
Checks whether the receiver is the user specified
public
scopeReceiver( $query[, $userId = null ]) : mixed
Parameters
Return values
mixed —scopeRelation()
Scopes to the relation between two users
public
scopeRelation( $query, $userIdA[, null $userIdB = null ]) : mixed
Parameters
Return values
mixed —scopeRelations()
Scopes to all relations with a user involved
public
scopeRelations( $query, $userId) : mixed
Parameters
Return values
mixed —scopeRequest()
Checks whether or not a friend request between two users exists Can find sender and acceptor by examining the returned object using ->get() on the result
public
scopeRequest( $query, $userIdA[, null $userIdB = null ]) : mixed
Parameters
Return values
mixed —scopeSender()
Checks whether the sender is the user specified
public
scopeSender( $query[, $userId = null ]) : mixed
Parameters
Return values
mixed —scopeSentRelations()
Scopes to all relations where a user initiated the relation
public
scopeSentRelations( $query, $userId) : mixed
Parameters
Return values
mixed —scopeSentRequests()
Scopes to friend requests sent by the passed in user. Takes logged in user if none are passed.
public
scopeSentRequests( $query[, null $userId = null ]) : mixed
Parameters
Return values
mixed —scopeSubscribers()
Scopes to a collection of a users subscribers
public
scopeSubscribers( $query[, null $userId = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —scopeSubscription()
Scopes to the relation where a user is subscribed to another
public
scopeSubscription( $query, $userIdA[, null $userIdB = null ]) : array<string|int, mixed>|mixed
Parameters
Return values
array<string|int, mixed>|mixed —scopeSubscriptions()
Scopes to a collection of a users subscriptions
public
scopeSubscriptions( $query[, null $userId = null ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —sender()
public
static sender(mixed $userId) :
Parameters
- $userId : mixed
Return values
—sentRelations()
public
static sentRelations(mixed $userId) :
Parameters
- $userId : mixed
Return values
—sentRequests()
public
static sentRequests(mixed $userId) :
Parameters
- $userId : mixed
Return values
—setBond()
Sets bonds between two users
public
setBond( $relation_states) : mixed
Parameters
Return values
mixed —setExclusiveBond()
Flushes all bonds and then sets the bonds passed in
public
setExclusiveBond( $relation_states) : mixed
Parameters
Return values
mixed —setStatus()
Sets the accepted field in the model.
public
setStatus( $status) : mixed
0 => Request sent 1 => Friend Accepted 2 => Friend Declined 3 => Blocked
Parameters
Tags
Return values
mixed —subscribers()
public
static subscribers(mixed $userId) :
Parameters
- $userId : mixed
Return values
—subscription()
public
static subscription(mixed $userIdA, mixed $userIdB) :
Parameters
- $userIdA : mixed
- $userIdB : mixed
Return values
—subscriptions()
public
static subscriptions(mixed $userId) :
Parameters
- $userId : mixed
Return values
—swapUsers()
Swaps the sender and receiver fields of the model
public
swapUsers() : Friends
Return values
Friends —timezonify()
Returns a timestamp adjusted by the logged in users Timezone Alias for getTime()
public
timezonify( $timestamp) : mixed
Parameters
Return values
mixed —trashed()
Determine if the model instance has been soft-deleted.
public
trashed() : bool
Return values
bool —whereAccepted()
public
static whereAccepted(mixed $value) :
Parameters
- $value : mixed
Return values
—whereCreatedAt()
public
static whereCreatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereDeletedAt()
public
static whereDeletedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereId()
public
static whereId(mixed $value) :
Parameters
- $value : mixed
Return values
—whereRelation()
public
static whereRelation(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUpdatedAt()
public
static whereUpdatedAt(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUserThatAcceptedRequest()
public
static whereUserThatAcceptedRequest(mixed $value) :
Parameters
- $value : mixed
Return values
—whereUserThatSentRequest()
public
static whereUserThatSentRequest(mixed $value) :
Parameters
- $value : mixed
Return values
—withTrashed()
Get a new query builder that includes soft deletes.
public
static withTrashed() : Builder|static
Return values
Builder|static —performDeleteOnModel()
Perform the actual delete query on this model instance.
protected
performDeleteOnModel() : mixed
Return values
mixed —performRestoreOnRelations()
Locates relations with softDelete flag and cascades the restore event.
protected
performRestoreOnRelations() : void
Return values
void —performSoftDeleteOnRelations()
Locates relations with softDelete flag and cascades the delete event.
protected
performSoftDeleteOnRelations() : void
Return values
void —runSoftDelete()
Perform the actual delete query on this model instance.
protected
runSoftDelete() : void
Return values
void —filterRelation()
Returns a relation model that has been filtered via a passed in closure function
private
filterRelation( $closure, $query, $userIdA[, null $userIdB = null ]) : array<string|int, mixed>|mixed
Parameters
Return values
array<string|int, mixed>|mixed —filterRelations()
Returns a collection of relation models which have been filtered via a passed in closure function
private
filterRelations( $closure, $query, $userId[, string $direction = '' ]) : array<string|int, mixed>