Share PDF on mail in laravel

PDF canbe shared in attachment at the time of storing data in database

PDF canbe shared in attachment at the time of storing data in database

Controller :


 use PDF;

 $rs = Model::create([
 'user_id' => Auth::user()->id,
 'name' => $request->name,
 'email' => $request->email,
 'phone' => $request->phone,
 'subject' => $request->subject,
 'message' => $request->message,
 ]);
 
 $pdf = PDF::loadView('pdf.invoice', ['title' => 'Title', 'rs' => $rs]);

 $path = $pdf->save(storage_path('app/pdf/'.$rs->id . '.pdf'));
 
 $attachment = asset('storage/app/sofpdf/'.$rs->sof_id . '.pdf');

Note: This attachment then can be shared shared on file as attachment

View : invoice.blade.php


{{ $rs->name }}

2 Comment's

  1. 202507210014312275.jpg
    Guest User
    Reply

    Great post! It really helped me a lot.

    Register to Reply

    • 202507150031512529.jfif
      Bhawesh Bhaskar

      Yes, it helped me also. Thank you.

Add Comment

Register to Reply

About Author

Looking for a reliable and skilled web developer? I'm Bhawesh Bhaskar, a Senior Full Stack Software Developer with proven expertise in both front-end and back-end development. I provide professional website design, custom web application development, and robust PHP solutions using Laravel, CodeIgniter, and Core PHP. I help businesses create modern, responsive, and high-performance websites that drive results. Whether you're starting from scratch or need to upgrade your existing site, I deliver solutions tailored to your goals.
💼 Let’s build something great together — contact me today for a free consultation!