-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPublicWikiResource.php
More file actions
29 lines (24 loc) · 1.08 KB
/
PublicWikiResource.php
File metadata and controls
29 lines (24 loc) · 1.08 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
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PublicWikiResource extends JsonResource {
public function toArray($request): array {
$logoSetting = $this->settings()->where('name', 'wgLogo')->first();
return [
'id' => $this->id,
'description' => $this->description,
'domain' => $this->domain,
'domain_decoded' => $this->domain_decoded,
'sitename' => $this->sitename,
'wiki_site_stats' => $this->wikiSiteStats,
'logo_url' => $logoSetting ? $logoSetting->value : null,
// Checking relation load state before reading it to avoid N+1 query
// This relies on the controller to eager load `wikiLatestProfile` relationship
'reuse_prototype' => $this->wikiLatestProfile
? $this->wikiLatestProfile->purpose === 'data_hub'
&& $this->wikiLatestProfile->temporality === 'permanent'
&& $this->wikiLatestProfile->audience === 'wide'
: null,
];
}
}