WowPress-Tailwind/theme/wowpress/Models/Notification.php

35 lines
852 B
PHP
Raw Permalink Normal View History

2024-06-27 23:06:15 +02:00
<?php
namespace WoWPress\Models;
use Wenprise\Eloquent\Model;
class Notification extends Model{
protected $table = "wowpress_notifications";
public $timestamps = true;
protected $primaryKey = 'ID';
protected $guarded = ['ID'];
public static function addNotification($user_id,$note_text){
$note = new Notification();
$note->user_id = $user_id;
$note->note = $note_text;
$note->save();
}
2024-08-07 22:34:54 +02:00
public static function addCapabilityNotification($capability,$note_text){
$users = get_users(array(
'capability' => $capability,
));
foreach($users as $user){
Notification::addNotification($user->ID, $note_text);
}
}
2024-06-27 23:06:15 +02:00
public static function getAll(){
return Notification::where('user_id',get_current_user_id())->get();
}
}