parent
f12773ccd1
commit
25cb60d377
@ -1,51 +0,0 @@ |
||||
<?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); |
||||
} |
||||
} |
Loading…
Reference in new issue