-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from musimana/11.x
v11.10.0
- Loading branch information
Showing
88 changed files
with
1,542 additions
and
1,045 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Enums\Webpages; | ||
|
||
enum WebpageStatus: int | ||
{ | ||
/* List of the webpage statuses available to the application. */ | ||
case DRAFT = 1; | ||
case PUBLISHED = 2; | ||
|
||
/** Get the status's label. */ | ||
public function label(): string | ||
{ | ||
return match ($this) { | ||
self::DRAFT => 'Draft', | ||
self::PUBLISHED => 'Published', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/Http/Resources/Views/Public/Content/PrivacyPolicyContentResource.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources\Views\Public\Content; | ||
|
||
use App\Enums\Blocks\BlockType; | ||
use App\Enums\Webpages\WebpageStatus; | ||
use App\Enums\Webpages\WebpageTemplate; | ||
use App\Http\Resources\Views\Public\Metadata\PageMetadataResource; | ||
use App\Interfaces\Resources\Items\ConstantItemInterface; | ||
use App\Models\Block; | ||
use App\Models\Page; | ||
|
||
final class PrivacyPolicyContentResource implements ConstantItemInterface | ||
{ | ||
/** Instantiate the resource. */ | ||
public function __construct( | ||
protected Page $page = new Page, | ||
) { | ||
if (!$this->page->id) { | ||
$this->page = Page::query() | ||
->published() | ||
->where('slug', 'privacy') | ||
->with('blocks') | ||
->first() | ||
?? new Page; | ||
} | ||
|
||
if (!$this->getTemplate()) { | ||
$this->setDefaultModel(); | ||
} | ||
} | ||
|
||
/** | ||
* Get the content array for the site's privacy page. | ||
* | ||
* @return array{ | ||
* blocks: array<int, array{ | ||
* type: string, | ||
* data: array<string, array<int, string>|string>, | ||
* }>, | ||
* } | ||
*/ | ||
public function getItem(): array | ||
{ | ||
return (new PageContentResource($this->page))->getItem(); | ||
} | ||
|
||
/** | ||
* Get the meta-data array for the site's privacy page. | ||
* | ||
* @return array{canonical: string, description: string, title: string} | ||
*/ | ||
public function getMetaData(): array | ||
{ | ||
return (new PageMetadataResource)->getItem($this->page); | ||
} | ||
|
||
/** Get the template for the resource. */ | ||
public function getTemplate(): ?WebpageTemplate | ||
{ | ||
return $this->page->getTemplate(); | ||
} | ||
|
||
/** Set the resource's page to the default privacy page model. */ | ||
public function setDefaultModel(): void | ||
{ | ||
$this->page = new Page([ | ||
'webpage_status_id' => WebpageStatus::PUBLISHED->value, | ||
'template' => WebpageTemplate::PUBLIC_CONTENT->value, | ||
'slug' => 'privacy', | ||
'title' => 'Privacy Policy', | ||
'meta_title' => 'Privacy Policy', | ||
'meta_description' => 'Privacy policy for the ' . config('app.name') . ' website, which covers how this app handles your data.', | ||
]); | ||
|
||
$this->page->blocks = collect([ | ||
new Block([ | ||
'type' => BlockType::WYSIWYG->value, | ||
'parent_type' => Page::class, | ||
'parent_id' => $this->page->id, | ||
'data' => json_encode([ | ||
'html' => '<h2 class="text-page-title">PRIVACY POLICY</h2> | ||
<p class="text-page-subtitle">' . config('app.name') . '</p>', | ||
]), | ||
]), | ||
|
||
new Block([ | ||
'type' => BlockType::SECTION_DIVIDER->value, | ||
'parent_type' => Page::class, | ||
'parent_id' => $this->page->id, | ||
]), | ||
|
||
new Block([ | ||
'type' => BlockType::PRIVACY_POLICY->value, | ||
'parent_type' => Page::class, | ||
'parent_id' => $this->page->id, | ||
]), | ||
]); | ||
|
||
$page = Page::factory()->privacyPage()->make(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.