Tinkerwell 4 is out now! Get the most popular PHP Scratchpad application. Learn more

Invoker

Display Model Relations

In addition to custom accessors, Invoker can also show information about your model relations on the table view. Just as with accessors, you can toggle relations by clicking on the "eye" icon.

For belongsToMany/hasMany relations, this field shows the count of all related items. For hasOne/belongsTo relations, it shows a descriptive label of the related model.

In this example, our "Post" model has two relations set up like this:

public function author()
{
    return $this->belongsTo(User::class);
}

public function comments()
{
    return $this->hasMany(Comment::class);
}

When enabling the author and comments relation in the table view, we can see both the comment count, as well as the author name.

When you click on the related model name/relation count, a new tab will be opened showing you the model(s) that are related.

Custom relation labels

When showing the hasOne/belongsTo relations on the table view, you can see that Invoker tries to guess the column to show for the relation label. This includes a set of common column names such as name, title, username, etc.

If you want to rather show a custom column for those relations, you can click on the cog icon next to the relation column and change the relation column to your preference.

Display relation panels

You can see a full-page detail view of a single model, by pressing the icon on the left in the table view.

This opens up a list showing all of the model columns in detail. Similar to the table view, you can specify which columns, accessors, and relations should be visible on the detail screen.

When your model has belongsTo/hasMany relations, Invoker can show these relations as tables within the detail view. Click on the "Panels" button to see a list of available relations. This list could also include custom model detail plugins. Take a look at the plugin documentation to find out how you can create your own custom detail panel.

Once you save the relations that you want to show on the model detail view, you will see an embedded table for the related models.

Just like the index tables for the models, you can filter, export and edit the related models from the detail view.