Setting model fields

Alter has built in support to WordPress default fields such as title and thumbnail, you just need to set to true using the $fields attribute. use Hero\Core\Model; class Car extends Model { public $fields = [ ‘title’ => true, ‘thumbnail’ => true ]; } Custom fields Alter allows you to use custom fields in your model: public

Request

Use the request object’s getBody() method to fetch the raw HTTP request body sent by the HTTP client. This is particularly useful for applications that consume JSON or XML requests. Route::get(‘/hello/:name’, function(){ $body = $this->request->getBody(); }); How to Deal with Content-Types By default Alter does not parse any other content-type other than the standard form data because

Dashboard customization

Using Alter you can customize the menu labels on WordPress dashboard: use Hero\Core\Model; class Car extends Model { public $labels = [“Car”, “Cars”]; } You can also customize the icon that will appear on WordPress dashboard: use Hero\Core\Model; class Car extends Model { public $icon = “dashicons-admin-home”; } Alter uses the WordPress Dashicons.

Seeding

Seeding Alter includes a simple method for seeding your database using Seed classes. All seed classes must be stored at /seed directory. Seed classes may have any name you wish, but probably should follow some sensible convention, such as CarSeeder, etc. All seed classes must implement Hero\Core\Seeder interface, the run() method will be called during the seed process. Writing Seeders To generate

Taxonomies

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’]; }