Exploring Built-in Resources 0:00Now that we have installed Nova, let's take a look at the available resources and how we can define them. So out of the box, Nova ships with a user resource that you can find on the sidebar. And you can think about resources as basically Nova representations of your Eloquent models. So a resource in Nova allows us to list the models that we have. We can create new models, so let's just create a new user here. Save it. So there we have the user. Then we can as well see it here in the listing. I can edit the user and update it. Planning a Post Resource 0:41Then we can as well see it here in the listing. I can edit the user and update it. And of course, we can also go and delete existing models and resources. So let's delete this user. All right, so let's see how we can define our own resource and use it in Nova. In the app Nova directory, there is a resource called user. And this is the resource that Nova ships with, which points to the user model. Now for this demo, I created a migration with some posts. So I want to basically just store blog posts and a blog post has a title and it has a body. Now let's create a resource to represent our Eloquent model in Nova and let it be fillable Generating Resource via CLI 1:24So I want to basically just store blog posts and a blog post has a title and it has a body. Now let's create a resource to represent our Eloquent model in Nova and let it be fillable through Nova. So of course, we can go and just create and duplicate this user class. But there is a better way we can use. So let's go and create a new user class and let's call it Nova ships with the CLI command PHP artisan, Nova resource. And there we just give it the name of the resource we want to use. So in our case, it would be post. And as you can see, we now have this post class here, which automatically points to our app post model. Then we have a title.And as you can see, we now have this post class here, which automatically points to our app post model. Then we have a title. So this is the string that represents this specific resource, for example, if you search for it, or if you have it in a drop down. So we're going to change this to title. Then we can define the fields or the columns of our resource that will be searchable. So I want to be able to search for the title and for the body. The next we can define our fields. So let's take a look in Nova refresh. And now we automatically see that we now have a new resource available for posts. And if we click on it, well, I still need to migrate my database table.And now we automatically see that we now have a new resource available for posts. And if we click on it, well, I still need to migrate my database table. So let's do this real quick. OK. Refresh. All right. So there are no posts available. Well, we just created the table. So of course, it's still empty. And if we try to create a new post, well, we don't have any fields available for our resource. Adding Resource Fields 3:15So of course, it's still empty. And if we try to create a new post, well, we don't have any fields available for our resource. So let's fix this by adding two new fields. So we want to add a new field for the title. So it will be a text field. Title. And then Nova ships with a what-you-see-is-what-you-get editor called Tricks. So let's use this for our body. And we still need to import these classes. All right.And we still need to import these classes. All right. So if I now go back and refresh, I have two fields that I can use for this resource. So I have a title and I have a body. So let's just say my first blog post and give it some text. And since this is this Tricks editor, we can add some basic formatting. All right. So let's save it. So now it was saved. It has the ID 1.So now it was saved. It has the ID 1. We see the title and we see the body, which is the HTML representation of what we have just stored. And of course, now we're also able to edit what we just saved. And if we go back to the listing, we also see the ID, which is sortable, and we see the title. So this is the basic behavior on how you can register resources. Now, if you wonder where these resources actually get loaded, and if you don't, for example, want to store them in this Nova directory or want to have them in different sub directories, Configuring Resource Loading 5:00Now, if you wonder where these resources actually get loaded, and if you don't, for example, want to store them in this Nova directory or want to have them in different sub directories, we can fix this by taking a look at the Nova service provider. So this one lives in your app providers directory. And there is this Nova service provider class. Let's open it. And in the service provider that we extend here, we can see a method called resources. And this basically just tells Nova that every resource that is in the app Nova path will automatically be available. Now, if you want to change this, you can just copy this method over to your custom Novaautomatically be available. Now, if you want to change this, you can just copy this method over to your custom Nova service provider and overwrite it. And then you can, for example, change the path. Or if you want to manually register your resources, you can do that as well by using the Nova resources method, which accepts an array of resource class names. So for example, you could do something like app and let's say you have it in a resource namespace and then user. But we just stick for the default, which is just fine. And it doesn't require any manual loading of resources for Nova.But we just stick for the default, which is just fine. And it doesn't require any manual loading of resources for Nova. In the next video, we will take a look at which fields are available that we can use for resources and how we can modify them.