Skip to content

Commit

Permalink
Merge pull request #196 from OpenSynergic/improvementss
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
rahmanramsi authored Feb 22, 2024
2 parents 61b6872 + 3aaea7b commit 0419d8c
Show file tree
Hide file tree
Showing 85 changed files with 1,923 additions and 605 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Blocks/UpdateBlockSettingsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function handle(string $blockName, array $settings): Block
DB::beginTransaction();

$block = Block::updateOrCreate([
'class' => $blockName,
'name' => $blockName,
], $settings);

DB::commit();
Expand Down
23 changes: 11 additions & 12 deletions app/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Models\Navigation;
use App\Models\ParticipantPosition;
use App\Models\PaymentItem;
use App\Models\PluginSetting;
use App\Models\Scopes\ConferenceScope;
use App\Models\Site;
use App\Models\StaticPage;
Expand All @@ -28,9 +27,9 @@ class Application extends LaravelApplication

public const CONTEXT_WEBSITE = 0;

protected ?Site $site;
protected int $currentConferenceId;

protected ?Conference $currentConference = null;
protected string $currentConferencePath;

public function isInstalled()
{
Expand Down Expand Up @@ -64,12 +63,17 @@ public function getPhpMinVersion()

public function getCurrentConference(): ?Conference
{
return $this->currentConference;
return Conference::find($this->getCurrentConferenceId());
}

public function setCurrentConference(Conference $conference)
public function getCurrentConferenceId(): int
{
$this->currentConference = $conference;
return $this->currentConferenceId ?? static::CONTEXT_WEBSITE;
}

public function setCurrentConferenceId(int $conferenceId)
{
$this->currentConferenceId = $conferenceId;
}

public function scopeCurrentConference(): void
Expand All @@ -85,7 +89,6 @@ public function scopeCurrentConference(): void
StaticPage::class,
Timeline::class,
PaymentItem::class,
PluginSetting::class,
] as $model) {
$model::addGlobalScope(new ConferenceScope);
}
Expand All @@ -101,11 +104,7 @@ public function getNavigationItems(string $handle): array

public function getSite(): Site
{
if (! isset($this->site)) {
$this->site = Site::getSite() ?? SiteCreateAction::run();
}

return $this->site;
return Site::getSite() ?? SiteCreateAction::run();
}

public function isReportingErrors(): bool
Expand Down
49 changes: 45 additions & 4 deletions app/Classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,69 @@

use App\Facades\Plugin as FacadesPlugin;
use App\Interfaces\HasPlugin;
use Filament\Panel;
use Illuminate\Support\Facades\View;
use Symfony\Component\Yaml\Yaml;

abstract class Plugin implements HasPlugin
{
protected array $info;

protected string $pluginPath;

public function load(): void
{
$this->info = Yaml::parseFile($this->getPluginInformationPath());

View::addNamespace($this->getInfo('folder'), $this->getPluginPath() . DIRECTORY_SEPARATOR . 'views');
}

public function getInfo(?string $key = null)
{
if ($key) {
return $this->info[$key] ?? null;
}

return $this->info;
}

public function getPluginPath()
{
return $this->pluginPath;
}

public function getPluginFullPath()
public function getPluginInformationPath()
{
return FacadesPlugin::getDisk()->path($this->getPluginPath());
return $this->getPluginPath() . DIRECTORY_SEPARATOR . 'index.yaml';
}

public function setPluginPath($path): void
{
$this->pluginPath = $path;
}

public function getSetting($key): mixed
public function getSetting($key, $default = null): mixed
{
return FacadesPlugin::getSetting($this->getInfo('folder'), $key, $default);
}

public function updateSetting($key, $value): mixed
{
return FacadesPlugin::updateSetting($this->getInfo('folder'), $key, $value);
}

public function onPanel(Panel $panel): void
{
// Implement this method to add your plugin to the panel
}

public function onAdministrationPanel(Panel $panel): void
{
// Implement this method to add your plugin to the panel administration
}

public function getPluginPage() : ?string
{
return FacadesPlugin::getSetting($this->getPluginPath(), $key);
return null;
}
}
1 change: 1 addition & 0 deletions app/Conference/Blocks/CalendarBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getViewData(): array
}

return [
'id' => $this->getDatabaseName(),
'timelines' => $formattedTimelines,
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Conference/Blocks/CommitteeBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getViewData(): array
->get();

return [
// Return the organized data with committee positions as keys and arrays of participants as values.
...parent::getViewData(),
'participants' => $participants,
];
}
Expand Down
5 changes: 0 additions & 5 deletions app/Conference/Blocks/InformationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ class InformationBlock extends Block
protected string $name = 'Information Block';

