mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-17 17:47:13 +00:00
generate methods for the SoftDeletes trait (#518)
This commit is contained in:
committed by
Barry vd. Heuvel
parent
d6d99994c3
commit
25b5576f57
@@ -206,6 +206,7 @@ class ModelsCommand extends Command
|
||||
}
|
||||
|
||||
$this->getPropertiesFromMethods($model);
|
||||
$this->getSoftDeleteMethods($model);
|
||||
$output .= $this->createPhpDocs($name);
|
||||
$ignore[] = $name;
|
||||
$this->nullableColumns = [];
|
||||
@@ -746,4 +747,21 @@ class ModelsCommand extends Command
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates methods provided by the SoftDeletes trait
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
*/
|
||||
protected function getSoftDeleteMethods($model)
|
||||
{
|
||||
$traits = class_uses(get_class($model), true);
|
||||
if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) {
|
||||
$this->setMethod('forceDelete', 'bool|null', []);
|
||||
$this->setMethod('restore', 'bool|null', []);
|
||||
|
||||
$this->setMethod('withTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||
$this->setMethod('withoutTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||
$this->setMethod('onlyTrashed', '\Illuminate\Database\Query\Builder|\\' . get_class($model), []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user