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

Update CrudBackpackCommand.php #205

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion src/Console/Commands/CrudBackpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ public function handle()
$this->call('route:cache');
}

$url = Str::of(config('app.url'))->finish('/')->append('admin/')->append($nameKebab);
$url = Str::of(config('app.url'))->finish('/')
->append(
(!empty(config('backpack.base.route_prefix'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @siberfxweb thanks for the PR.

Totally agree with this change. Just 2 things that I would have prefer to address in a different way:
1 - this ternary condition became a little bit difficult to read, we should probably create a variable above like $routePrefix = .... and then ->append($routePrefix).
2 - I think it's safer if we do ->append($routePrefix)->finish('/') and avoid manually adding the /. finish() will take care to add the / if it doesn't exist and does not duplicate it in case it's already present.

If you agree with me, do you mind doing the changes ?

Cheers

Copy link
Contributor Author

@siberfxweb siberfxweb Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what if we use it with empty string, I mean backpack works on the root, then double slashes will be added, how do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, github for idk what reason, marked my main account as spam and no responses, even I was using pro :/ usually its me siberfx

? config('backpack.base.route_prefix') . '/'
: '') . $nameKebab
);

$this->newLine();
$this->line(" Done! Go to <fg=blue>$url</> to see the CRUD in action.");
Expand Down