protected ?string $position = 'right';

public function getViewData(): array
{
return [];
}
}
24 changes: 0 additions & 24 deletions app/Conference/Blocks/MenuBlock.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Conference/Blocks/PreviousBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PreviousBlock extends Block
public function getViewData(): array
{
return [
...parent::getViewData(),
'archives' => Conference::where('status', ConferenceStatus::Archived)->get(),
];
}
Expand Down
5 changes: 0 additions & 5 deletions app/Conference/Blocks/SubmitBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ class SubmitBlock extends Block
protected string $name = 'Submit Block';

protected ?string $position = 'right';

public function getViewData(): array
{
return [];
}
}
1 change: 1 addition & 0 deletions app/Conference/Blocks/TimelineBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function getViewData(): array
}

return [
'id' => $this->getDatabaseName(),
'timelines' => $timelineData,
];
}
Expand Down
9 changes: 4 additions & 5 deletions app/Conference/Pages/Committe.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Conference\Pages;

use App\Models\Participant;
use App\Panel\Resources\Conferences\CommitteePositionResource;
use Rahmanramsi\LivewirePageGroup\Pages\Page;

class Committe extends Page
Expand All @@ -22,11 +23,9 @@ public function getBreadcrumbs(): array
protected function getViewData(): array
{
// Retrieve participants with their associated committee positions.
$participants = Participant::with('positions')
->whereHas('positions', function ($query) {
// Filter participants to include only those with 'committee' type positions.
$query->where('type', 'committee');
})
$participants = Participant::with([
'positions' => fn ($query) => $query->where('type', CommitteePositionResource::$positionType),
])
->orderBy('order_column') // Order the retrieved data by the 'order_column'.
->get();

Expand Down
20 changes: 10 additions & 10 deletions app/Console/Commands/CreatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public function handle()
required: false,
);

$conferenceId = select(
label: 'Where the plugin will be installed?',
options: Conference::all()
->pluck('name', 'id')
->prepend('Website', 0),
);

if ($conferenceId) {
app()->setCurrentConference(Conference::find($conferenceId));
}
// $conferenceId = select(
// label: 'Where the plugin will be installed?',
// options: Conference::all()
// ->pluck('name', 'id')
// ->prepend('Website', 0),
// );

// if ($conferenceId) {
// app()->setCurrentConference(Conference::find($conferenceId));
// }

$pluginDisk = Plugin::getDisk();

Expand Down
4 changes: 2 additions & 2 deletions app/Facades/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Support\Facades\Facade;

/**
* @method static string getPlugin(string $pluginName)
* @method static string getPlugins()
* @method static \App\Classes\Plugin getPlugin(string $pluginName)
* @method static \Illuminate\Support\Collection getPlugins()
*/
class Plugin extends Facade
{
Expand Down
23 changes: 0 additions & 23 deletions app/Http/Middleware/BootPluginMiddleware.php

This file was deleted.

7 changes: 1 addition & 6 deletions app/Http/Middleware/IdentifyArchiveConference.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public function handle(Request $request, Closure $next): Response
return abort(404);
}

$conference = Conference::query()
->where('path', $request->route()->parameter('conference'))
->first();
$conference = app()->getCurrentConference();

if (! $conference) {
return abort(404);
Expand All @@ -38,9 +36,6 @@ public function handle(Request $request, Closure $next): Response
break;
}

app()->setCurrentConference($conference);
app()->scopeCurrentConference();

return $next($request);
}
}
14 changes: 11 additions & 3 deletions app/Http/Middleware/IdentifyCurrentConference.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Middleware;

use App\Models\Conference;
use App\Models\Enums\ConferenceStatus;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -18,14 +19,21 @@ class IdentifyCurrentConference
*/
public function handle(Request $request, Closure $next): Response
{
$conference = Conference::active();
$conference = app()->getCurrentConference();

if (! $conference) {
return abort(404);
}

app()->setCurrentConference($conference);
app()->scopeCurrentConference();
switch ($conference->status) {
case ConferenceStatus::Archived:
return redirect('archive/' . $conference->path);
break;
case ConferenceStatus::Upcoming:
return abort(404);
break;
}


return $next($request);
}
Expand Down
Loading

0 comments on commit 0419d8c

Please sign in to comment.