Code Duplication    Length = 4-6 lines in 2 locations

app/Mail/SendNewsEmail.php 1 location

@@ 38-41 (lines=4) @@
35
                ->subject($this->news->title);
36
37
        //ATTACH FILES
38
        foreach ($this->news->attachments as $file) {
39
            $path = 'app/news_'.$file->imageable_id.'/'.$file->filename;
40
            $mailer->attach(storage_path($path), ['as' => $file->filename, 'mime' => $file->mime]);
41
        }
42
43
        return $mailer;
44
    }

app/Listeners/EmailTraining.php 1 location

@@ 70-75 (lines=6) @@
67
                $m->to($user->email, $user->userFullName)->subject($training->name.' was assigned to you.');
68
69
                //ATTACH FILES
70
                foreach ($training->attachments as $file) {
71
                    if (!$file->admin_only) {
72
                        $path = 'app/training_'.$file->imageable_id.'/'.$file->filename;
73
                        $m->attach(storage_path($path), ['as' => $file->filename, 'mime' => $file->mime]);
74
                    }
75
                }
76
            } // end $m function
77
        );
78
    }