{"id":144,"date":"2021-01-12T22:04:51","date_gmt":"2021-01-13T01:04:51","guid":{"rendered":"https:\/\/blog.galsoft.duckdns.org\/?p=144"},"modified":"2021-01-12T22:04:51","modified_gmt":"2021-01-13T01:04:51","slug":"adjuntar-pdf-en-mailable","status":"publish","type":"post","link":"https:\/\/blog.galsoft.com.ar\/?p=144","title":{"rendered":"Adjuntar pdf en Mailable"},"content":{"rendered":"<p class=\"wp-block-paragraph\"><\/p>\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App\\Mail;\n\nuse Illuminate\\Bus\\Queueable;\nuse Illuminate\\Mail\\Mailable;\nuse Illuminate\\Queue\\SerializesModels;\n\nclass HistoriaClinicaMail extends Mailable\n{\n   use Queueable, SerializesModels;\n\n   public $subject = &#039;HISTORIA CL&Iacute;NICA DEL PACIENTE&#039;;\n\n   public $historia_clinica;\n   public $pdf;\n\n   \/**\n     * Create a new message instance.\n     *\n     * @return void\n    *\/\n    public function __construct($historia_clinica, $pdf)\n    {\n        $this-&gt;pdf = $pdf;\n        $this-&gt;historia_clinica = $historia_clinica;\n    }\n\n    \/**\n      * Build the message.\n      *\n      * @return $this\n    *\/\n    public function build()\n    {\n        return $this-&gt;view(&#039;mails.historia_clinica&#039;)\n        -&gt;attachData($this-&gt;pdf, &#039;historia_clinica.pdf&#039;, [&#039;mime&#039; =&gt; \n   &#039;application\/pdf&#039;]);\n    }\n}\n<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Luego en la funci\u00f3n en la que enviamos el correo tomamos la salida de la funci\u00f3n output de Dompdf y la pasamos por par\u00e1metro hacia ac\u00e1:<\/p>\n<pre class=\"wp-block-code\"><code>public function enviarCorreo($historia_clinica)\n{\n    $pdf = PDF::loadView(&#039;reportes.historia_clinica&#039;, compact(&#039;historia_clinica&#039;));\n    $output = $pdf-&gt;output();\n    Mail::to($historia_clinica-&gt;usuario-&gt;correo)\n    -&gt;send(new HistoriaClinicaMail($historia_clinica, $output));\n}\n<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Esto funcion\u00f3 para m\u00ed, espero que funcione para alguien m\u00e1s.<\/p>","protected":false},"excerpt":{"rendered":"<p>Luego en la funci\u00f3n en la que enviamos el correo tomamos la salida de la funci\u00f3n output de Dompdf y la pasamos por par\u00e1metro hacia ac\u00e1: Esto funcion\u00f3 para m\u00ed, espero que funcione para alguien m\u00e1s.<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[9,2,10],"tags":[],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","category-laravel","category-php","category-programacion","entry"],"_links":{"self":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=144"}],"version-history":[{"count":1,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=\/wp\/v2\/posts\/144\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.galsoft.com.ar\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}