Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Fix laravel11 compatibility issues #411

Merged
merged 2 commits into from
May 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading