Transcript
Looking for something specific? Feel free to search the page for keywords to find a specific portion of the live stream that interests you most.
okay cool came on and the screen was black so i wasn't quite sure if it was working
um so i think instead of doing like a proper lesson this week um with the holiday over here in the us and
everything um kind of also had some other stuff that threw me off
schedule i think i might just go ahead and stream twice this week so we'll do one today and then we'll try to do one tomorrow as well
we'll be building out more of the jagerko site so not a whole lot code wise has changed at
least you know back end wise since the last stream i did go through and kind of stub out the home page
subject to change but this is all just hard-coded stuff so nothing dynamically pulling or anything
like that it's where's my there it is it's quite literally just like if i go
into the index page of resources views it's all right here so
um so like the sidebar latest lessons it's all just hardcoded right here sorry i had to
bark at my dog there she was growling weren't you yeah um
we need to do that at some point but today in particular what i want to do is actually get the remainder of the models
and migrations that we're going to need at least storage wise set up so for a post we're
going to have uh where did i put it so i'm going to actually change this up so previously i
had a post model a series model and then topics
model but i think we're going to change it up because this would allow things to be a little bit more dynamic in naming
so we're going to do a post model i guess i shouldn't highlight a collection model and then a taxonomy
model so a collection would be things like the series however that also opens up the possibility for me to allow you
guys to create your own playlists or whatever since underneath the hood that is all
considered a collection and then we could have something like a collection type that would say all right this is a
course it's a series it's a playlist so it just allows things to be a little bit more dynamic as opposed to having a model just called series
and then we also have a taxonomy which is also more generic than just saying this is specifically a topic right so this
allows us to have a kind of a tree-based node system for our topics so we could
do you know a topic like adonisjs then we could do subtopics for each like little adonis js
sub set package um so one for like edge i need to stop highlighting one for lucid one for the
validator and so on and then that would also allow for us to do that same thing with other libraries as well like alpine
and vue um so i think that's the approach at least that i want to try out and see how it
goes and then we have our intermediary tables with like the post users which is i think we already have that and then the collection posts post taxonomies and
collection taxonomies as well so collections themselves would be able to have taxonomies assigned to them too
so we'll see how that goes um and then one last thing that i did is if
you recall on the last stream um i think it was we were getting like the
little avatar logo wasn't spinning up and that's because we were actually hitting rate limiting with google so i
was using this url straight from google um so instead what i did is i added a hook
to save this into my digitalocean spaces let's see where it was at social service
so whenever we're doing a find or create user every time that a user logs in just in case their avatar changes or whatever
we refresh the avatar using that user user data that we're getting from the
social service and then that was not deprecated or at least that wasn't lined
up whenever i wrote this okay well i'll need to change that evidently eventually but what it will do is it will fetch the
social service url then it will turn it into a array buffer and then turn it into a buffer and then i have it saving
up into well then i get the file name and then i have it checking whether or not exists
if it does exist then it will destroy it and then it will re-upload the new version
so that's what i have going on right there um apart from that that's all that's changed so let's go ahead and
oh shoot i already created topic controllers and all that all right so we'll end up deleting did i do the
relationship here i did okay well why don't we just leave that in
there we'll go ahead and make the models and that for the new here let me get this over onto the side so that i can
cheat and see exactly what all we need here so that i don't have to go back and forth
okay so we're going to have we already have user we already have post we need one for collection so let's do node ace
make model collection
and node ace make model taxonomy now what i did not do is
pre-think what columns i'm going to need for this so we might need to just kind of play
that by ear and then we need a migration for the
intermediary table so that would be node ace make migration um
nope yeah no collection posts would be the first new one and then
we have one for collection taxonomies and then we have another one
that's not collection based at all that is post taxonomies okay
so there we go that should be all of the models and migrations that we need to generate we will go ahead and get rid of
the topic here in a little bit uh let's do the migration first let's
try to think through what all columns we're going to need for this so for the collections first we know we're gonna
need a um a collection type now we
could create a collection type table um i think at least starting out that's okay
to just have it as an enum and then if at any point we determine you know down the road that we need it
to be a table we can always do that so let's do table dot um
well i guess first we'll start with well yeah so integer um and then that would be collection
type id unsigned and that won't that won't reference anything right now and then
we'll have table string um collection we'll need to have a name
i want to say let's limit it uh let's do 75 yeah let's do 100 yeah
um and then let's see
that might be good enough starting out um well hold on a minute so we would want a couple of
other things um so like um
on the current site if we go to the old
not that one this one so i have it marked as being oops i clicked on it outdated um so we would want something
like a status indicator to tell whether or not it's in progress outdated
completed something like that so why don't we also do another integer
table dot integer um status id that collection status id
status id what's our current i know i already have a status enum
it states yeah yeah we could use the states
because then you know if it's we could add one for in progress that
wouldn't be too bad but then if it's completed then it would just be yeah i don't know
that's not one to one what's status oh there we go
status perfect all right so yeah we'll just do status id um so step status id that will be
unsigned that won't reference anything because that does not have its own table either
um [Music] i'm going to note that down on my little note here
just so i don't forget that it's actually there well i don't have anywhere to note it
okay nevermind um so then that would take care of that why don't
we do this description oh string um dude description
that could be 255 table string why don't we do why don't we do a page title and meta description too
i don't think those are ever going to need to be different
than the name and description but why not
okay actually meta descriptions are supposed to be what what what are those supposed to be
oh i have that as two okay well that works just give it a 255. um
and then why don't we also do an icon so we'll attach this to the assets as well
do we want that to be a single or do we want an intermediary table for that though
why why don't we start out as single so we could do table integer asset
id unsigned and this one will reference id and table
assets i had to think for a second what the heck asset ids table was um
okay that should be a good starting point for the collections i think should get us oh oh um
collections should be able to nest within one another um
at least one layer so we're also going to want table dot integer that
uh parent how do you spell point there we go parent id parent collection id let's
just do parent id um references id dot in
table uh table name
okay so that should be good and then we need to do the taxonomies
uh taxonomies are going to be the same they're going to be nestable within one another so this will have another integer parent id
dot unsigned references id and table
uh this dot table name there we go all right and then table dot
um let's see this is gonna be pretty similar to the topics table so it's not
going to take much yeah collections also need a slug good point so um let's also do that before i forget
on the collection so just after the name we will do slugs since the name is 100
we'll do this log as 150 to account for the hyphens and all that other stuff that just might need to
change based off of the title and then this will have the same
um it's also going to have a name so we'll do name first
these should be shorter i would say they should not exceed 50. um and then we'll do 100 for the slug on
that one oh yeah i need to do the null not no differentiation here so name should be
not null description that's fine um actually you know what i'm going to do
not nullable and default it yeah there we go
that way we don't have to do knowledge checks we could just do empty string checks
okay and then this is nullable i'm going to explicitly
note that this is not nullable and we will default it
to um
state status status right there status dot
in progress i guess that would be the appropriate one to default to and then collection type id we need to
create an enum for that actually let's do that real quick so enums
new file collection type
oh i didn't capitalize type
okay there we go enum collection type
and then this would be let me use my cheat sheet because i already blinking on it
of course series playlist things like that um so
why don't we do series as one courses two
and playlist is three
all right and we will default that
to
course
okay so that table should be all good and then taxonomies
so we have the parent we have the name we have the slug why don't we also kind of mimic this a little bit closer to the
collection so it would have page title it would have description um and it would also have an asset id as
well because why not so we'll just copy those
um those status id wouldn't make a whole lot of sense so this should be good um
for the taxonomy and then we have the what is this collection posts
so that's pretty similar to the post series table that i had on the um
old project i'm gonna cheat and see what all i had on there because i i think it i don't remember if i it should have
sword order um oh nevermind i remember so we have
table dot first and foremost we need the id integers so this would be post id
unsigned references the id in the table
posts and then we have integers almost series
collection there we go collection id unsigned
references id in the table collections
and then we're going to have table dot integer we're going to have
so because collections we're gonna have the same kind of thing going on with taxonomies to an extent
um
no actually no we don't need to worry about that so previously um
what i had going on on the did i have it open i thought i opened it up on the previous project which
i did i never liked it the way that i did this um
if we take a look here where is series oh no post series sorry um i had
a sort order but then i also had a module sort order for the actual module
excuse me and then the modules were set up just based off of the actual group uh
like the same module string so that's kind of a cheap way to do it this way is going
to be i think a little bit better so instead of doing it to where we just checked to see you know which all
collection posts records have the same module and group those all together we can just do it based off of the parent
ids and then sort based off of those so these should just need a single sort order column instead of having one for
the module one for the actual parent level and this will be non-nullable and we'll
just default that to zero because it may not be necessary in every
case okay and i think that's it
for the collection posts we can always add to it later on and then collection taxonomies
is i don't even know if we need to worry about that sounded good in my head whenever i was
thinking through them schema
but now that i'm here thinking about what would actually go inside of it i don't know
so why don't we do so first and foremost we'll go ahead and
get the um ids in place
references id and table taxonomies
but apart from that like i think that's mostly just binding you know what what
we'll leave it like that you never know could come in handy we'll leave it like that and we'll see if we end up using it whenever we actually go to implement
things and then post taxonomies these will definitely be needed so we'll do integer
post id references id and table
posts
and then we have table dot integer um taxonomy id
uh text on me id unsigned references
id in table uh okay i'm pretty sure i spelt that
wrong according to the highlight i did not but
i rewrote it anyway um and then these will have a sort order as well i think
i'm going to go ahead and just go ahead and plop a sword order on this too on the collection taxonomies
i don't think it's going to need it if we do use it but it'll be there just in case
okay so let's go ahead and fill out the models with um these so again i'm just going to copy all of
those and then we need to find them so here's collection
paste that in there let's line it up
okay i'll leave those there for a second
um and then we'll want to do at column public
drop that in do the type and then
let's see here what have we got going on they are all not nullable aren't they except for the asset id
okay good enough so we're going to just get rid of all of those um and then there's
one more thing i need to do what is it oh
camel case there we go and then we need to switch these from
integer to number
and then i need to do ordinal on the asset id
since it's nullable okay there we go so collection should be good
now we need to do taxonomy oh actually
so we have collection type that is not just a type of number but that is a
collection type and then the status id is not just a number but it is a
status there we go now that is good all right so now let's do the taxonomies
okay
so at column drop that down public
cut that out paste it in camel case it
and then after that we will is any of our um asset ids nullable
oh i need to go put required um not nullable on the name and on the
well no parent id is nullable actually i need to go do that on the collection too because paranoid is nullable there too i just didn't
explicitly just specify that okay and then we'll go to our space change
these two numbers it's always those little things right
number number or null on both of those actually
okay and then we'll do the same thing on collection
there so parent id should definitely be ordinal okay
is that yeah that should be good and then we on what was it on the taxonomy table we need to go put
no that is nullable so i can i can go ahead and explicitly specify that just so i don't confuse myself and then not nullable
on the name okay that should be good and then we just
need to define the relationships for these intermediary tables to actually make them workable with lucid so
let's go do that so collection here
let's see collection should
collection has collection to post really shouldn't that also be to the
user why did i not do that
hmm oh yeah okay because it's more so to yeah you're not necessarily a user
but then if you do a playlist then it would be to yeah um
let's make an explicit user id on that i guess
at least for right now um
do owner id how about that
okay that should be good and then we will define that so that that way if i need to add
the ability later on for more i don't know why i would but for more people to be on it then we could just
null out that column or whatever and create a separate table for it um so where was that collection so we'll
go ahead and do the user first so at that well we need to add that into the
actual model as well so at column
public no owner id owner id
um which is of type number and um yeah
and then we would do at belongs to
if i'm remembering my rule right on that uh belongs to
user public owner id
belongs to type of oops user okay something didn't import there was
it belongs to it was it user
or i got something wrong am i misremembering something here i
must be let me go cheat and look at one of the others it's been a it's been a minute
ah it looks pretty right let me try rewriting it maybe i fledge something up
belongs to user all right what are you actually
complaining about let's read it argument of type collection is not assignable to a parameter of type owner id belongs to
that um okay
oh well okay at least there that needs to yeah yeah something as simple as tacking an
id on the end of it all right there we go and then this also needs
uh a mini to many with post so many too many
with uh post i'm going to explicitly specify the pivot table
as what is it collection posts
and then we have the pivot columns of what did we put on it collection
posts just sword order okay
there we go public posts
many too many type of post
and then collection taxonomies which is the one that we weren't quite i wasn't quite sure whether or not i'd actually
need whoa no we're not tax enemies
there we go taxonomy scroll up a little bit
this one has pivot sure column of i believe i just put sword order on that
and then a pivot table
of collection taxonomies public taxonomies
many to many type of taxonomy there we go okay so that should
be for the collection and then we just need to go do the taxonomy and the user um
taxonomy is very much so will be specific to just jaeger so there won't necessarily need to be a user uh per se
on that um so we'll do at
nope see oh we need to go do the asset as well so there's asset id on there
so we'll do that so that would be what that that would be another belongs to so let me put that up with the other belongs to
asset public asset um
belongs to type of asset
okay now that should be good if i go take a look at everything else parent we need
to do the parent too oh boy there's always one more thing in there all right so at
belongs to itself so collection
public just name this parent belongs to type of
collection all right now that should be it now let's go do the taxonomy okay so we
have parent so i'm gonna and and we have asset
so i'm gonna go ahead and just copy and we'll we're gonna have posts
so why don't we just copy all three of those and we'll just need to import stuff
so belongs to asset
belongs to collect nope not collection type sorry
collection and
many to many post
and many to many okay and then the name of this pivot table then goes to
what what am i on taxonomy and this is for post so that would be post taxonomies
and that also has a sort order um
isn't there one more oh yeah the inverse of the taxonomy um
so here i can actually copy and paste this and we'll just inverse it
okay so instead of taxonomy here which is the model that we're currently within this would be
collection and then instead of collection no yes no that would still be collection
taxonomies and instead of taxonomies that would be collections
and then instead of type of taxonomy that would be type of collection there we go now we
got the information that and then we can we need to go tech on collections onto the user so
that's going it's going to be a has many so we'll put that with asmini's
and uh collection is the model for that
yeah flip that up there we go and i said i was putting
this with the has minis but i put it right underneath it has one so let's put that with the has many
okay and then we're gonna be getting rid of topics so i'm gonna go ahead and do that within here
so there goes topic bye bye um i'm going to get rid of the model if
i can find it there it is so delete
and then we will go ahead and because i don't believe we've done anything yeah now the controller's
completely empty so it should be a-okay to just get rid of
it okay that looks good
and then we didn't do series yet so that's weird that i did already had topic in there but not serious
but that works um okay so let's go ahead and
roll back and try running the migrations let's see if we run into any issues and then
before we rerun the migration we'll go ahead and get rid of the topics migrations so be topic post topics
and i think that's it so node ace migration
roll back hyphen hyphen back batch zero so say goodbye to everything
and then node ace migration run oh no
get rid of you and you
all right and i don't know why they just scrolled me up so all right looks good
let's go ahead and hit run and everything ran okay let's go ahead
and let's log out
and then oh
all right let's see what we've got going on here so can i find module topic where
model post so all right i took it out of the user but i forgot to take it out of the post as well so let's do that so we're going to want
to get rid did i i might not have gotten rid of the import in the user either i think i just deleted out the um
relationship so there we go now it's out of the post
uh let's go take care of the import on the user okay so now that we have that oops did not
mean to open safari my bad all right
cool so now we're signed out um let's go ahead and sign up
and all right my fix is in place but i fixed the scroll so as you can see here on the
login the scroll is fixed but my fix is still in place here so we'll need to fix that at some point but
all right did i break this
i might have broken this i was working on this earlier today and i could not remember what i was working on
but i had to abruptly leave so it could be that i broke something and never finished it my
bad if that is indeed the case no value in column email of relation
users violates non-null constraint insert into users avatar url created at
google access to a control id values returning id
so it looks like it wasn't setting an email but doesn't google come with the email
like you need a email to have a google account i'm pretty sure
all right well if i didn't change so much view-wise i would go look and see what
the git history was but if i had to guess it's something with the off social changes that i did with the
steve did i change anything in particular two emails here
you're gonna have to assume it's trying to insert it into the user right insert it to users yes
so it would probably be this right here oh i didn't provide the email
really i didn't provide the email
yeah no no emails lit up what are you lit up about string or null oh okay yeah well both
github and google the two social services that i require uh
come with an email so it should be good to just state that that is actually there
so let's back out try that again see if that was indeed the issue uh no not quite role id what what is it now
returning inserter update on user table violates foreign cake straight user role id foreign
so i'm providing a role id is oh i didn't
seed nothing
there we go now we should be good cedars are so easy to forget about
especially since it's been you know whenever it's been a little bit so there we go all right we were able to
log in i need to make myself an administrator again um
let's jump in here and do that okay
what was that roll two i think
and voila there's all that stuff okay
so now just the the fun portion where and how do we want to bind
collection and taxonomy creation management
so first the verbage here on the pages should probably be updated
from post to series topics to post collections and taxonomies um
so why don't we go ahead and do that if i can remember where that is i think
oh yeah no i also kind of restructured the components and all that too um
so that's another thing that i did off screen so like if we come in here instead of referencing components um and then
components and then the actual path uh just using the shorthand of you know
form input alt to read from components form input
um so cut back on a little bit of the syntax there
uh so that's another thing that happened but what was i gonna go do the header for the studio
so this changes to collections and this changes to taxonomies
and then we'll need and we i need to update the permission check on
that as well but we'll circle around and do that later um
and then the drop down for the actual header needs that as well so uh post
uh collections and
taxonomies okay so now that should be updated here as well and it is
okay so now we need to create the we'll start with collections so we'll create the collections page
um i think uh
yeah we'll go ahead and create so let's do node ace make
controller studio
collection it should work oh i forgot to make it as a resource
let's see if we can override it maybe
skip okay well let me delete it and we'll recreate it
there we go okay so we'll need an index page this for
right now we will just return back the view so we'll extract view return views dot
render studio uh
collections index and that should just be view
we'll go ahead and create that page so we'll go down to studio
collapse some of this up here and cut back on the noise all right so studio new file
collections index.edge i'm just going to copy and paste the post index uh it's definitely
going to be different but for the most part it's probably still going to be a table at the end of the day um so it'd just be a matter of changing
table columns and all that stuff so create new collection and then we're gonna get
an error here but we'll go ahead and type in what the so this would be
collection with an s
and that would be collections and then
trying to think of whether or not this is going to throw an error probably i'm just going to provide an empty array for right now and then we'll
need to go through and update all the columns and all that stuff okay so
we need to go create the create page as well so that that does not throw an error so
let's see right here
so this will be view return view dot render
studio collections are we going to need a separate create
an update page i want to say no we can always split it
apart if we end up needing that so let's do create or edit for this as well
yeah we need to go create that
so down here do a new file create or edit
and i don't think it would hurt to just copy
and paste it from the posts i mean it's going to need a decent amount of changes
but it should be okay right so let's see if we have a collection id
then this would be update collection otherwise it's create new collection
um um i think these actually i think this
also needs a state doesn't it because then you should be able to put a collection as public private or um
yeah yeah so it needs a state as well so let's go back into migrations
collections and where is status let's do state as well
so table integer state id unsigned
not nullable and default it to
public ship that's private public should be good okay there we go
and then let's go add it into the model and then rerun our migration and then we should be good to proceed
so there's status we'll do it right underneath there column public
state id state cool cool
all right so what was i doing down here yeah so
for the most part we should be okay to keep some of that right here um
the draft doesn't make sense but save as unlisted save as private
and then just i don't know save i'll workshop that
later on um let's see and then i'm going to just
comment this double okay we'll just do everything here one one go so let's do
collections collections
hey mike thanks for stopping by
collections there oh thank you for the complaint i appreciate that
um and then let's see so
we will stick with the state id but we will get rid of defaulting to draft
instead we'll default to public and then instead of post that needs to be collection
and instead of post form this will be collection form um
this does not need time zone and then we'll need to alter a lot of
these fields form fields um the
the uh see we don't need publish at at all so we get rid of that
we have slug we have description uh instead of nate at title its name
of title would make more sense but we'll change this to name
um and then this also needs um go ahead and just do a quick find and replace on this so post
changes to collection there there there there
there there oh skip over that one actually we can get rid of canonical
altogether won't need that okay
let's replace that one won't need this at all either
actually this whole right side we're good to get rid of but we want to maintain it because at a
later point in time we'll add in like the post and the taxonomy management over there
so we'll leave that there uh we don't need the editor
so that doesn't need to be there and that leaves us with what is this oh description yeah i
think i think that's all the right fields okay um and then we can get rid of this
script i think uh i miss name so i named this studio
post editor but it does a little bit more than just the editor
but i i need to split this up so i was going to do it as this just the
editor and then import it in to another file specifically for the editor page
but no this does not have anything in it that the collection page would need so we're good
to get rid of that and then i don't know why that console log was there
i think this is it so i think that's pretty pretty spot on what we'll need
um and that just takes us back to defining the routes
so there's our posts so the route that group
wow
all right there we go we got our spelt right this time route.get
um um shoot collections yes
and i believe i said this last time but i'll say it again so you can definitely use a resource here um i have this thing
where i just really like having all of my routes manually labeled out it's i don't know how to describe it it's just
personal preference but definitely if it's your cup of tea use a
resource instead of doing what i'm doing and manually defining everything
i'm going to say hey just copy and paste the posts i think that's what i usually do anyways just copy and paste from one another
whenever i have a new resourceful style rail
and then just change all of these from posts to
collections all right and then on here we'll prefix it
with collections
as collections and this will require the middleware role with a role of admin
and then that leaves us with the finishing up this controller for the
most part but before we do that
no i didn't actually add in the url to go to the page let's do that i guess first
so down to our header and studio header did i close it i did
oh it's partials so header studio
wanna do route studio collections index and i will copy this
and then in the main header we will paste that in
okay so we should be good to go to collections
and this button is updated yeah it's updated but it
cannot read so we need to provide that data the same way that we are to um the
posts so if we go into the post controller here and we go into
the create page we have these states so we also need to provide that the same
way with our collections controller so for the show create sorry
do state and states
okay so now if we try it there it is so we have name slug description
and the seo stuff
okay so then let's
[Music] go ahead and
get that store written then so we'll want
the request and response for that no yeah yeah yeah response
um and we'll want to validate it and i think i'm going to use
a separate validator so we'll do node ace make validator
collection i don't remember yeah just collection validator
yeah that works all right um so name which is the schema dot string
um trim it to true
rules dot oh i need to import rules oop
there we go rules dot
um max length of i believe i set it to 100 you can always double check that
sl uh well what did i do for the post does that need a slug i think slug.optional
right
yeah that should be good okay
and then we need to copy over that slug unique constraint as well
i'm doing get rid of that massive comment okay here we go
um uh what else do you have
i'll copy that over onto the side so i can actually see it uh owner will get off of the
authenticated user uh whenever it's created um parents would be another one that we need so
uh would that be yes that would
would it be yeah i guess
we'll bypass that for right now we can always add it in later on so we'll just do a single layer first and then we'll come back and add on that
second layer with the parent id on it uh collection [Music]
type id which is a schema and
job enum
what is it object.values collection type
am i remembering that right all right it reads quickly so i guess
all right and then we have status id
would be very similar so oh
wait what options allow oh yeah okay
so that would be object values and that would be status
and then you have asset id schema.number and then that we need to
do rules.exists table
assets column id
and then we already have the name in the slug
description schema.string
uh we'll go ahead and say sure trim that as why do i keep trying to type trim prime
so we'll do trim there too and then we'll have meta description
and then we'll tack on the max lengths to those i believe both are 255.
okay and a page title skipped every page title so we'll put that above
the descriptions
i don't remember what i said as a max length for that max length for that sorry i can't speak
um
okay
cool
slug is 150 here so instead of 255 we'll do 150 there we go all right so that should be it i think
for the collection
so then we'll head back into the collections controller and we'll do const data equals
await request.validate
collection validator
await collection dot create
data return response dot
redirect dot to
route studio
collections index
we haven't set anything up with the session um alerts yet but we'll do session.flash
success your collection
has been created
and we have a red squiggly on our data what is it
oh yeah i do need to provide some more stuff into there don't i
let's see so what are we missing here we're missing the owner id so we need off
okay what else are we missing
um
paranoid is nullable so that's not going to be needed
status id should be in data i think right
um we need to do the slug but that would be we'd do the same thing there as we're
doing for the post so we need to add that onto the model actually
collection type id no i'm pretty sure that's in the data
yep it's in both
oh types of prop oh right right right right
so let's change these back to number
that should fix that right because what what does this say the collection type id
type is for the validator straight all right string um
ran into that with the post as well didn't we that's why we didn't end up using the enum type because we needed numbers
so what did we do for the post i think we just changed it to numbers
yeah so number.optional okay i'm sure you do some type of
check on that as well but uh all right so
well those these ones are required well no we do have the database well yeah we'll leave them as required that would
make more sense okay
so did that get rid of this quickly it did okay so give that a save
and we'll go ahead and try this out let's see if it works so we'll do
uh test collection believe that oh that reminds me slug so we need to go do
what we did on the post for the collection and then while we're
while we have this copy and pasted um we'll do the same thing for the taxonomy because we'll have the exact
same thing so there's slug all the way down there
now we need to import sluggify this one
all right and then instead of title that reads off of name okay and
the same thing there for taxonomy so where is slug on this one
there we go okay now we should be good test so we'll leave the slug empty
this is the description is it save
nothing all right so it didn't even seem like it refreshed
at all so i'm guessing it didn't fire out at all which means we probably have something going wrong here so
yeah can't access priority state id document forms post form oh okay
so on the uh creator update page for the collections all the way down here if we scroll all the way down
to the bottom change this to collection form
okay let's try this again
empty that and scale it down all right so
test collection this is a test
save all right that time it refreshed it brought us back to here i have to assume that we got some sort
of validation error um
so let's dig into what that might be
so i will do a pre-tag well let's actually just do
inspect um
let's just inspect all the flash messages and we'll tr yeah refreshed all right so
test collection this is test
send it off so
collection type id status id asset id
page title i really messed up on the validation evidently
so let's go take a look at that so yeah well these are sending up to my all
right so my thinking was these were sending up empty strings but obviously that's not happening the save is empty strings
if they're not provided so we need to definitely provide optional here
as for the asset id that should be optional and status id should not be
so i'm not i said i said he should be sitting up with him so i'm digging why that's not
and then the collection type id we'll need to add a selector for
but why would these status um status id not be simple
well no so this is state not status so you do need a state a status id selector
as well so okay
underneath here let's do um what do i have going on for this look
but i believe that's in the normal input component yeah
yeah select right there okay so copy
copy this
okay type is select
oops
and then we'll want to do the options here so we'll do at well we do optional manually to find
them that's fine value equals
and then we need to provide these into the page so let's do const statuses
status there we go and what was the other one um uh collection type so const
collection types equals collection type
okay so then this would be
this would be first status
status id it will have a default selection so we
don't need to worry about that collection dot status id otherwise flash message
for the status id otherwise it should be
statuses dot what is in my statuses
[Music] in progress if you're just creating it
in progress all right now that does not need rows at
all so statuses dot
in progress
and then we'll have another one
for completed and another one for archived
and another one for outdated actually so yeah
so completed archived
outdated oh i never put the ending
there we go okay so that should be good for that one and then we need one more for the
collection type which should probably not be the last field in the form but we'll put it here for right now
so this will be type
collection type id
collection type id and then this would be collection types dot
sirius i think is the default that i put on the database so we'll default it here as well and then collection type
and then i think this just has three and the first one
is series course
playlist
all right
so the select style could use some work that's not the best but we'll fix that up later on um let's go ahead and do our
test collection here this is test
then we have our default of in progress and series save
okay cool we went back to the home page so all should be good there it should have created we can verify that with the
database to refresh and go to collections
and there it is so then we'll go ahead and get that querying down
probably do the same thing as we're doing here um
yeah copy most of what we're doing for the posts
directly into the series and just import our stuff so state descriptions
uh we already got states we need to import the route module and it doesn't want to it's too many
competing stuff so we'll import route from at ifc
adonis core route and then we need our off and request so
request auth and that should now do it and then instead of the base url blank
studio post that should be studio collections and we need to return back
states let's uh shoot
state descriptions and instead of querying the related
posts this should now instead be collections
which does not have authors but i'll comment that out for right now
good enough all right so let's see if we can get that at least plopping the name out in the table
so we'll come in here name
name will not have an author column
it will have a status that will have a type it will eventually probably have a view account
won't have publish app and it will have actions and we'll publish that at all so we get rid of that um
and then we need to provide did i change the name of that or am i still writing i just post yeah
collections uh
collections and collections
so provide that into the table as collections uh we can get rid of
that bit right there change this one to name
and instead of doing
say name there everything else should be okay we're gonna need to update the routing though so instead of that it
should be collections uh
yeah and then i have this one hardcoded because it doesn't exist yet but it definitely won't be collections but we'll
hold it there for right now um okay i think that's it so we can go
ahead save oh this needs to change the collections as well edit and destroy
okay now we should be okay to refresh or at
least try nope missing model attribute user dot
collections expects user id to exist on collection model but it is missing so
that is a model based issue with how we are defining the user is and
collections so we are querying from the user
did i never i might have never defined the inverse so i know that we put the user on the
collection as owner
did we not put collections on the user nope it's right here
all right i must have something inversed here let's see
oh it's okay yeah so what what what is that form
foreign key i think that's what they use for that and then that needs to be owner id since this doesn't know what the heck
i'm referencing it as on the collection table i need to tell hey check out the owner id for what collection this user
belongs to so that should nope
okay now user.collections expects owner id to exist on collection model
there we go unexpected okay yeah now it's the commented out issue so we got past that
and it does not like this style of comment well we can get rid of that this definitely doesn't have
authors in it all right another error oh yeah there is no post type
description but this does have a type
so let's just replace this for right now with scope row
type id is it type id it's collection type id isn't it
okay there we go so we get we at least have the name down
so that's a start uh the status is undefined i'm not entirely sure why
and then our uh type is one so our post type there's collection type is one
um so let's see why why why why is the status undefined here so we have state descriptions which i
believe i'm sending down with it and then we have the state id
is that all saving is that let's see where state id
oh there's no state id oh i never refreshed the migration now did i i added it i'm pretty sure i added it i
added it right
yep and double check i wasn't just messing up my eyes here
no there is no state okay so we need to note ace migrate
roll back everything should already be on badge zero so let me just do that and then
notice migration run
let's go log out let's go sign up
and
another issue with this i just fixed it insert into users avatar url created at
email yada yada
user's role id form is that the same issue i ran into last time that i had just fixed
or did i not fix it evidently i didn't what was the issue
oh i didn't see
i need to i need to group those um freaking commands into just a node ace
um migration reset or something like that so that automatically tries to run the seeds for
me and then now somehow we got to the page login
so i'm not i don't know how we got to there
prop oh prob probably the middleware i haven't updated that quite yet
all right let's make ourselves an admin
really okay there we go
definitely logged in should have a user okay
verify that that worked there we go all right so if we go into collections
and we create a new one we should be good to get rid of that now um that little inspect
so if we go down to collections creator edit it's up here at the top right here
all right
this is a test we have these types there go ahead and save
all right now it's coming through as public there we go
test private collection
sure that's fine though um save us private ooh
that didn't work
so what's going on there um click save as private
that worked for the post if i had to guess well no i wouldn't
need it for the validator wouldn't it
and those buttons don't submit the form
hmm
so it would have had to have sent up with something is it still is it looking for state id or did it
change that state all right is it collection form
it is collection form
all right let's try to oh i didn't make the edit page yet so we can't edit it all right
and i don't have delete yet either
so let's see if unlisted might work
nope all right what did i do to you
so let's put actually let's pass in
man i can no longer type i'm sorry event
event and event there we go
let's pass in the event let's prevent default and verify that it's actually sending up
altering then sending up
okay well what am i doing let's get rid of the submit it is just in that click
all right there we go let me get rid of the event there we go okey dokey
so really i shouldn't need to test or type anything but we will go ahead and affirm
document collection form dot what was it state id status id get those
two confused too much state id dot value
actually is it looking for state id or
did i do state id or do it did i just do state
well okay there's a part of the issue there is no state okay
state id schema.number
so there's half of the battle
i wasn't passing it up into the data
so let's see if that was the whole issue testing
unlisted two yep sure enough
well that i mean it would be hard to save it as a specific state if you're not actually saying that it should be a
specific state not wouldn't it there we go all right
there should be different colors but that's a whole different issue hey roman um let's see he said you
should create a mf s that migrates back
runs and seeds alias mfs star yeah
i i don't know why i have such a hard time remembering to run seeds
um but it is an ever long issue for me all right um
let's see let me go ahead rig up the edit page and the delete because this should already
exist since we just need to query it provide the same stuff that we have here in the store and then delete would just
be deleting it and then we'll need to slowly add in the ability to manage the posts
and then we'll see whether or not we want to do taxonomy so i'm still undecided about that
um so we would want view we
did params and [Music]
that probably probably it um so we'll want to do const
collection equals await collection dot find
or fail programs dot id
shouldn't need to preload anything at this point in time um
yeah so and then we will do return
view dot render studio
collections create or edit and pass it in
the collection and we're also going to need to pass it the same stuff that we're passing to the create so states
statuses and collection types so we'll go up to here and just copy
these okay here oh
that's supposed to be statuses there we go
so that might actually just be it for edit and then we would need to go through and do update so we'll see if we can yep
um the slug auto populated nothing else did did i have maybe i i knew i put a
description on this one yeah so this is probably still just referencing title probably forgot to update that
let's go see sure enough there it is
okay there we go and then while we're here let's go ahead and do the update as well
so this one will take request response params
session and i don't think we'll need off because the owner's
already set so use the same validator as the create so
wait request dot validate collection valid theater
um scroll to the top on accent
all right and then let's actually do well yeah validate the data before you actually
query and then we'll do collection equals awaits
collection finder fail params.id
and then collection dot merge
data dot save wait
return view oh i grabbed a response i want view
there we go dot render studio
i had such a hard time remembering collections collections index
no create no uh sorry no what am i doing here you do you're not
referencing the edit this is update so you do want response
and you want to redirect to that route
okay and then we can go ahead and while we're here let's do destroy
no we won't need requests at all we just need response and params
so const collection equals weight
collection.find or fail params.id
and then we will do awaits collection dot delete
return response dot redirect to route
studio collections oop doing dots
collections index there we go okie doke
so i think everything on the front end should already be set up to accommodate
for that so we have the name in here we have the
slug description and the statuses so let's change this to a course type
let's change the description to have edit on it let's change the title or the name
to have edit on it as well and this one was public so let's try to
change it to unlisted did i have two of these
i must have so this changed to unless it created
it might have created let's try that again
edit two sure enough yeah that created because
now we have seven we had six so
i bet you that still checking if post which would definitely be
false yep right there so if post so if
collection all right there we go
well that gives us the uh plenty of records to test start to lead out with anyway so we'll delete
can i find route studio collections index oh collection needs ass
well why am i hard coding that to route studio dot
collections dot index there you go see so i was right with dots i was just second guessing myself
because that's a redirect not a not a render path okay
man i need to go to bed it's only going on six but i am
evidently really ready for bed all right so let's try delete row not found
we're not found studio collection seven
taxonomy tech nope collections so we only have six
and it looks like this one may have already deleted so yeah okay that makes sense then
all right and then we'll try it again this one make sure it goes okay yeah all right there we go
all right so now let's try this again let's see if so let's do edit three we haven't named anything three yet
give that a save okay still with this can i find route studio
collections index on the redirect
to the route oh i fixed that on the delete but not
the yeah right here
all right there we go i thought i looked at them
all but evidently not all right so let's try you again so let's let's go back into collections
and we have this three now so let's try four
and we no longer have a three but we do have a four so that seems to be working let's try changing it from public to private
that's working private to unlisted that's working
in progress to archived and from series to course
oh i don't have the in progress state on here but the series the course did work
and then we can try course to playlist which should be three now and there we go okay so that's working
and then
we're going to do
add the status onto there go ahead and do that real quick
so no that is status archived
in progress complete archived outdated but no so i have that mislabeled that's not
status it's state yeah
yeah got that mislead so state
state id uh really that
could probably just put that on the same line
that way it's not taking up a whole other column
so we have state descriptions do we have a status description
state status we do status description so we will go to
here and on the index page in addition to states and state descriptions we'll do const
i don't know if i need status provide it and see
okay
and then we'll just need to do the same thing here so status descriptions
scope row status id
we'll see how that looks it might not look what that why did it what did i do
why did that just turn into a number
oh yeah i need to update this as well
there we go all right sitting here going what did i do wrong
all right let's try this now status descriptions scope row
status id and it's not the best
i'll leave it as is though it wouldn't be too bad to do like a little slash have this be darker and bolded and that
light and not folded
um yeah i don't really know how i like in the previous project i didn't use them a
whole lot it was mostly just on this page and then on the create network page [Music]
but i'll play that by ear i definitely could make those globals
um
well i can see
yeah that's a be on the post page series page
comments page so it's mostly all on the back end side but
i'll play that by ear
okay
let's see um
so we need to bind our posts to our well we
don't have any post anymore but we need to bind our posts to our controllers as well our
collections as well i might save that for tomorrow um
kind of out of it tonight but we did manage to get our collection
set up we managed to get our migration set up for the future and
some other stuff i can't quite remember but yeah um so
cool good times ahead we'll hopefully be getting this homepage rigged up to live
data here soonish once we get the posts and the collections set up which should
be good taxonomies can come in later um but yeah so thanks everybody for
stopping by i'm gonna go take a nap or something but i appreciate you guys appreciate you
guys stopping by and i will see you guys tomorrow i'm not quite sure what time but
um probably morning or afternoonish
Join The Discussion! (0 Comments)
Please sign in or sign up for free to join in on the dicussion.
Be the first to Comment!