What Files are Inside the CRUD
If you prefer a video version:
Sometimes there is a need to create a new CRUD for existing panel, even after a lot of manual code changes. How to add new CRUD's code into existing system? For that, you need to understand its structure.
When you create a CRUD, minimum of 14 new files are generated automatically - 10 new files, and 4 old ones re-generated.
There may be more changes, depending on CRUDs fields and modules involved.
For example, if you create CRUD called Transactions with a few simple columns like "amount" and "transaction_date", here's the minimum list of generated files:
[New Form Requests]
[New database migration]
[New Blade views]
[Changed main menu Blade view]
[Changed main routes]
[Changed Seeds for Permissions]
[Changed Translation Files for new CRUD]
After every new or changed CRUD, we regenerate all migration files to make sure they are in the right order, to avoid creating foreign keys on non-existing tables. Therefore, keep in mind that you need to double-check the migration files manually, so they still work after you merge changes.
A few more files may change with each new CRUD.
For example, if you add a belongsTo relationship column to other CRUD like Users, then additional these files are touched:
- [Changed] app/User.php
- [New] database/migrations/2019_12_02_relationships_transactions_table.php
If you ticked the checkbox to generate API, another list of new files:
- [New] app/Http/Controllers/Api/V1/Admin/TransactionsApiController.php
- [New] app/Http/Resources/Admin/TransactionResource.php
- [Changed] routes/api.php
And the list may be bigger, with additional field types or modules. But, in short, these are the minimum files you need to download and copy-paste or merge into your existing project code.