@@ 103-107 (lines=5) @@ | ||
100 | */ |
|
101 | public static function createForModel(Model $model): Version |
|
102 | { |
|
103 | if (!in_array(Versionable::class, class_uses($model), true)) { |
|
104 | throw new NotVersionableModel( |
|
105 | "{$model} not use Versionable " . config('versionable.version_model') |
|
106 | ); |
|
107 | } |
|
108 | $versionClass = $model->getVersionModel(); |
|
109 | /** @var Version $version */ |
|
110 | $version = new $versionClass(); |
|
@@ 145-147 (lines=3) @@ | ||
142 | if ($model instanceof self) { |
|
143 | $source = $model->contents; |
|
144 | } else { |
|
145 | if (!in_array(Versionable::class, class_uses($model), true)) { |
|
146 | throw new NotVersionableModel("{$model} is not versionable"); |
|
147 | } |
|
148 | ||
149 | $source = $model->versionableFromArray($this->versionable->toArray()); |
|
150 | } |