/**
  * Update published status for the changed files.
  * @param $changes
  * @param $organizationId
  */
 public function updateStatus($changes, $organizationId)
 {
     $this->organizationModel = $this->organization->findOrFail($organizationId);
     foreach ($changes['changes'] as $filename => $change) {
         $row = $this->activityPublished->query()->where('filename', '=', $filename)->where('organization_id', '=', $organizationId)->first();
         $row->published_to_register = 1;
         $row->save();
     }
 }
 /**
  * Update Settings with segmentation changes.
  * @param SettingsRequestManager $requestManager
  * @return mixed
  * @internal param TempRequest|Request $request
  */
 public function updateSettings(SettingsRequestManager $requestManager)
 {
     $organizationId = session('org_id');
     $settings = $requestManager->requestHandler->all();
     $organization = $this->organization->findOrFail($organizationId);
     if (!$organization->publishedFiles->isEmpty()) {
         if ($this->settingsService->hasSegmentationChanged($organizationId, $settings)) {
             $changes = $this->settingsService->getChangeLog($organizationId, $settings);
             if (empty($changes['previous']) && empty($changes['changes'])) {
                 return redirect()->route('settings.index')->withResponse(['type' => 'warning', 'messages' => ['You do not have any files for the segmentation change to take effect on.']]);
             }
             return view('settings.change-log', compact('organizationId', 'changes', 'settings'));
         }
     }
     if (!$this->settingsManager->updateSettings($settings, $this->organization, $this->settings)) {
         $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Settings']]];
     } else {
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Settings']]];
     }
     return redirect()->to(config('app.admin_dashboard'))->withResponse($response);
 }
 /**
  * update organization profile
  * @param $input
  * @return mixed
  */
 protected function updateOrganizationProfile($input)
 {
     $organization = $this->organization->findOrFail($this->orgId);
     $file = Input::file('organization_logo');
     if ($file) {
         $fileUrl = url('files/logos/' . $this->orgId . '.' . $file->getClientOriginalExtension());
         $fileName = $this->orgId . '.' . $file->getClientOriginalExtension();
         $image = Image::make(File::get($file))->resize(150, 150)->encode();
         Storage::put('logos/' . $fileName, $image);
         $organization->logo_url = $fileUrl;
         $organization->logo = $fileName;
     }
     $organization->name = $input['organization_name'];
     $organization->address = $input['organization_address'];
     $organization->country = $input['country'];
     $organization->organization_url = $input['organization_url'];
     $organization->telephone = $input['organization_telephone'];
     $organization->twitter = $input['organization_twitter'];
     $organization->disqus_comments = array_key_exists('disqus_comments', $input) ? $input['disqus_comments'] : null;
     return $organization->save();
 }
 /**
  * get organization by its id
  * @param $id
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getOrganizationById($id)
 {
     return $this->organization->findOrFail($id);
 }
 /**
  * Find an Organization with a specific organizationId.
  * @param $organizationId
  * @return mixed
  */
 public function find($organizationId)
 {
     return $this->organization->findOrFail($organizationId);
 }
 public function destroy($id)
 {
     Organization::findOrFail($id)->delete();
     return redirect()->back()->withFlashSuccess('The organization was successfully deleted.');
 }