bakaphp /
phalcon-api
| 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 static function create(Users $user, string $content, int $notificationTypeId,string $systemModule): void |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
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
|
|||
| 48 | Di::getDefault()->getLog()->error((string)current($notification->getMessages())); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |