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 }}

0 Comment's

Add Comment

Register to Reply

About Author

I am Bhawesh Bhaskar, a Full Stack Sr. Software Developer. I am a good learner and always eager to learn new technologies. I can develop both client and server software. In addition to mastering HTML and CSS, I also know how to: Program a browser (like using JavaScript, jQuery) Program a server (like using Laravel, Code Ignitor or Core PHP).