-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.php
More file actions
53 lines (46 loc) · 1.2 KB
/
Model.php
File metadata and controls
53 lines (46 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// Import additionnal class into the global namespace
use \LaswitchTech\Core\Base\BaseModel;
class NotificationsModel extends BaseModel {
/**
* Constructor
*/
public function __construct()
{
// Call the parent constructor
parent::__construct();
// Initialize the Model
$this->init('notifications');
}
/**
* Apply Joins to the Query
*
* @param Query $Query
* @return Query
*/
protected function joins(object $Query): object
{
// Apply Joins
$Query->join('assignedTo', 'users', 'id');
return $Query;
}
/**
* Create a Notification
* @param int $assignedTo
* @param string $title
* @param string $content
* @param string|null $link
* @param string $category
* @return int
*/
public function notify(int $assignedTo, string $title, string $content, string $link = null, string $category = "System"): int
{
return $this->create([
'assignedTo' => $assignedTo,
'title' => $title,
'content' => $content,
'link' => $link,
'category' => $category,
]);
}
}