model = $model; } public function _set($name, $value){ $this->{$name} = $value; } public function createContractPDF() { $pdf = new ContractPDF(); $pdf->AddPage('P', array(210, 297)); $pdf->SetFont('Helvetica', '', 11); $pdf->SetDrawColor(160, 160, 160); $x1 = 16.5; $x2 = 109; $y = 70; $nl = 17.5; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->m_account); $pdf->SetXY($x2, $y); $pdf->Write(0, now()->format("d.m.Y")); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->company); $pdf->SetXY($x2, $y); $pre = $this->model->account->pre_phone_id != "" ? $this->model->account->pre_phone->phone." " : ""; $pdf->Write(0, $pre.$this->model->account->phone); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->m_first_name); $pdf->SetXY($x2, $y); $pre = $this->model->account->pre_mobil_id != "" ? $this->model->account->pre_mobil->phone." " : ""; $pdf->Write(0, $pre.$this->model->account->mobil); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->m_last_name); $pdf->SetXY($x2, $y); $pdf->Write(0, $this->model->email); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->address); $pdf->SetXY($x2, $y); $pdf->Write(0, $this->model->account->birthday); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->account->zipcode." ".$this->model->account->city); $y += $nl; $pdf->SetXY($x1, $y); $pre = $this->model->account->country_id ? $this->model->account->country->de." " : ""; $pdf->Write(0, $pre); if($this->model->m_sponsor){ $y += 48; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->user_sponsor->account->company); $pdf->SetXY($x2, $y); $pdf->Write(0, $this->model->user_sponsor->account->m_account); $y += $nl; $pdf->SetXY($x1, $y); $pdf->Write(0, $this->model->user_sponsor->account->m_first_name." ".$this->model->user_sponsor->account->m_last_name); $website = $this->model->user_sponsor->shop()->count() ? $this->model->user_sponsor->shop->getSubdomain(false) : "www.mivita.care"; }else{ $website = "www.mivita.care"; } $pdf->AddPage('P', array(210, 297)); $pdf->SetFont('Helvetica', '', 10); $pdf->SetDrawColor(160, 160, 160); $pdf->SetXY(52, 56); $pdf->Write(0, $website); $pdf->SetXY($x1, 65); $pdf->Write(0, $this->model->account->m_first_name." ".$this->model->account->m_last_name); $pdf->SetXY($x2, 65); $pdf->Write(0, $this->model->account->m_account); $pdf->AddPage('P', array(210, 297)); if(!Storage::disk($this->disk)->exists( $this->dir )){ Storage::disk($this->disk)->makeDirectory($this->dir); //creates directory } $filename = "MIVITA_Beratervertrag.pdf"; Storage::disk($this->disk)->put($this->dir.$filename, $pdf->Output('S')); $size = Storage::disk($this->disk)->size($this->dir.$filename); $mine = Storage::disk($this->disk)->getMimeType($this->dir.$filename); File::create([ 'user_id' => $this->model->id, 'identifier' => $this->identifier, 'filename' => $filename, 'dir' => $this->dir, 'original_name' => $filename, 'ext' => "pdf", 'mine' => $mine, 'size' => $size ]); return true; } }