NotificationsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 7
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A single() 0 12 2
A download() 0 6 1
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.');
0 ignored issues
show
Bug introduced by
The method flash() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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