Add all files
This commit is contained in:
112
extensions/Others/CustomPages/CustomPages.php
Normal file
112
extensions/Others/CustomPages/CustomPages.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\CustomPages;
|
||||
|
||||
use App\Classes\Extension\Extension;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Paymenter\Extensions\Others\CustomPages\Admin\Resources\CustomPagesResource;
|
||||
use Paymenter\Extensions\Others\CustomPages\Models\Page;
|
||||
|
||||
class CustomPages extends Extension
|
||||
{
|
||||
public function getConfig($values = [])
|
||||
{
|
||||
try {
|
||||
return [
|
||||
[
|
||||
'name' => 'Notice',
|
||||
'type' => 'placeholder',
|
||||
'label' => new HtmlString(
|
||||
'Use this extension to create Custom Pages like a ToS, FAQ or Privacy Policy.
|
||||
Manage your Pages at <a class="text-primary-600" href="' . CustomPagesResource::getUrl() . '">Custom Pages</a>.
|
||||
<br><br><small><i>Need help? Join our Discord at <a href="https://discord.gg/V3nJ3jVURN">https://discord.gg/V3nJ3jVURN</a></small></i>'
|
||||
),
|
||||
],
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
[
|
||||
'name' => 'Notice',
|
||||
'type' => 'placeholder',
|
||||
'label' => new HtmlString(
|
||||
'Use this extension to create Custom Pages like a ToS, FAQ or Privacy Policy. You will need to enable it before you can use it.
|
||||
<br><br><small><i>Need help? Join our Discord at <a href="https://discord.gg/V3nJ3jVURN">https://discord.gg/V3nJ3jVURN</a></small></i>'
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function enabled()
|
||||
{
|
||||
Artisan::call('migrate', [
|
||||
'--path' => 'extensions/Others/CustomPages/database/migrations',
|
||||
'--force' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
require __DIR__ . '/routes/web.php';
|
||||
|
||||
View::addNamespace('custompages', __DIR__ . '/resources/views');
|
||||
|
||||
\Livewire\Livewire::component('custompages.show', \Paymenter\Extensions\Others\CustomPages\Livewire\Show::class);
|
||||
|
||||
Event::listen('navigation', function () {
|
||||
return Page::where('visible_in_menu', true)
|
||||
->where('is_active', true)
|
||||
->whereNotNull('slug')
|
||||
->where('slug', '!=', '')
|
||||
->get()
|
||||
->filter(function ($page) {
|
||||
switch ($page->visibility) {
|
||||
case 'admins':
|
||||
if (!Auth::check() || is_null(Auth::user()->role)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'customers':
|
||||
if (!Auth::check() || !is_null(Auth::user()->role)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'guests':
|
||||
if (Auth::check()) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'logged-in':
|
||||
if (!Auth::check()) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'everyone':
|
||||
default:
|
||||
// everyone mag zien
|
||||
break;
|
||||
}
|
||||
|
||||
return true; // fucked up
|
||||
})
|
||||
->map(function ($page) {
|
||||
return [
|
||||
'route' => 'custompages.show',
|
||||
'name' => $page->title,
|
||||
'params' => ['fallbackPlaceholder' => $page->slug],
|
||||
'icon' => 'ri-pages',
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user