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(){

View Helpers

Session The Session class helps you handle session items and flash messages. Interacting with session You can use the set(), get() and has() methods to interact with session items. Session::set(‘hello’, ‘world’); if(Session::has(‘hello’)) echo Session::get(‘hello’); The above script will output this: world Flash messages You can use the flash() method to deal with flash messages. Flash messages will be available via the get() method only