With Laravel Nova, they tried to make everything as easy as possible. So, a Resource
is what adds all the functionality to your Model
, and a Model
represents (in some way) a table in your database. A resource is just a class that extends from Resource
, and has some functions to be completely functional.
So, in your example, you should have a Model
called Post
, the code showing is an incomplete Resource
called Post
(that's why you se those three points before and after the function). As you read the Resource
documentation, you will see that the function fields()
always returns an array of Fields
. The code
MediaLibrary::make('Image')
is, indeed, a field, that's why it's inside de array. The code that you have is just an example, and it's purpose is to illustrate that the MediaLibrary
field can be used as any other field. I strongly recommend that you take enough time to read about Models, Eloquent, Resources and Fields.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…