SearchesController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 17 3
A unsubscribe() 0 8 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 Illuminate\Support\Facades\URL;
8
use JobApis\JobsToMail\Jobs\Searches\Delete;
9
use JobApis\JobsToMail\Jobs\Searches\GetUserSearches;
10
11
class SearchesController extends BaseController
12
{
13
    use DispatchesJobs, ValidatesRequests;
14
15
    /**
16
     * View a user's searches
17
     */
18
    public function index(Request $request, $userId = null)
19
    {
20
        // Get the searches for this user (or specified in ID)
21
        $results = $this->dispatchNow(
22
            new GetUserSearches(
23
                $userId ?: $request->session()->get('user.id')
24
            )
25
        );
26
27
        if (!$results->isEmpty()) {
28
            return view('searches.index', ['searches' => $results]);
29
        }
30
31
        $request->session()->flash('alert-danger', 'You currently have no active searches. Try adding one.');
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...
32
33
        return redirect('/');
34
    }
35
36
    /**
37
     * Unsubscribe from single search
38
     */
39
    public function unsubscribe(Request $request, $searchId)
40
    {
41
        $message = $this->dispatchNow(new Delete($searchId));
42
43
        $request->session()->flash($message->type, $message->message);
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...
44
45
        return redirect(URL::previous('/'));
46
    }
47
}
48