Closed brandonferens closed 7 years ago
Thanks! Yeah, you're right :)
There should have been a category_id
in the posts migration. You can put in a PR for that and I can merge it in.
So, there isn't any $fillable or $guarded array. Each row will get added individually if the checkmark is checked for Edit and Add:
You can copy and paste the posts
folder to an admin folder inside of your resources and those files will be used instead. Since the posts already have a separate folder inside of the /vendor/tcg/voyager/src/views/posts those are used instead.
There are 2 files for each datatype which are: browse.blade.php and edit-add.blade.php. If you create a custom type for the 'slug', so products in this case it will be overridden.
I'll be adding more documentation for this soon.
Let me know if that makes sense. Have to bounce right now for some Halloween Festivities.
Talk to you soon.
I pushed up a pull request, but still curious your opinion on the relationships. Having to create the relationships inside of each model is the proper way to go, but having the backend system you've built makes that difficult. I've also noticed that in a couple places you have, for example, pulled all the categories in their own object and the pulled out the one needed for the given post or whatever. That is fine if the project remains small and there aren't many categories.
I'm not opposed to moving the models and whatnot outside of the package and adding those relationships, but then I would potentially miss out on package updates.
I'm wondering if there is a way to dynamically define the relationships... I want to play with some magic methods...
So the dynamic thing didn't workout too well. The last bit of the puzzle was determining the proper namespace. Brick wall.
So instead I decided the best approach would simply be, for the front end stuff at least, to create my own Post model that extends the Voyager Post model. This way, I am not overwriting the package model, nor am I missing out on potential package updates.
@brandonferens, I'm wondering what is the best approach to enable devs to overwrite the models.
Was thinking of using even Contracts
or aliases? Any ideas?
@marktopper I'm assuming what you are wanting to do is extend the voyager models? If so, I would just create a model in my app and instead of extending Eloquent like normal, extend the Voyager class, which ultimately extends Eloquent.
i have the exact same problem, category_id didnt send to the DB. how can I fix this? i cant seems understand the discussion above.
I think I have finally figured out what's on here.
This is a case where the posts table and bread data is build from the seeder, and it's actually missing the category_id
.
I will make sure to add this.
@marktopper, was this ever resolved? Can it be closed? I see a Closed PR, but it was never merged.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
I have been working on building out simple blog for our website using Voyager. This is hands down the best option I've worked with. Thanks for it.
I have run across some issues as follows. Not sure if you have plans to build it out further, if it was missed, or if something more dynamic that I haven't seen is not working properly. It mainly revolves around Posts.
I don't see any relationships for the author or the category in the
Post
model. There doesn't appear to be acategory_id
in the posts migration. I manually added these and attempted to attach a category to a post, but it didn't get writte to the db making me wonder if there is a$guarded
or$fillable
property being created dynamically.If this is all stuff you are okay with me adding in, let me know and I can put it a PR for you. Otherwise, tell me to pipe down ;)