Laravel Nova: The Only Admin Panel You’ll Ever Need
Let’s face it: the admin panel is one of the most critical components in a web application; sadly, building it is also the most tedious job in the world. Now, developers don’t mind creating forms for sure, but if there are more than a few, it’s enough to make one cry. Forms, controllers, validations, styling . . . the cycle never seems to end as the deadline creeps ever closer.
There’s no shame in admitting that you loathe creating CRUD parts of your application. But if you’re a Laravel developer, you have a very good reason to smile: Nova.
The What and the Why
There are several admin panel and CRUD generators available for Laravel artisans, but the struggle is always real. The selection of an admin panel UI is a project in itself, let along climbing the mountain of coding out everything. As usual, the Laravel core team has been listening, and has finally delivered a neat solution.
[For those who want to relive the magical moments, (and have 90+ minutes to spare!), the Laracon 2018 talk by Taylor Otwell is available here.]
Nova isn’t just an admin panel. It’s a Laravel-aware admin package with lots of goodies built right in. Let’s have a quick look at how it helps create incredibly useful and pleasant admin panels in record time.
Fluent resource management
While even basic CRUD generators can directly work with your database models, Nova goes a few steps further. To begin, full-fledged resource management is built right into Nova, which means working with databases need not be a chore. Even better, Nova recognizes that sometimes we need extra information to be stored in the pivot table, so it supports such relations right out of the box. Otwell says that they’ve done their best to cover all edge cases. But honestly, even if all edge cases aren’t covered, relationship-aware resources are a major relief.
Powerful field types
Laravel developers are used to the Eloquent fields such as string, boolean, timestamp, file, etc. Nova takes this to the next level, offering fields such as Markdown, Code, Location, and more. In other words, if you need to store, say, location, there’s no need to wrestle with the backend; just drop in the Location field and you’re good to go!
Search that just works
An admin panel is nothing without a search facility, and any developer worth his salt knows how much time and effort even a rudimentary search function takes. No more! With Nova, searching is a first-class citizen in your admin panel. While NoSQL search stores are supported by default, you can also integrate with Laravel Scout and enjoy turbocharged search experience.
The best part? Nova’s search function is aware of model relationships! If you search for Categories, for example, the engine also searches across the associated Products. Now, that’s cool!
Apart from this, there’s a global search function that searches across pretty much everything.
Actions (and who did what)
Perhaps the most killer feature of Laravel Nova is the Actionable trait. You can think of this as a simplified form of the Command pattern. Actions are simple classes that use this trait, and thus, end up with a handle() function. Complex actions that span multiple resources can now be written inside this function.
And how does it help? Well, here’s the absolute magic: Once actions have been defined, these appear as a drop-down in the Nova panel, letting the admin fire an action with just a single click!
As if this wasn’t enough, Actions also have a built-in audit trail that logs the user that fired that Action and the timestamp. So, the next time you want to see who issued that unapproved refund, just ask Nova!
Laravel developers are no strangers to Scopes, which let you attach extra queries with your models. While the feature is great, the rub is that it hard-codes into the model, so if don’t want to use it, for example, you end up writing separate code or queries.
Nova solves that problem by providing Filters. Just like Scopes, Filters are extra queries on models, except that these can be attached or detached from the admin UI!
Custom reports are a fact of life when building an admin panel, and here too Nova does a lot (if not everything) for you. Lenses are an abstraction over DB queries that allow you to generate your own interpretation of an underlying model. A Lens can define new “views” for the same model, and can even have its own custom fields. You, of course, need to tell Nova how these custom fields are calculated.
Nova also simplifies calculation and display of metrics. For instance, if you want the User model to also display the trend of total number of users per day, all you need to do is this:
Class UsersPerDay extends Trend
public function calculate(Request $request)
return $this->countByDays($request, User::class);
With this, the graph for users per day will be automatically generated and displayed!
There’s so much more to Nova that it’s not possible to cover it all in one post. But just in case you feel that you need to customize Nova even more, we suggest you head over to Nova Packages before you start reinventing the wheel!
Is there a catch?
Yes, there is, but a very minor one. Nova isn’t available for free for live projects. If you’re a solo developer, you can get it for $99 per site, while if you’re a business with annual revenue of more than $20,000, Nova will cost you $199 per site.
But, honestly, considering what tremendous value Nova brings to the table, the price is laughably small.
If you’ve ever been in a Django vs. Laravel debate (admit it!), the admin panel always comes up as a counter-argument. Well, no more! With the likes of Scout, Dusk, Mix, and Forge, Nova joins the league of extraordinary packages (no intended reference to the PHP project with a similar name!) released by the Laravel core team.
We generally stay away from predicting the future, but it does look likely that Nova will have the kind of impact on Laravel development that Laravel had on PHP web development!