Skip to content

Commit

Permalink
Fixes tracing modal
Browse files Browse the repository at this point in the history
  • Loading branch information
yordadev committed Dec 21, 2024
1 parent 21a7947 commit 99b6822
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/Models/ShortUrlTracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ShortUrlTracing extends Model
/**
* @var bool
*/
public $incrementing = true;
public $incrementing = false;

/**
* @var string
Expand All @@ -24,7 +24,7 @@ class ShortUrlTracing extends Model
/**
* @var string
*/
protected $primaryKey = 'id';
protected $primaryKey = 'short_url_id';

/**
* @var string[]
Expand Down
20 changes: 11 additions & 9 deletions src/Repositories/UrlRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ public static function findOwnershipUrls(string $owner_type, int $owner_id): Col
public static function getOwnershipUrlsCount(string $owner_type, int $owner_id): int
{
try {
return ShortUrl::whereIn('id', function ($query) use ($owner_type, $owner_id) {
$query->from('short_url_ownerships');
$query->where([
'ownerable_type' => $owner_type,
'ownerable_id' => $owner_id,
]);
$query->select('short_url_id');
})->count();
return ShortUrl::query()
->whereIn('id', function ($query) use ($owner_type, $owner_id) {
$query->from('short_url_ownerships');
$query->where([
'ownerable_type' => $owner_type,
'ownerable_id' => $owner_id,
]);
$query->select('short_url_id');
})
->count();
} catch (Exception $exception) {
throw new UrlRepositoryException($exception->getMessage());
}
Expand Down Expand Up @@ -94,7 +96,7 @@ public static function findByPlainText(string $plain_text): ShortUrl
{
try {
return ShortUrl::where(
'plain_text', 'like', $plain_text.'%'
'plain_text', 'like', $plain_text . '%'
)->with(self::defaultWithRelationship())->firstOrFail();
} catch (Exception $exception) {
throw new UrlRepositoryException($exception->getMessage());
Expand Down

0 comments on commit 99b6822

Please sign in to comment.