CRUD (Create, Read, Update, Delete)
🔥 Hot Tips
- Attach CRUD to any ORM model.
- Single method to auto generate routes and templates for a fully functioning CRUD system.
- Can be used as website, api or both.
- Default CSS provided by Bootstrap.
Generating CRUD
- Ensure the desired
Tina4\ORMmodel is created. - Create an empty
phpfile in your routes folder. - Type in the following command in the file.
- Run any page in the website.
- The CRUD is built completely.
php
<?php
// The path '/crud/catalog' is used for both the route names and template folder structure
(new Catalog())->generateCrud("/crud/catalog");So let's look at what just happenend.
- A landing route
/crud/catalog/landinghas been created which loads the browser based screens. - The single route
/crud/catalogto run the browser screens, or as an api is created. This handles all operations. - The screen templates are created in the
templates/crud/catalogfolder. The first filegrid.twigis the display page. The second fileform.twigis the editing modal. - Both files extend the
public/components/base.twigfile. - These templates are created from the templates found in the
public/components.
Customisation
- Templates can be customized in the
public/componentsfiles. - CSS can be replaced or extended.
- Generated files can be further customised as desired.