/** * Preview PDF template * * @param $recordId * @return mixed */ public function preview($recordId) { try { $model = $this->formFindModelObject($recordId); return PDFTemplate::render($model->code); } catch (Exception $ex) { Flash::error($ex->getMessage()); } }
/** * Sample pdf templates */ public function run() { PDFTemplate::insert([['title' => 'Invoice', 'description' => 'Example Invoice Template', 'layout_id' => '1', 'code' => 'renatio::invoice', 'content_html' => File::get(__DIR__ . '/templates/invoice.htm'), 'created_at' => Carbon::now()]]); }