Laravel 邮件附件

Laravel Mail Attachment

如何在laravel中添加邮件附件?然后下载 link,并仅验证 PDF,大小不再高达 2mb。对不起,我只是一个喜欢编码的学生。请帮助我。

这是我的控制器代码

public function store_applier(Request $request)
{   
    $this->validate($request, [
        'nama' => 'required',
        'email' => 'required',
        'kontak' => 'required',
        'kategori'=>'required',
        'posisi' => 'required',
        'alamat' => 'required',
    ]); 

    $tambah = new appliers(); //kita buat objek yang terhubung ke table JOBS
    $tambah->nama = $request['nama'];
    $tambah->email = $request['email'];
    $tambah->kontak = $request['kontak'];
    $tambah->kategori = $request['kategori'];
    $tambah->posisi = $request['posisi'];
    $tambah->alamat = $request['alamat'];


    $file = $request->file('upload_cv');
    $fileName = $file->getClientOriginalName();
    $request->file('upload_cv')->move("cv/", $fileName);
    $tambah->upload_cv = $fileName;
    $tambah->save();

    $email = DB::table('user')->where('email');

    Mail::send('emails.welcome', [
        'email' => $request['email'],
        'HP' => $request['kontak'],
        'nama' => $request['nama'], 
        'posisi' => $request['posisi'], 
        'CV' => $tambah->upload_cv = $fileName
    ], function ($message) use ($request, $tambah, $email) {

        $message->from('stevanajja@gmail.com', $request->posisi);   

        $message->to('stevantinusl47@gmail.com')
                ->subject('Lamaran Baru')
                ->cc('stevanlai@yahoo.com.sg')
                ->replyTo($request->email);

        $message->getSwiftMessage();

    });

    return redirect()->to('index'); 
}

这是查看代码

**<h1>Lamaran Baru</h1>

From : {{ $email }}

<br />

NO.HP : {{$HP}}

<br />

=========================

<br /><br />

Nama saya {{ $nama }},

<br /><br />

Saya ingin melamar pekerjaan di PT.Halcom dengan posisi sebagai 

<h2>{{$posisi}}</h2>

<br />

Berikut saya lampirkan CV saya

<br /><br /><br />

*Klik link dibawah untuk melihat CV

<br />

<a href="{!!URL::asset('../cv/{{$CV}}')!!}">KLIK</a>**

抱歉浪费你的时间回答这个愚蠢的问题..我只是学生

在您的消息链中添加 attach 方法。

$message->to('stevantinusl47@gmail.com')
        ->subject('Lamaran Baru')
        ->cc('stevanlai@yahoo.com.sg')
        ->replyTo($request->email)
        ->attach('path_to_pdf_file', [
            'as' => 'your-desired-name.zip', 
            'mime' => 'application/pdf'
        ]);

为了你的道路

<a href="{{ asset('path-to-your-pdf-in-public-directory') }}">KLIK</a>