Skip to content

Commit

Permalink
[1.x] Fix laravel11 compatibility issues (#411)
Browse files Browse the repository at this point in the history
* Update LiapConfigPublishCommand.php

* chore: remove unnecessary comments

- rename method

---------

Co-authored-by: imdhemy <imdhemy@gmail.com>
  • Loading branch information
LittleHans8 and imdhemy committed May 25, 2024
1 parent cc4f797 commit bd7303d
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions src/Console/LiapConfigPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,25 @@
use Imdhemy\Purchases\ServiceProviders\LiapServiceProvider;

/**
* Config publish command.
*
* This command is used to publish LIAP configuration file
* This command is used to publish LIAP configuration file.
*/
class LiapConfigPublishCommand extends Command
{
/**
* @const string The failure message to display if file is already published
*/
public const MESSAGE_ALREADY_INSTALLED = 'liap.php is already published.';

/**
* @const string The success message to display if file is published successfully
*/
public const MESSAGE_SUCCESS = 'liap.php published successfully';

protected $signature = 'liap:config:publish {--f|force}';

protected $description = 'Publishes the LIAP configuration file.';

/**
* Executes the console command.
*/
public function handle(): int
{
if ($this->shouldForce()) {
return $this->publishConfig(true);
}

if ($this->isInstalled()) {
return $this->fail();
return $this->publishFailed();
}

return $this->publishConfig();
Expand All @@ -53,9 +41,6 @@ private function shouldForce(): bool
return (bool)$this->option('force');
}

/**
* Publish configurations.
*/
private function publishConfig(bool $force = false): int
{
$params = [
Expand All @@ -73,18 +58,12 @@ private function publishConfig(bool $force = false): int
return $result;
}

/**
* Check if the freya is installed.
*/
private function isInstalled(): bool
{
return File::exists(config_path(LiapServiceProvider::CONFIG_KEY.'.php'));
}

/**
* Should run on command failure.
*/
private function fail(): int
private function publishFailed(): int
{
$this->error(self::MESSAGE_ALREADY_INSTALLED);

Expand Down

0 comments on commit bd7303d

Please sign in to comment.