datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.0 KiB
52 lines
1.0 KiB
7 years ago
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
/**
|
||
|
* Notification received by a user
|
||
|
*/
|
||
|
class Notification extends Model
|
||
|
{
|
||
|
/** Recipient user */
|
||
|
public function user()
|
||
|
{
|
||
|
return $this->belongsTo(User::class, 'user_id');
|
||
|
}
|
||
|
|
||
|
/** User who triggered this notification */
|
||
|
public function actor()
|
||
|
{
|
||
|
return $this->belongsTo(User::class, 'actor_id');
|
||
|
}
|
||
|
|
||
|
/** Notification context (what was affected) */
|
||
|
public function context()
|
||
|
{
|
||
|
return $this->morphTo();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Unseen notifications
|
||
|
*
|
||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||
|
*/
|
||
|
public function scopeUnseen($query)
|
||
|
{
|
||
|
return $query->where('seen', false);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Seen notifications
|
||
|
*
|
||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||
|
*/
|
||
|
public function scopeSeen($query)
|
||
|
{
|
||
|
return $query->where('seen', true);
|
||
|
}
|
||
|
}
|