Completed
Push — master ( ce343e...8c2661 )
by Sam
12:36
created

AssociationsController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 8 1
1
<?php
2
3
namespace App\Http\Controllers\Api;
4
5
use App\Http\Controllers\Controller;
6
7
use App\Association;
8
use App\Division;
9
use App\Match;
10
use App\ResultSubmission;
11
use App\Round;
12
use App\Series;
13
use App\Schedule;
14
use App\User;
15
use App\Venue;
16
17
use App\Http\Resources\Association as AssociationResource;
18
use App\Http\Resources\AssociationCollection as AssociationCollectionResource;
19
20
use Bouncer;
21
use Illuminate\Http\Request;
22
use Illuminate\Support\Str;
23
24
class AssociationsController extends Controller
25
{
26
27
    public function __construct(Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function __construct(/** @scrutinizer ignore-unused */ Request $request) {

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

Loading history...
28
        $subdomain = array_first(explode('.', \Request::getHost()));
0 ignored issues
show
Deprecated Code introduced by
The function array_first() has been deprecated: Arr::first() should be used directly instead. Will be removed in Laravel 5.9. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

28
        $subdomain = /** @scrutinizer ignore-deprecated */ array_first(explode('.', \Request::getHost()));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
29
30
        $this->association = Association::where('subdomain', $subdomain)->first();
0 ignored issues
show
Bug Best Practice introduced by
The property association does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
    }
32
33
    public function index(Request $request) {
34
        $user = $request->user();
0 ignored issues
show
Unused Code introduced by
The assignment to $user is dead and can be removed.
Loading history...
35
36
        $userAssociations = Association::all()->filter(function ($association) {
37
            return Bouncer::can('manage', $association);
38
        });
39
40
        return new AssociationCollectionResource($userAssociations);
41
    }
42
43
}
44