Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit e6df3cb

Browse files
committed
Update files system trait
1 parent 3a57834 commit e6df3cb

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Traits/FileSystemModelTrait.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ protected function associateFileSystem(): bool
6666
*/
6767
public function attach(array $files): bool
6868
{
69-
$systemModule = SystemModules::getSystemModuleByModelName(self::class, Di::getDefault()->getApp()->getId());
69+
$appId = Apps::getIdByKey(getenv('GEWAER_APP_ID'))->id;
70+
$systemModule = SystemModules::getSystemModuleByModelName(self::class, $appId);
7071

7172
foreach ($files as $file) {
7273
//im looking for the file inside an array
@@ -81,7 +82,7 @@ public function attach(array $files): bool
8182
$fileSystemEntities = null;
8283
//check if we are updating the attachment
8384
if ($id = (int) $file['id']) {
84-
$fileSystemEntities = FileSystemEntities::getByIdWithSystemModule($id, Di::getDefault()->getApp()->getId());
85+
$fileSystemEntities = FileSystemEntities::getByIdWithSystemModule($id, $appId);
8586
}
8687

8788
//new attachment
@@ -94,18 +95,18 @@ public function attach(array $files): bool
9495

9596
//If filesystem entity does not exist then create a new one
9697
$users = FileSystemEntities::create([
97-
'system_modules_id'=> $systemModule->id,
98-
'companies_id'=> $file['file']->companies_id,
99-
'entity_id'=> $this->id,
100-
'created_at'=> $file['file']->created_at
98+
'system_modules_id' => $systemModule->id,
99+
'companies_id' => $file['file']->companies_id,
100+
'entity_id' => $this->id,
101+
'created_at' => $file['file']->created_at
101102
]);
102103
}
103104

104105
//If filesystem entity does exist then update
105106
$users = FileSystemEntities::update($fileSystemEntities->id, [
106-
'filesystem_id'=> $file['file']->id,
107-
'field_name'=> $file['field_name'] ?? null,
108-
'is_deleted'=> 0
107+
'filesystem_id' => $file['file']->id,
108+
'field_name' => $file['field_name'] ?? null,
109+
'is_deleted' => 0
109110
]);
110111

111112
// $fileSystemEntities->filesystem_id = $file['file']->getId();

0 commit comments

Comments
 (0)