Test Failed
Pull Request — master (#70)
by Rafael
04:52
created

library/Traits/NotificationsTrait.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Traits;
6
7
use Gewaer\Models\Users;
8
use Gewaer\Models\SystemModules;
9
use Gewaer\Models\Notifications;
10
use Phalcon\Di;
11
12
/**
13
 * Trait ResponseTrait
14
 *
15
 * @package Gewaer\Traits
16
 *
17
 * @property Users $user
18
 * @property AppsPlans $appPlan
19
 * @property CompanyBranches $branches
20
 * @property Companies $company
21
 * @property UserCompanyApps $app
22
 * @property \Phalcon\Di $di
23
 *
24
 */
25
trait NotificationsTrait
26
{
27
    /**
28
     * Create a new notification
29
     * @param Users $user
30
     * @param string $content
31
     * @param int notification_type_id
32
     * @param string systemModule;
33
     * @return void
34
     */
35
    public function create(Users $user, string $content, int $notificationTypeId,string $systemModule): void
0 ignored issues
show
Expected 1 space between comma and type hint "string"; 0 found
Loading history...
36
    {
37
        $notification =  new Notifications();
38
        $notification->users_id = $user->getId();
39
        $notification->companies_id = Di::getDefault()->getUserData()->currentCompanyId();
40
        $notification->apps_id = Di::getDefault()->getApp()->getId();
41
        // $notification->notification_type_id = $notificationTypeId;
42
        $notification->system_module_id = SystemModules::getSystemModuleByModelName($systemModule)->id;
43
        $notification->entity_id = $user->getId();
44
        $notification->content = $content;
45
        $notification->created_at = date('Y-m-d H:i:s');
46
47
        if(!$notification->save()){
0 ignored issues
show
Expected 1 space(s) after IF keyword; 0 found
Loading history...
48
            Di::getDefault()->getLog()->error((string)current($notification->getMessages()));
49
        }
50
    }
51
}