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

library/Traits/NotificationsTrait.php (3 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
0 ignored issues
show
The type Gewaer\Traits\notification_type_id was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
     * @param string systemModule;
0 ignored issues
show
The type Gewaer\Traits\systemModule was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     * @return void
34
     */
35
    public function create(Users $user, string $content, int $notificationTypeId,string $systemModule): void
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;
0 ignored issues
show
Bug Best Practice introduced by
The property system_module_id does not exist on Gewaer\Models\Notifications. Since you implemented __set, consider adding a @property annotation.
Loading history...
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()){
48
            Di::getDefault()->getLog()->error((string)current($notification->getMessages()));
49
        }
50
    }
51
}