Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 30, 2024
1 parent 9597f66 commit 59591d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/laravel": "^10.0",
"laravel/laravel": "^10.43",
"mockery/mockery": "^1.4.4",
"phpunit/phpunit": "^10.0",
"laravel/pint": "^1.6",
Expand Down
33 changes: 17 additions & 16 deletions src/Console/Commands/ClearCarts.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,32 @@ class ClearCarts extends Command
/**
* Execute the console command.
*/
public function handle(): int
public function handle(): void
{
if ($this->option('all')) {
Cart::proxy()->newQuery()->truncate();
Item::query()->where('itemable_type', Cart::getProxiedClass())->delete();
Shipping::proxy()->newQuery()->where('shippable_type', Cart::getProxiedClass())->delete();
Cart::query()->get();

// Cart::proxy()->newQuery()->truncate();
// Item::proxy()->newQuery()->where('itemable_type', Cart::getProxiedClass())->delete();
// Shipping::proxy()->newQuery()->where('shippable_type', Cart::getProxiedClass())->delete();

$this->info('All carts have been deleted.');
} else {
Item::query()
->where('itemable_type', Cart::getProxiedClass())
->whereIn('itemable_id', Cart::proxy()->newQuery()->expired()->select('id'))
->delete();
// Item::proxy()
// ->newQuery()
// ->where('itemable_type', Cart::getProxiedClass())
// ->whereIn('itemable_id', Cart::proxy()->newQuery()->expired()->select('id'))
// ->delete();

Shipping::proxy()
->newQuery()
->where('shippable_type', Cart::getProxiedClass())
->whereIn('shippable_id', Cart::proxy()->newQuery()->expired()->select('id'))
->delete();
// Shipping::proxy()
// ->newQuery()
// ->where('shippable_type', Cart::getProxiedClass())
// ->whereIn('shippable_id', Cart::proxy()->newQuery()->expired()->select('id'))
// ->delete();

Cart::proxy()->newQuery()->expired()->delete();
// Cart::proxy()->newQuery()->expired()->delete();

$this->info('Expired carts have been deleted.');
}

return Command::SUCCESS;
}
}
9 changes: 4 additions & 5 deletions tests/Console/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Cone\Bazar\Tests\Console;

use Cone\Bazar\Tests\TestCase;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Queue;

class CommandsTest extends TestCase
Expand All @@ -12,21 +11,21 @@ public function test_it_can_clear_carts(): void
{
$this->artisan('bazar:clear-carts', ['--all' => true])
->expectsOutput('All carts have been deleted.')
->assertExitCode(Command::SUCCESS);
->assertSuccessful();

$this->artisan('bazar:clear-carts')
->expectsOutput('Expired carts have been deleted.')
->assertExitCode(Command::SUCCESS);
->assertSuccessful();
}

public function test_it_can_install_bazar(): void
{
Queue::fake();

$this->artisan('bazar:install')
->assertExitCode(Command::SUCCESS);
->assertSuccessful();

$this->artisan('bazar:install', ['--seed' => true])
->assertExitCode(Command::SUCCESS);
->assertSuccessful();
}
}

0 comments on commit 59591d8

Please sign in to comment.