Skip to content

Commit

Permalink
add upgrade command and fix lang problem
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Feb 3, 2023
1 parent 0e5985a commit 50e4847
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 6 deletions.
5 changes: 0 additions & 5 deletions publish/resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ createApp({
render: renderSpladeApp({ el }),
mounted() {
this.$helpers.setDarkMode(this.$helpers.setStorage("dark"));
this.$helpers.langSwitch(
this.$helpers.setStorage("lang")
? this.$helpers.setStorage("lang").id
: "en"
);
},
})
.use(SpladePlugin, {
Expand Down
4 changes: 4 additions & 0 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ class="mb-4 items-start justify-between space-y-2 filament-header sm:flex sm:spa
</div>
</div>
</div>
<x-splade-script>
this.$helpers.langSwitch('{{app()->getLocale()}}');
console.log('{{app()->getLocale()}}');
</x-splade-script>
</x-splade-data>
57 changes: 57 additions & 0 deletions src/Console/TomatoAdminUpgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace TomatoPHP\TomatoAdmin\Console;

use Illuminate\Console\Command;
use TomatoPHP\ConsoleHelpers\Traits\HandleFiles;
use TomatoPHP\ConsoleHelpers\Traits\RunCommand;

class TomatoAdminUpgrade extends Command
{
use RunCommand;
use HandleFiles;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'tomato-admin:upgrade';

/**
* The console command description.
*
* @var string
*/
protected $description = 'upgrade tomato admin to next version can have some changes this command fix this';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
$this->publish = base_path('vendor/tomatophp/tomato-admin/publish');
parent::__construct();
}

/**
* @return void
*/
public function handle(): void
{
$this->info('🍅 Updating Files ...');
$this->handelFile('/tailwind.config.js', base_path('/tailwind.config.js'));
$this->handelFile('/vite.config.js', base_path('/vite.config.js'));
$this->handelFile('/package.json', base_path('/package.json'));
$this->handelFile('/config/tomato-php.php', config_path('/tomato-php.php'));
$this->handelFile('/resources/js', resource_path('/js'), 'folder');
$this->handelFile('/resources/css', resource_path('/css'), 'folder');
$this->callSilent('optimize:clear');
$this->info('🍅 Install NPM packages ...');
$this->yarnCommand(['install']);
$this->yarnCommand(['build']);
$this->info('🍅 Upgrade Done!');
}
}
4 changes: 3 additions & 1 deletion src/TomatoAdminServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TomatoPHP\TomatoAdmin;
use Illuminate\Support\ServiceProvider;
use TomatoPHP\TomatoAdmin\Console\TomatoAdminInstall;
use TomatoPHP\TomatoAdmin\Console\TomatoAdminUpgrade;
use TomatoPHP\TomatoAdmin\Views\Aside;
use TomatoPHP\TomatoAdmin\Views\Footer;
use TomatoPHP\TomatoAdmin\Views\GuestLayout;
Expand Down Expand Up @@ -65,7 +66,8 @@ public function register(): void
]);

$this->commands([
TomatoAdminInstall::class
TomatoAdminInstall::class,
TomatoAdminUpgrade::class
]);
}

Expand Down

0 comments on commit 50e4847

Please sign in to comment.