Completed
Pull Request — master (#36)
by Karl
05:12
created

NotificationsController::download()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php namespace JobApis\JobsToMail\Http\Controllers;
2
3
use Illuminate\Foundation\Bus\DispatchesJobs;
4
use Illuminate\Http\Request;
5
use Illuminate\Routing\Controller as BaseController;
6
use Illuminate\Foundation\Validation\ValidatesRequests;
7
use JobApis\JobsToMail\Jobs\Notifications\GenerateCsv;
8
use JobApis\JobsToMail\Jobs\Notifications\GetNotificationById;
9
10
class NotificationsController extends BaseController
11
{
12
    use DispatchesJobs, ValidatesRequests;
13
14
    /**
15
     * Show the notification
16
     */
17
    public function single(Request $request, $id)
18
    {
19
        $notification = $this->dispatchNow(new GetNotificationById($id));
20
21
        if ($notification) {
22
            return view('notifications.single', ['notification' => $notification]);
23
        }
24
25
        $request->session()->flash('alert-danger', 'This job alert has expired.');
26
27
        return redirect('/');
28
    }
29
30
    /**
31
     * Download jobs from a collection by ID
32
     */
33
    public function download(Request $request, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        $path = $this->dispatchNow(new GenerateCsv($id));
36
37
        return response()->download($path, null, ['Content-Type: text/csv']);
38
    }
39
}
40