Skip to content

Commit

Permalink
getActualClassNameForMorph
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed May 16, 2024
1 parent 9f87a35 commit cb6c34e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Models/TransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Arr;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

Expand Down Expand Up @@ -64,4 +66,21 @@ public function transactionable()
{
return $this->morphTo();
}

/**
* Retrieve the actual class name for a given morph class.
*
* @param string $class
* @return string
*/
public static function getActualClassNameForMorph($class)
{
$value = Arr::get(Relation::morphMap() ?: [], $class, $class);

if (is_callable($value)) {
return $value();
}

return $value;

Check warning on line 84 in src/Models/TransactionEvent.php

View check run for this annotation

Codecov / codecov/patch

src/Models/TransactionEvent.php#L84

Added line #L84 was not covered by tests
}
}

0 comments on commit cb6c34e

Please sign in to comment.