| 1: | <?php |
| 2: | |
| 3: | namespace Aurora\System\Models; |
| 4: | |
| 5: | use Aurora\System\Classes\Model as ClassesModel; |
| 6: | use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; |
| 7: | use Barryvdh\LaravelIdeHelper\Contracts\ModelHookInterface; |
| 8: | use Illuminate\Database\Eloquent\Model; |
| 9: | |
| 10: | class Hook implements ModelHookInterface |
| 11: | { |
| 12: | public function run(ModelsCommand $command, Model $model): void |
| 13: | { |
| 14: | if (! $model instanceof ClassesModel) { |
| 15: | return; |
| 16: | } |
| 17: | |
| 18: | $modelClass = '\\' . \Illuminate\Database\Eloquent\Builder::class . '|\\' . get_class($model); |
| 19: | $whereParams = ['Closure|string|array|\Illuminate\Database\Query\Expression $column', 'mixed $operator = null', 'mixed $value = null', 'string $boolean = \'and\'']; |
| 20: | $command->setMethod('where', $modelClass, $whereParams); |
| 21: | $command->setMethod('firstWhere', $modelClass, $whereParams); |
| 22: | |
| 23: | $whereInParams = ['string $column', 'mixed $values', 'string $boolean = \'and\'', 'bool $not = false']; |
| 24: | $command->setMethod('whereIn', $modelClass, $whereInParams); |
| 25: | |
| 26: | $command->setMethod('find', $modelClass, ['int|string $id', 'array|string $columns = [\'*\']']); |
| 27: | $command->setMethod('findOrFail', $modelClass, ['int|string $id', 'mixed $id', 'Closure|array|string $columns = [\'*\']', 'Closure $callback = null']); |
| 28: | |
| 29: | $command->setMethod('first', $modelClass, ['array|string $columns = [\'*\']']); |
| 30: | |
| 31: | $command->setMethod('count', 'int', ['string $columns = \'*\'']); |
| 32: | } |
| 33: | } |
| 34: | |