How to Create CMS with Laravel Nova
By: Jaymine Shah
Tags: Web Applications, Laravel, Laravel Nova, Hire Laravel Developer, Laravel Framework

Laravel Nova

Nova is administration panel for Laravel application development that designed with a clean and beautiful design. Nova is powered by Vue.js, Vue Router, and Tailwind.css which is powerful and flexible to build custom tools, cards, and fields. Nova is configured entirely using simple PHP classes; configuration is not stored in the database. Pricing of Nova is $99 per site for a solo license and $199 per site for Businesses & Teams with a pro license. Once you have a license you will download nova files and install it with the composer. Although it’s worth to use the license as it provides awesome features.

There is plenty of CMS available in the market like WordPress, Magento, Joomla etc. So here are the reasons to use laravel CMS:

It’s very effective and lightweight content management. It’s not necessary to learn any CMS Purely object-oriented Easy to customize

So Nova is perfectly suitable for lightweight CMS, but it can’t use to build complex CMS because it takes a lot of efforts. By using nova user can easily perform CRUD operations as well searching and filtration of data. Let’s see the topics provide nova:

Resource Fields Actions Filters Lenses Search Metrics Authorization

1. Resource:

The resource is the backbone of the Nova, each of resource has its own class. As simply we can say the resource is list page, detail page, and an edit/create page.

namespace App\Resources; use App\User;

use Illuminate\Nova\Resource; class UserResource extends Resource { protected $model = User::class; public function fields() {

return [

ID::make()->sortable(),

Text::make('Name')

->sortable()

->rules(['required']),

Gravatar::make(),

];

} }

2. Fields:

There are many types of fields like Text, ID, Date, etc… As well you can also build your own custom field and you can use it in your resource. Many of fields are sync column in a database, for a Text shows an <input> and matches to a VARCHAR data type. It’s about a single UI item, but there are some fields that have one UI element for multiple columns/UI elements. So these type of fields might not have database columns.

Some of the field types:

ID

Text

Textarea

Password

Boolean

Markdown

Trix

Code (with customizable properties about which language you’re working with for syntax highlighting)

DateTime (with a super slick picker)

Date (with a super slick picker)

BelongsTo

HasMany

MorphMany

ManyToMany etc.

File — customize the disk, store the original name, store size etc.

Image — like the file, but with image previews and thumbnails

Avatar-like image, but shows next to the item in search results

Video

Gravatar

Place

Country

Place fields:

function location() {

return [

Text::make('Address'),

Text::make('City'),

Text::make('State'),

Text::make('Zip'),

Country::make('Country'),

];

}

Formatting fields

Text::make('File', 'file', function ($value) {

return number_format($value / 1024, 2) . 'kb';

});

Modification

function customization() {

return [

Text::make('Zipcode')

->rules(['required'])

->creationRules(['rules here'])

->updateRules(['rules here'])

];

}

3. Actions:

Actions are classes that used in for perform task on a collection of items. To add an action into your class, just use actions() method on your resource, and return your actions in there:

class NewActionResource { // ...

public function actions() {

return [

new Actions\Publish,

];

} }

4. Filter:

Filters are quite similar to actions; as they are defined as simple PHP classes that enable you to scope your queries with the query builder. Filters are shown up in a drop-down on the index page and let you show only items that match this filter. As similar to action, the filter defines with filter() method:

class NewFilterResource { // ...

public function filters() {

return [

new Filters\PublishedPosts,

];

} }

5. Lenses

Lenses allow you to customize or build different views for a resource with full control over the underlying query and fields returned. Lenses can be used in the resource’s index page when it’s defined.

You can also use fields() and filters() and actions() methods on your Lens class, just like on resources.

6. Metrics

There are three standard metrics,

Value Metrics: To make the value metric, Trend Metrics: To make the trend metric, Partition Metrics: To make the third type of pie graph, modify your trend metric.

All three metrics makes easy to generate a custom matrix for your application. It will available in resource view of the index, while you define on a resource.

7. Authorization

Nova integrated with laravel authorization policies. Nova resources automatically leverage your existing application policies to determine a user’s abilities. Nova takes a simple approach to authorization that leverages many of the laravel features you are already familiar with.

Contact Laravel Development Company to develop your Business mobile app or web application with elegant design. Contact us to Hire dedicated Laravel developer today or reach us at inquiry@techcompose.com for any assistance regarding larval development requirement.