vkovic / laravel-commando

Collection of handy Laravel artisan commands that most projects needs
MIT License
60 stars 10 forks source link

Problem with db: exist: #7

Closed videositefree closed 3 years ago

videositefree commented 4 years ago

Hello, I have a problem with db: exist:

$ test = Artisan :: call ('db: exist'); echo $ test; if it wants to check if db exists it displays 0 even though the database exists. It displays text in the console so no problem worse if I would like to do it with if

vkovic commented 3 years ago

Hey there, the actual approach of the commands are that they will return 0 (null) if command is successful and number greater than 0 (mostly 255) if command fails. You can not check what you are trying to do since it'll always return 0 in your case.

On the other hand, you can use part of the package to check what you desire - something like:

use Vkovic\LaravelCommando\Handlers\Database\AbstractDbHandler;

$database = config('database.connections.' . config('database.default') . '.database');
$dbHandler = app()->make(AbstractDbHandler::class);
$result = $dbHandler->databaseExists($database);
dd($result);