Skip to content

Commit 4e3e11a

Browse files
committed
Add validation when setModel()
1 parent 86ede87 commit 4e3e11a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Builder/ExtractBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace NaimSolong\DataExtractor\Builder;
44

5+
use Exception;
56
use Illuminate\Database\DatabaseManager;
7+
use Illuminate\Database\Eloquent\Model;
68
use Illuminate\Support\Collection;
79
use InvalidArgumentException;
810
use RuntimeException;
@@ -65,6 +67,10 @@ public function getModel(): mixed
6567
*/
6668
public function setModel(mixed $model): self
6769
{
70+
if (! is_subclass_of($model, Model::class)) {
71+
throw new Exception('The provided model, parent must be an instance of Illuminate\Database\Eloquent\Model');
72+
}
73+
6874
$this->model = $model;
6975

7076
return $this;

0 commit comments

Comments
 (0)