| 1: | <?php |
| 2: | |
| 3: | namespace Baril\Bonsai\Console\Concerns; |
| 4: | |
| 5: | use Illuminate\Database\Eloquent\Model; |
| 6: | use InvalidArgumentException; |
| 7: | |
| 8: | trait InteractsWithTree |
| 9: | { |
| 10: | protected function checkModel($model) |
| 11: | { |
| 12: | if ( |
| 13: | !class_exists($model) |
| 14: | || !is_subclass_of($model, Model::class) |
| 15: | || !method_exists($model, 'getClosureTable') |
| 16: | ) { |
| 17: | throw new InvalidArgumentException( |
| 18: | sprintf('%s is not a valid model class or does not use the BelongsToTree trait!', $model) |
| 19: | ); |
| 20: | } |
| 21: | } |
| 22: | } |
| 23: | |