auth = $auth; } /** * Handle the update component command. * * @param \CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand $command * * @return \CachetHQ\Cachet\Models\Component */ public function handle(UpdateComponentCommand $command) { $component = $command->component; $originalStatus = $component->status; if ($command->status && (int) $originalStatus !== (int) $command->status) { event(new ComponentStatusWasChangedEvent($this->auth->user(), $component, $originalStatus, $command->status, $command->silent)); } $component->update($this->filter($command)); event(new ComponentWasUpdatedEvent($this->auth->user(), $component)); return $component; } /** * Filter the command data. * * @param \CachetHQ\Cachet\Bus\Commands\Incident\UpdateComponentCommand $command * * @return array */ protected function filter(UpdateComponentCommand $command) { $params = [ 'name' => $command->name, 'description' => $command->description, 'link' => $command->link, 'status' => $command->status, 'enabled' => $command->enabled, 'order' => $command->order, 'group_id' => $command->group_id, 'meta' => $command->meta, ]; return array_filter($params, function ($val) { return $val !== null; }); } }