Test Setup Failed
Pull Request — master (#24)
by
unknown
04:09
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
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;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_MATCH, expecting T_STRING or '{' on line 9 at column 8
Loading history...
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) {
28
        $subdomain = array_first(explode('.', \Request::getHost()));
29
30
        $this->association = Association::where('subdomain', $subdomain)->first();
31
    }
32
33
    public function index(Request $request) {
34
        $user = $request->user();
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