public function sendMail($id) { $file = Data::findOrFail($id); $pathToFile = $file->path; Mail::raw(Input::get('body'), function ($message) use($pathToFile, $file) { $message->to(Input::get('email')); $message->subject(Input::get('subject')); $message->attach($pathToFile, ['as' => $file->name, 'mime' => 'application/pdf']); }); if ($file->courseId != null) { $course = Course::findOrFail($file->courseId); return Redirect::action('CoursesController@showParam', [$course->slug]); } if ($file->snippetId != null) { $snippet = Snippet::findOrFail($file->snippetId); return Redirect::action('CoursesController@show', [$snippet->slug]); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $snippet = Snippet::findOrFail($id); $snippet->delete(); return redirect()->route('snippet.index')->with('message', 'Snippet well deleted.'); }