Model

Example of of result of the Model Component

The newRoot() function allows you to define a new chapter within your CMS. To use this, you'll need to pass a new model instance to the function. Models are created using the new keyword followed by a class name starting with \model\.

Adding a Menu Item for the Homepage

Suppose you want to add a menu item in the admin panel for a contact page. You can achieve this by initializing the model class as follows:

@php($page = newRoot(new \model\contact_page));

Adding a Custom Label

If you want a different label to appear in the menu, use the ->label() method. For example:

@php($page = newRoot(new \model\contact_page)->label('Contact'));

Generating Input Fields

Once you've created a root model, you can generate input fields using the $page object. Here is an example of how to generate a text input field for a title:

@php($page = newRoot(new \model\contact_page)->label('Contact'))
<h1>{{ $page->text('title') }}</h1>

Summary

By combining Blade templates, Tailwind CSS, and the newRoot() function, you can efficiently build and style a flexible CMS. Use newRoot() to define chapters, customize labels for better navigation, and generate dynamic input fields for your admin interface.

No more than once a month
Newsletter