|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Canvas\Api\Controllers; |
|
6
|
|
|
|
|
7
|
|
|
use Canvas\Models\Notifications; |
|
8
|
|
|
use Canvas\Dto\Notification; |
|
9
|
|
|
use Canvas\Mapper\NotificationMapper; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class LanguagesController. |
|
13
|
|
|
* |
|
14
|
|
|
* @package Canvas\Api\Controllers |
|
15
|
|
|
* |
|
16
|
|
|
*/ |
|
17
|
|
|
class NotificationsController extends BaseController |
|
18
|
|
|
{ |
|
19
|
|
|
/* |
|
20
|
|
|
* fields we accept to create |
|
21
|
|
|
* |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $createFields = ['read']; |
|
25
|
|
|
|
|
26
|
|
|
/* |
|
27
|
|
|
* fields we accept to create |
|
28
|
|
|
* |
|
29
|
|
|
* @var array |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $updateFields = ['read']; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* set objects. |
|
35
|
|
|
* |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
public function onConstruct() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->model = new Notifications(); |
|
41
|
|
|
$this->additionalSearchFields = [ |
|
42
|
|
|
['is_deleted', ':', '0'], |
|
43
|
|
|
['users_id', ':', $this->userData->getId()], |
|
44
|
|
|
['companies_id', ':', $this->userData->currentCompanyId()], |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Pass the resultset to a DTO Mapper. |
|
50
|
|
|
* |
|
51
|
|
|
* @param mixed $results |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function processOutput($results) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->dtoConfig->registerMapping(Notifications::class, Notification::class) |
|
57
|
|
|
->useCustomMapper(new NotificationMapper()); |
|
58
|
|
|
|
|
59
|
|
|
return is_iterable($results) ? |
|
60
|
|
|
$this->mapper->mapMultiple($results, Notification::class) |
|
61
|
|
|
: $this->mapper->map($results, Notification::class); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|