diff --git a/app/DataMapper/ClientSettings.php b/app/DataMapper/ClientSettings.php index 133719737de7..19550b3d2dc4 100644 --- a/app/DataMapper/ClientSettings.php +++ b/app/DataMapper/ClientSettings.php @@ -5,7 +5,6 @@ namespace App\DataMapper; use App\DataMapper\ClientSettings; use App\DataMapper\CompanySettings; use App\Utils\TranslationHelper; -use Illuminate\Support\Facades\Log; /** * ClientSettings @@ -118,7 +117,6 @@ class ClientSettings extends BaseSettings { if(!isset($client_settings->{$key}) && property_exists($company_settings, $key)) { - Log::error('settings ' . $key .' to '. $company_settings->{$key}); $client_settings->{$key} = $company_settings->{$key}; } diff --git a/app/Events/User/UserWasArchived.php b/app/Events/User/UserWasArchived.php new file mode 100644 index 000000000000..196d5dd00858 --- /dev/null +++ b/app/Events/User/UserWasArchived.php @@ -0,0 +1,51 @@ +user = $user; + $this->company = $company; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Events/User/UserWasDeleted.php b/app/Events/User/UserWasDeleted.php new file mode 100644 index 000000000000..16323cb0e50a --- /dev/null +++ b/app/Events/User/UserWasDeleted.php @@ -0,0 +1,51 @@ +user = $user; + $this->company = $company; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Events/User/UserWasRestored.php b/app/Events/User/UserWasRestored.php new file mode 100644 index 000000000000..73333103c75a --- /dev/null +++ b/app/Events/User/UserWasRestored.php @@ -0,0 +1,51 @@ +user = $user; + $this->company = $company; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Events/User/UserWasUpdated.php b/app/Events/User/UserWasUpdated.php new file mode 100644 index 000000000000..9fe191138ce5 --- /dev/null +++ b/app/Events/User/UserWasUpdated.php @@ -0,0 +1,51 @@ +user = $user; + $this->company = $company; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Listeners/User/ArchivedUserActivity.php b/app/Listeners/User/ArchivedUserActivity.php new file mode 100644 index 000000000000..b766a584f755 --- /dev/null +++ b/app/Listeners/User/ArchivedUserActivity.php @@ -0,0 +1,44 @@ +activityRepo = $activityRepo; + } + + /** + * Handle the event. + * + * @param object $event + * @return void + */ + public function handle($event) + { + + $fields = new \stdClass; + + if(auth()->user()->id) + $fields->user_id = auth()->user()->id; + else + $fields->user_id = $event->user->id; + + $fields->company_id = $event->user->company_id; + $fields->activity_type_id = Activity::ARCHIVE_USER; + + $this->activityRepo->save($fields, $event->user); + } +} diff --git a/app/Listeners/User/CreatedUserActivity.php b/app/Listeners/User/CreatedUserActivity.php index 35bd06a336e4..9881360e9803 100644 --- a/app/Listeners/User/CreatedUserActivity.php +++ b/app/Listeners/User/CreatedUserActivity.php @@ -31,7 +31,11 @@ class CreatedUserActivity $fields = new \stdClass; - $fields->user_id = auth()->user()->id; + if(auth()->user()->id) + $fields->user_id = auth()->user()->id; + else + $fields->user_id = $event->user->id; + $fields->company_id = $event->user->company_id; $fields->activity_type_id = Activity::CREATE_USER; diff --git a/app/Listeners/User/DeletedUserActivity.php b/app/Listeners/User/DeletedUserActivity.php new file mode 100644 index 000000000000..aa3549f71795 --- /dev/null +++ b/app/Listeners/User/DeletedUserActivity.php @@ -0,0 +1,44 @@ +activityRepo = $activityRepo; + } + + /** + * Handle the event. + * + * @param object $event + * @return void + */ + public function handle($event) + { + + $fields = new \stdClass; + + if(auth()->user()->id) + $fields->user_id = auth()->user()->id; + else + $fields->user_id = $event->user->id; + + $fields->company_id = $event->user->company_id; + $fields->activity_type_id = Activity::DELETE_USER; + + $this->activityRepo->save($fields, $event->user); + } +} diff --git a/app/Listeners/User/RestoredUserActivity.php b/app/Listeners/User/RestoredUserActivity.php new file mode 100644 index 000000000000..f98fff41cf49 --- /dev/null +++ b/app/Listeners/User/RestoredUserActivity.php @@ -0,0 +1,44 @@ +activityRepo = $activityRepo; + } + + /** + * Handle the event. + * + * @param object $event + * @return void + */ + public function handle($event) + { + + $fields = new \stdClass; + + if(auth()->user()->id) + $fields->user_id = auth()->user()->id; + else + $fields->user_id = $event->user->id; + + $fields->company_id = $event->user->company_id; + $fields->activity_type_id = Activity::RESTORE_USER; + + $this->activityRepo->save($fields, $event->user); + } +} diff --git a/app/Listeners/User/UpdatedUserActivity.php b/app/Listeners/User/UpdatedUserActivity.php new file mode 100644 index 000000000000..8a320de63f0e --- /dev/null +++ b/app/Listeners/User/UpdatedUserActivity.php @@ -0,0 +1,44 @@ +activityRepo = $activityRepo; + } + + /** + * Handle the event. + * + * @param object $event + * @return void + */ + public function handle($event) + { + + $fields = new \stdClass; + + if(auth()->user()->id) + $fields->user_id = auth()->user()->id; + else + $fields->user_id = $event->user->id; + + $fields->company_id = $event->user->company_id; + $fields->activity_type_id = Activity::UPDATE_USER; + + $this->activityRepo->save($fields, $event->user); + } +} diff --git a/app/Models/CompanyToken.php b/app/Models/CompanyToken.php index 5dd0b2c12495..fa75f73dcbf5 100644 --- a/app/Models/CompanyToken.php +++ b/app/Models/CompanyToken.php @@ -15,6 +15,11 @@ class CompanyToken extends BaseModel 'id', ]; + protected $with = [ + // 'user', + // 'company', + ]; + public function account() { return $this->belongsTo(Account::class);