-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathOrgsController.php
More file actions
45 lines (38 loc) · 1.19 KB
/
OrgsController.php
File metadata and controls
45 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace App\Http\Controllers;
use App\Models\Org;
use Illuminate\Contracts\Database\Query\Builder;
class OrgsController extends Controller
{
public function index()
{
$activeOrgs = Org::with('category')
->orderBy('title')
->get()
->sortBy(fn (Org $org) => $org->category?->isInactive()
? PHP_INT_MAX
: $org->category?->id ?? 0, SORT_NUMERIC)
->groupBy('category_id');
return view('orgs.index', compact('activeOrgs'));
}
public function show(Org $org)
{
return view('orgs.show', [
'org' => $org->load([
'events' => function (Builder $query) {
$query
->with('organization', 'venue')
->ongoingAndFuture()
->published()
->orderBy('active_at')
->limit(25);
},
]),
]);
}
public function inactive()
{
$inactiveOrgs = Org::with('category')->onlyTrashed()->get()->groupBy('category_id');
return view('orgs.inactive', compact('inactiveOrgs'));
}
}