You can also register taxonomies using Alter: use use Hero\Core\Taxonomy; Taxonomy::register(‘city’, ‘City’, ‘Cities’); Taxonomy::register(‘province’, ‘Province’, ‘Provinces’); Linking to models And you can easily link taxonomies to models: use use Hero\Core\Model; class CarModel extends Model { public $taxonomies = [‘car_type’, ‘car_color’]; }

Retrieving and Saving data

Retrieving Alter offers a simple and powerful API to retrieve data. Let’s supose that you have this Car model: use Hero\Core\Model; class Car extends Model { public $fields = [ ‘title’ => true ‘thumbnail’ => true, ‘gallery’ => [ ‘type’ => ‘image’, ‘label’ => ‘Gallery’, ‘multiple’ => true ], ‘year’ => [ ‘type’ => ‘int’, ‘label’ =>


In Alter you can specify relations between models such as belongs_to and has_many. Creates the Car model: use Hero\Core\Model; class Car extends Model { } Attachs a field of type checkbox_list with a list of cars into the User model: use Hero\Core\Model; class User extends Model { public $has_many = ‘car’; } Attachs a field of type list with a list of users into the Apartment model: use

Creating models

To create Alter models you need to create a directory named model in your theme’s root directory. Inside the model folder you can create your model classes extending Hero\Core\Model. Note: Alter needs that the file name match the class name to work properly. Generating Models To generate a model you can run the create:model command in your terminal: ./vendor/bin/hero create:model car The above


The HTTP response returned to the client will have a body. The HTTP body is the actual content of the HTTP response delivered to the client. You can use the Response object to set the HTTP response’s body. The response object is binded to route and middlewares closures, so you can access usind $this: Route::get(‘/’, function(){