Is there a command to safely delete a model in Laravel 5? To create a model we use
php artisan make:model modelname
And that will create a mode
Here is what I've created for my project to remove controller and model
app/Console/Commands/RemoveController.php
argument('name').'.php';
$controllerPath = base_path('app/Http/Controllers/').$controllerName;
if(file_exists($controllerPath)){
unlink($controllerPath);
$this->line('Controller removed successfully.');
}else{
$this->line('No controller found.');
}
}
}
app/Console/Commands/RemoveModel.php
argument('name').'.php';
$modelPath = base_path('app/').$modelName;
if(file_exists($modelPath)){
unlink($modelPath);
$this->line('Model removed successfully.');
}else{
$this->line('No controller found.');
}
}
}
I Hope this helps someone