Skip to content

Commit b1ec5a1

Browse files
authored
Fix incorrect use and invalid check of Model
1 parent 6b2534f commit b1ec5a1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/DataTableResponder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace LangleyFoxall\ReactDynamicDataTableLaravelApi;
33

44
use Illuminate\Database\Eloquent\Model;
5-
use Illuminate\Database\Query\Builder;
5+
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Http\Request;
77

88
/**
@@ -43,12 +43,12 @@ public function __construct($className, Request $request)
4343
throw new \InvalidArgumentException('Provided class does not exist.');
4444
}
4545

46-
if (!$className instanceof Model) {
47-
throw new \InvalidArgumentException('Provided class is not an Eloquent model.');
48-
}
49-
5046
$this->model = new $className();
5147
$this->request = $request;
48+
49+
if (!$this->model instanceof Model) {
50+
throw new \InvalidArgumentException('Provided class is not an Eloquent model.');
51+
}
5252
}
5353

5454
/**
@@ -119,4 +119,4 @@ public function respond()
119119

120120
return DataTableResponse::success($results)->json();
121121
}
122-
}
122+
}

0 commit comments

Comments
 (0)