Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Feb 19, 2024
1 parent 9456cd2 commit 194ad12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/Interfaces/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Cone\Bazar\Interfaces\Models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

interface Transaction
Expand All @@ -25,7 +24,7 @@ public function pending(): bool;
/**
* Mark the transaction as completed.
*/
public function markAsCompleted(?DateTimeInterface $date = null): void;
public function markAsCompleted(): void;

/**
* Mark the transaction as pending.
Expand Down
8 changes: 3 additions & 5 deletions src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,10 @@ public function pending(): bool
/**
* Mark the transaction as completed.
*/
public function markAsCompleted(?DateTimeInterface $date = null): void
public function markAsCompleted(): void
{
$date = $date ?: Date::now();

if ($this->pending() || $this->completed_at->notEqualTo($date)) {
$this->setAttribute('completed_at', $date)->save();
if ($this->pending()) {
$this->setAttribute('completed_at', Date::now())->save();

TransactionCompleted::dispatch($this);
}
Expand Down

0 comments on commit 194ad12

Please sign in to comment.