Activity extends Model
Activity Class.
Represents a single user activity at a specified point in time.
Tags
Table of Contents
$table | string | |
---|---|---|
$fillable | ||
$ip_address | string | |
$user_id | int | |
$type | string | |
$occurred_at | datetime | |
$description | string | |
$ci | ContainerInterface | |
$timestamps | bool | |
$manyMethodsExtended | The many to many relationship methods. | array |
scopeJoinUser() | Joins the activity's user, so we can do things like sort, search, paginate, etc. | mixed |
scopeMostRecentEvents() | Add clauses to select the most recent event of each type for each user, to the query. | Builder |
scopeMostRecentEventsByType() | Add clauses to select the most recent event of a given type for each user, to the query. | Builder |
user() | Get the user associated with this activity. | BelongsTo |
__construct() | mixed | |
attributeExists() | Determine if an attribute exists on the model - even if it is null. | bool |
findUnique() | Determines whether a model exists by checking a unique column, including checking soft-deleted records. | Model|null |
relationExists() | Determine if an relation exists on the model - even if it is null. | bool |
store() | Store the object in the DB, creating a new row if one doesn't already exist. | int |
newEloquentBuilder() | Overrides Laravel's base Model to return our custom Eloquent builder object. | EloquentBuilder |
newBaseQueryBuilder() | Overrides Laravel's base Model to return our custom query builder object. | Builder |
export() | Get the properties of this object as an associative array. Alias for toArray(). | array |
queryBuilder() | For raw array fetching. Must be static, otherwise PHP gets confused about where to find $table. | Builder |
hasMany() | Overrides the default Eloquent hasMany relationship to return a HasManySyncable. | HasManySyncable |
morphMany() | Overrides the default Eloquent morphMany relationship to return a MorphManySyncable. | MorphManySyncable |
belongsToManyThrough() | Define a many-to-many 'through' relationship. | BelongsToManyThrough |
belongsToManyUnique() | Define a unique many-to-many relationship. Similar to a regular many-to-many relationship, but removes duplicate child objects. | BelongsToManyUnique |
morphToManyUnique() | Define a unique morphs-to-many relationship. Similar to a regular morphs-to-many relationship, but removes duplicate child objects. | MorphToManyUnique |
getBelongsToManyCaller() | Get the relationship name of the belongs to many. | string |
Properties
$table
protected
string
$table
= 'activities'
$fillable
protected
mixed
$fillable
= ['ip_address', 'user_id', 'type', 'occurred_at', 'description']
$ip_address
public
string
$ip_address
$user_id
public
int
$user_id
$type
public
string
$type
$occurred_at
public
datetime
$occurred_at
$description
public
string
$description
$ci
public
static ContainerInterface
$ci
$timestamps
public
bool
$timestamps
= false
$manyMethodsExtended
The many to many relationship methods.
public
static array
$manyMethodsExtended
= ['belongsToMany', 'morphToMany', 'morphedByMany', 'morphToManyUnique']
Methods
scopeJoinUser()
Joins the activity's user, so we can do things like sort, search, paginate, etc.
public
scopeJoinUser(
$query :
Builder
)
: mixed
Parameters
- $query : Builder
Return values
mixedscopeMostRecentEvents()
Add clauses to select the most recent event of each type for each user, to the query.
public
scopeMostRecentEvents(
$query :
Builder
)
: Builder
Parameters
- $query : Builder
Return values
BuilderscopeMostRecentEventsByType()
Add clauses to select the most recent event of a given type for each user, to the query.
public
scopeMostRecentEventsByType(
$query :
Builder
, $type :
string
)
: Builder
Parameters
- $query : Builder
- $type : string
The type of event, matching the
event_type
field in the user_event table.
Return values
Builderuser()
Get the user associated with this activity.
public
user(
)
: BelongsTo
Return values
BelongsTo__construct()
public
__construct(
[ $attributes :
array
= [] ]
)
: mixed
Parameters
- $attributes : array = []
Return values
mixedattributeExists()
Determine if an attribute exists on the model - even if it is null.
public
attributeExists(
$key :
string
)
: bool
Parameters
- $key : string
Return values
boolfindUnique()
Determines whether a model exists by checking a unique column, including checking soft-deleted records.
public
static findUnique(
$value :
mixed
, $identifier :
string
[, $checkDeleted :
bool
= true ]
)
: Model|null
Parameters
- $value : mixed
- $identifier : string
- $checkDeleted : bool = true
set to true to include soft-deleted records
Return values
Model|nullrelationExists()
Determine if an relation exists on the model - even if it is null.
public
relationExists(
$key :
string
)
: bool
Parameters
- $key : string
Return values
boolstore()
Store the object in the DB, creating a new row if one doesn't already exist.
public
store(
)
: int
Calls save(), then returns the id of the new record in the database.
Return values
int —the id of this object.
newEloquentBuilder()
Overrides Laravel's base Model to return our custom Eloquent builder object.
public
newEloquentBuilder(
$query :
Builder
)
: EloquentBuilder
Parameters
- $query : Builder
Return values
EloquentBuildernewBaseQueryBuilder()
Overrides Laravel's base Model to return our custom query builder object.
protected
newBaseQueryBuilder(
)
: Builder
Return values
Builderexport()
Get the properties of this object as an associative array. Alias for toArray().
public
export(
)
: array
Tags
Return values
arrayqueryBuilder()
For raw array fetching. Must be static, otherwise PHP gets confused about where to find $table.
public
static queryBuilder(
)
: Builder
Tags
Return values
BuilderhasMany()
Overrides the default Eloquent hasMany relationship to return a HasManySyncable.
public
hasMany(
$related :
string
[, $foreignKey :
string
= null ]
[, $localKey :
string
= null ]
)
: HasManySyncable
Parameters
- $related : string
- $foreignKey : string = null
- $localKey : string = null
Return values
HasManySyncablemorphMany()
Overrides the default Eloquent morphMany relationship to return a MorphManySyncable.
public
morphMany(
$related :
string
, $name :
string
[, $type :
string
= null ]
[, $id :
string
= null ]
[, $localKey :
string
= null ]
)
: MorphManySyncable
Parameters
- $related : string
- $name : string
- $type : string = null
- $id : string = null
- $localKey : string = null
Return values
MorphManySyncablebelongsToManyThrough()
Define a many-to-many 'through' relationship.
public
belongsToManyThrough(
$related :
string
, $through :
string
[, $firstJoiningTable :
string
= null ]
[, $firstForeignPivotKey :
string
= null ]
[, $firstRelatedKey :
string
= null ]
[, $secondJoiningTable :
string
= null ]
[, $secondForeignPivotKey :
string
= null ]
[, $secondRelatedKey :
string
= null ]
[, $throughRelation :
string
= null ]
[, $relation :
string
= null ]
)
: BelongsToManyThrough
This is basically hasManyThrough for many-to-many relationships.
Parameters
- $related : string
- $through : string
- $firstJoiningTable : string = null
- $firstForeignPivotKey : string = null
- $firstRelatedKey : string = null
- $secondJoiningTable : string = null
- $secondForeignPivotKey : string = null
- $secondRelatedKey : string = null
- $throughRelation : string = null
- $relation : string = null
Return values
BelongsToManyThroughbelongsToManyUnique()
Define a unique many-to-many relationship. Similar to a regular many-to-many relationship, but removes duplicate child objects.
public
belongsToManyUnique(
$related :
string
[, $table :
string
= null ]
[, $foreignPivotKey :
string
= null ]
[, $relatedPivotKey :
string
= null ]
[, $parentKey :
string
= null ]
[, $relatedKey :
string
= null ]
[, $relation :
string
= null ]
)
: BelongsToManyUnique
Can also be used to implement ternary relationships.
Parameters
- $related : string
- $table : string = null
- $foreignPivotKey : string = null
- $relatedPivotKey : string = null
- $parentKey : string = null
- $relatedKey : string = null
- $relation : string = null
Return values
BelongsToManyUniquemorphToManyUnique()
Define a unique morphs-to-many relationship. Similar to a regular morphs-to-many relationship, but removes duplicate child objects.
public
morphToManyUnique(
$related :
string
, $name :
string
[, $table :
string
= null ]
[, $foreignPivotKey :
string
= null ]
[, $relatedPivotKey :
string
= null ]
[, $parentKey :
string
= null ]
[, $relatedKey :
string
= null ]
[, $inverse :
bool
= false ]
)
: MorphToManyUnique
Parameters
- $related : string
- $name : string
- $table : string = null
- $foreignPivotKey : string = null
- $relatedPivotKey : string = null
- $parentKey : string = null
- $relatedKey : string = null
- $inverse : bool = false
Return values
MorphToManyUniquegetBelongsToManyCaller()
Get the relationship name of the belongs to many.
protected
getBelongsToManyCaller(
)
: string