From d49c9703a739daab78bb697cf331b9b285ea56bc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 5 Feb 2025 20:03:27 +1100 Subject: [PATCH] Updated documentation --- app/Services/Report/ProjectReport.php | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/Services/Report/ProjectReport.php diff --git a/app/Services/Report/ProjectReport.php b/app/Services/Report/ProjectReport.php new file mode 100644 index 0000000000..d8fd338a7b --- /dev/null +++ b/app/Services/Report/ProjectReport.php @@ -0,0 +1,89 @@ +company->db); + App::forgetInstance('translator'); + App::setLocale($this->company->locale()); + $t = app('translator'); + $t->replace(Ninja::transformTranslations($this->company->settings)); + + return $this->getPdf(); + } + + public function getPdf() + { + $user = isset($this->input['user_id']) ? User::withTrashed()->find($this->input['user_id']) : $this->company->owner(); + + $user_name = $user ? $user->present()->name() : ''; + + + $projects = \App\Models\Project::where('company_id', $this->company->id) + ->whereIn('id', $this->transformKeys($this->input['projects']) + ->get(); + + $data = [ + 'projects' => $projects, + 'company_logo' => $this->company->present()->logo(), + 'company_name' => $this->company->present()->name(), + 'created_on' => $this->translateDate(now()->format('Y-m-d'), $this->company->date_format(), $this->company->locale()), + 'created_by' => $user_name, + ]; + + $ts = new TemplateService(); + + $ts_instance = $ts->setCompany($this->company) + ->setData($data) + ->setRawTemplate(file_get_contents(resource_path($this->template))) + ->parseNinjaBlocks() + ->save(); + + return $ts_instance->getPdf(); + } + +}