Skip to content

Commit

Permalink
Format Code
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io authored and github-actions[bot] committed Nov 27, 2024
1 parent 1a1f707 commit b3028ac
Show file tree
Hide file tree
Showing 19 changed files with 208 additions and 236 deletions.
12 changes: 6 additions & 6 deletions config/filament-themes-manager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

return [
"themes" => [
"scan" => true,
"sections" => [
"/vendor/tomatophp/filament-cms/src/Sections"
]
]
'themes' => [
'scan' => true,
'sections' => [
'/vendor/tomatophp/filament-cms/src/Sections',
],
],
];
4 changes: 2 additions & 2 deletions database/migrations/2023_11_23_190637_themes_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
public function up(): void
{
if(config('filament-cms.features.theme-manager')){
if (config('filament-cms.features.theme-manager')) {
$this->migrator->add('themes.theme_name', 'main');
$this->migrator->add('themes.theme_path', 'themes.main');
$this->migrator->add('themes.theme_namespace', '');
Expand All @@ -23,7 +23,7 @@ public function up(): void

public function down(): void
{
if(config('filament-cms.features.theme-manager')) {
if (config('filament-cms.features.theme-manager')) {
$this->migrator->delete('themes.theme_name');
$this->migrator->delete('themes.theme_path');
$this->migrator->delete('themes.theme_namespace');
Expand Down
38 changes: 19 additions & 19 deletions resources/lang/ar/messages.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php

return [
"themes" => [
"title" => "القوالب",
"single" => "القالب",
"actions" => [
"active" => "تفعيل",
"disable" => "تعطيل",
'themes' => [
'title' => 'القوالب',
'single' => 'القالب',
'actions' => [
'active' => 'تفعيل',
'disable' => 'تعطيل',
],
"notifications" => [
"autoload" => [
"title" => "فشل تحميل القالب",
"body" => "فشل تحميل القالب",
'notifications' => [
'autoload' => [
'title' => 'فشل تحميل القالب',
'body' => 'فشل تحميل القالب',
],
"enabled" => [
"title" => "تم تفعيل القالب",
"body" => "تم تفعيل القالب بنجاح",
'enabled' => [
'title' => 'تم تفعيل القالب',
'body' => 'تم تفعيل القالب بنجاح',
],
"disabled" => [
"title" => "تم تعطيل القالب",
"body" => "تم تعطيل القالب بنجاح",
'disabled' => [
'title' => 'تم تعطيل القالب',
'body' => 'تم تعطيل القالب بنجاح',
],
"deleted" => [
"title" => "تم حذف القالب",
"body" => "تم حذف القالب بنجاح",
'deleted' => [
'title' => 'تم حذف القالب',
'body' => 'تم حذف القالب بنجاح',
],
],
],
Expand Down
38 changes: 19 additions & 19 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php

return [
"themes" => [
"title" => "Themes",
"single" => "Theme",
"actions" => [
"active" => "Active",
"disable" => "Disable",
'themes' => [
'title' => 'Themes',
'single' => 'Theme',
'actions' => [
'active' => 'Active',
'disable' => 'Disable',
],
"notifications" => [
"autoload" => [
"title" => "Autoload Error",
"body" => "The theme autoload class does not exist",
'notifications' => [
'autoload' => [
'title' => 'Autoload Error',
'body' => 'The theme autoload class does not exist',
],
"enabled" => [
"title" => "Theme Enabled",
"body" => "The theme has been enabled successfully",
'enabled' => [
'title' => 'Theme Enabled',
'body' => 'The theme has been enabled successfully',
],
"disabled" => [
"title" => "Theme Disabled",
"body" => "The theme has been disabled successfully",
'disabled' => [
'title' => 'Theme Disabled',
'body' => 'The theme has been disabled successfully',
],
"deleted" => [
"title" => "Theme Deleted",
"body" => "The theme has been deleted successfully",
'deleted' => [
'title' => 'Theme Deleted',
'body' => 'The theme has been deleted successfully',
],
],
],
Expand Down
13 changes: 5 additions & 8 deletions src/Console/FilamentThemeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
namespace TomatoPHP\FilamentCms\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Str;
use TomatoPHP\ConsoleHelpers\Traits\RunCommand;
use TomatoPHP\FilamentCms\Generator\GenerateTheme;
use TomatoPHP\FilamentTranslations\Services\SaveScan;

use function Laravel\Prompts\error;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\text;
Expand Down Expand Up @@ -34,22 +33,20 @@ public function __construct()
parent::__construct();
}


/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$themeName =text(label:'What is the name of the theme?', required: true);
if(!$themeName){
$themeName = text(label: 'What is the name of the theme?', required: true);
if (! $themeName) {
error('Theme name is required');
$themeName = text(label:'What is the name of the theme?', required: true);
$themeName = text(label: 'What is the name of the theme?', required: true);
}

$themeDescription = text(label:'What is the description of the theme?', required: true, default: 'No description');

$themeDescription = text(label: 'What is the description of the theme?', required: true, default: 'No description');

$response = spin(
function () use ($themeName, $themeDescription) {
Expand Down
5 changes: 2 additions & 3 deletions src/Console/FilamentThemesManagerInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct()
parent::__construct();
}


/**
* Execute the console command.
*
Expand All @@ -37,8 +36,8 @@ public function __construct()
public function handle()
{
$this->info('Publish Vendor Assets');
$this->artisanCommand(["migrate"]);
$this->artisanCommand(["optimize:clear"]);
$this->artisanCommand(['migrate']);
$this->artisanCommand(['optimize:clear']);
$this->info('Filament themes manager installed successfully.');
}
}
24 changes: 10 additions & 14 deletions src/Filament/Pages/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,33 @@
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Support\Facades\File;
use Filament\Pages\Actions\ButtonAction;
use Nwidart\Modules\Facades\Module;
use TomatoPHP\FilamentThemesManager\Filament\Pages\Traits\HasShield;
use TomatoPHP\FilamentThemesManager\Models\Theme;
use TomatoPHP\FilamentThemesManager\Settings\ThemesSettings;

class Themes extends Page implements HasTable
{
use InteractsWithTable;
use HasShield;
use InteractsWithTable;

protected static ?string $navigationIcon = 'heroicon-o-swatch';

protected static string $view = 'filament-cms::pages.themes';

public function getTitle(): string
{
return trans('filament-cms::messages.themes.title');
return trans('filament-cms::messages.themes.title');
}

public static function getNavigationLabel(): string
{
return trans('filament-cms::messages.themes.title');
return trans('filament-cms::messages.themes.title');
}

public static function getNavigationGroup(): ?string
{
return trans('filament-cms::messages.content.group');
return trans('filament-cms::messages.content.group');
}

public function disableAction(): Action
Expand All @@ -52,7 +50,7 @@ public function disableAction(): Action
$module = Module::find($arguments['item']['module_name']);
$module?->disable();

$setting = new ThemesSettings();
$setting = new ThemesSettings;
$setting->theme_name = null;
$setting->save();

Expand Down Expand Up @@ -88,7 +86,6 @@ public function deleteAction(): Action
});
}


public function activeAction(): Action
{
return Action::make('active')
Expand All @@ -98,26 +95,27 @@ public function activeAction(): Action
->color('success')
->requiresConfirmation()
->action(function (array $arguments) {
if(!class_exists(json_decode($arguments['item']['providers'])[0])){
if (! class_exists(json_decode($arguments['item']['providers'])[0])) {
Notification::make()
->title(trans('filament-cms::messages.themes.notifications.autoload.title'))
->body(trans('filament-cms::messages.themes.notifications.autoload.body'))
->danger()
->send();

return;
}
$module = Module::find($arguments['item']['module_name']);
$module?->enable();

$themes = Theme::all();
foreach ($themes as $theme){
if($theme->module_name != $arguments['item']['module_name']) {
foreach ($themes as $theme) {
if ($theme->module_name != $arguments['item']['module_name']) {
$module = Module::find($theme->module_name);
$module?->disable();
}
}

$setting = new ThemesSettings();
$setting = new ThemesSettings;
$setting->theme_name = $arguments['item']['module_name'];
$setting->save();

Expand All @@ -132,8 +130,6 @@ public function activeAction(): Action
});
}



public function table(Table $table): Table
{
return $table
Expand Down
19 changes: 6 additions & 13 deletions src/Filament/Pages/Traits/HasShield.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait HasShield
{
public function booted(): void
{
if(filament('filament-cms')->isShieldAllowed()){
if (filament('filament-cms')->isShieldAllowed()) {
$this->beforeBooted();

if (! static::canAccess()) {
Expand All @@ -35,17 +35,11 @@ public function booted(): void
}
}

protected function beforeBooted(): void
{
}
protected function beforeBooted(): void {}

protected function afterBooted(): void
{
}
protected function afterBooted(): void {}

protected function beforeShieldRedirects(): void
{
}
protected function beforeShieldRedirects(): void {}

protected function getShieldRedirectPath(): string
{
Expand All @@ -65,10 +59,9 @@ protected static function getPermissionName(): string

public static function canAccess(): bool
{
if(filament('filament-cms')->isShieldAllowed()){
if (filament('filament-cms')->isShieldAllowed()) {
return Filament::auth()->user()->can(static::getPermissionName());
}
else {
} else {
return true;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/FilamentThemesManagerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class FilamentThemesManagerPlugin implements Plugin
{

public function getId(): string
{
return 'filament-themes-manager';
Expand Down
Loading

0 comments on commit b3028ac

Please sign in to comment.