nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
773 stars 108 forks source link

CRUD OPERATIONS #84

Closed desarrollowebvnzla closed 7 months ago

desarrollowebvnzla commented 7 months ago

Hello, I need to give the application user the option to perform CRUD operations in: Countries, State, Cities. This is because you need to manage, activate/deactivate at your convenience, also be able to use softdelete, is there a way to do it? since you cannot publish models/migrations.

nnjeim commented 7 months ago

hi @desarrollowebvnzla The package is not covering this scenario. However you can copy the code in vendor\nnjeim to any other local folder of your choice and change the paths and the relative paths.

Regarding the crud operations you are look for: At the moment there is only an index method / route per countries, states, cites .... etc... you need to add a :

Route:delete('/countries', [Controllers\Country\CountryController::class, 'delete'])->name('countries.delete');

The method delete is not found in the controller and should not be added in it.

You need to create a request class in Http\Requests\Country and name it DeleteRequest You need to create an action class in Actions\Country and name it DeleteAction. You can edit the migrations where you need soft delete by adding $table->softDeletes();

The action is responsible to soft delete the country record Same applies for the restore method.

My recommendation is to copy all the code and restructure it as the folder structure is not relevant to a normal project but to a package, in the sense that all files in the folder src should be moved to different folders. the migrations, the routes should be moved... etc... You need to see all functioning and you need to understand the abstraction i tried to describe above. The lifecycle of a request should remain like: Route -> Request Class -> Action

Unfortunately there is no intention to modify the package to support crud operations at the moment. The only way for you is to copy the code and restructure it, add the needed routes, request classes and actions.