Models in Wayfinder

Use models to manage your data, controllers can pass the right data to them so that your model can create, read, update or delete items.

Anatomy of a model

A model should extend the Wayfinder Class so that you have access to all of it's public methods, like so:

class MyModel extends Wayfinder {



Within your class, you can optionally use the __construct() method to automatically run some tasks when the Class is first initiated.

class MyModel extends Wayfidner {

    function __construct() {
        // do stuff here


Demo model

As part of the documentation, an example model is included with the project. You can see the output at /documentation/models/demo-users.

The model is a simplified example of how you can load and manipulate data to pass back to your controller. Look for the models() method in the Documentation controller to see how the model is loaded and used.

Public and private methods

Public methods in a model are used to expose functionality to controllers in Wayfinder. Private methods are more like helpers, and can help you to better organise your code.