Build and Deploy Laravel 11 + React Full Stack App - TypeScript, Inertia v2, SSR, Permissions — Transcript
Full transcript
- 0:00in this video you're going to see how to
- 0:02create fullstack application with Lal 11
- 0:05inera version 2.0 with react typescript
- 0:08and server side rendering how to use
- 0:11spot's roles and permissions package to
- 0:14implement three different roles and
- 0:16finally how to deploy the project on VPS
- 0:19server on custom domain and set up
- 0:22GitHub actions as well whenever we push
- 0:25something on the main branch it is going
- 0:26to be deployed automatically on the VPS
- 0:29server and we also have up and running
- 0:31SSR on VPS server so the entire react
- 0:34application is serers side rendering
- 0:37which gives you great SEO capabilities
- 0:40now let's have a look at the demo of the
- 0:42project the idea of the entire
- 0:44application is to create new features
- 0:47and then the other users will have
- 0:49ability to upload or download the
- 0:51feature or leave comments on the
- 0:54specific feature what they like about
- 0:56the feature whether they want to
- 0:57implement for the project or not we have
- 1:00three roles inside the application admin
- 1:03role commenter role and the user role
- 1:07admin users are able to create new
- 1:10features and to also assign roles change
- 1:13roles for the users commentary users are
- 1:17able to leave comments on the features
- 1:20and regular users are only able to
- 1:23upvote or downvote the feature and of
- 1:26course admin user role covers the
- 1:28commenter role in the regular user role
- 1:31and also commenter role covers regular
- 1:34user role meaning that commenter users
- 1:36can also upvote and downvote to be able
- 1:40to authenticate on the website and to up
- 1:43Vote or downvote or do anything you need
- 1:46to First
- 1:48register we're going to go into register
- 1:50page the registration requires the email
- 1:54verification as well and right now I'm
- 1:56using local mail pit server which we're
- 1:59going to also learn how to set up
- 2:00locally on the following Port without
- 2:02Docker so we don't uh do this with a
- 2:05Docker so here I'm going to provide some
- 2:08name John John example.com we hit the
- 2:12enter now we have to verify our email
- 2:15let's open mail pit we received an email
- 2:17click on this email verification has
- 2:20been completed now let's reload the page
- 2:23and after the email verification we say
- 2:26the dashboard the dashboard is basically
- 2:27a dumy page it doesn't display anything
- 2:30this is just default Lal pre dashboard
- 2:32we are we are interested in features but
- 2:35pay attention to one thing this is a
- 2:38regular user and because it is a regular
- 2:40user it doesn't see users menu item so
- 2:43that happens through roles and
- 2:45permissions if we click on features we
- 2:48also don't see right here create new
- 2:51feature and if we click on comments this
- 2:54user is not also able to leave a comment
- 2:57the user can read the comment can can
- 3:00browse these features and can check
- 3:02every other feature and can do up vot on
- 3:05the specific feature but they cannot do
- 3:09anything else rather than up Vote or
- 3:11downvote that specific feature that is
- 3:15um to just make that working we have to
- 3:20authenticate as admin user then admin
- 3:23user can go into users and find John
- 3:27here edit John Give It Up admin
- 3:30permission click on Save and then when
- 3:34join will authenticate on the
- 3:37server JN will see users right here
- 3:40features JN can also create new feature
- 3:43provide the name and description of the
- 3:44feature and just like this um John can
- 3:48also edit the feature or delete the
- 3:50feature which is the Privileges only for
- 3:52the admin users and John right now is
- 3:55the admin user for the entire
- 3:57application we're going to use laravel
- 3:59and react with typescript we're going to
- 4:01learn how to define types and how to use
- 4:03the inertia version 2.0 several great
- 4:06features such as for example deferred
- 4:08props when we open the page first the
- 4:10content of the feature is loaded and
- 4:12then the comments are loaded it we also
- 4:15have the prefetching when we click on
- 4:17this it's going to the content is
- 4:19actually already prefetched and loaded
- 4:21for the users as well so the navigation
- 4:24between these pages is super smooth
- 4:26there are several other great features
- 4:28of iner 2.0 and we're going to see all
- 4:30of them how we can use and the main
- 4:34thing is that the application also uses
- 4:37serers side rendering if we click on a
- 4:39specific item specific feature so this
- 4:43is rendered with react but with the help
- 4:46of service side rendering we this is
- 4:50actually fully SEO friendly let me show
- 4:53you what I mean we have the application
- 4:55started with PHP Artisan serve and we
- 4:58also have mpm run Dev up and running for
- 5:01the react and asset building and right
- 5:04now serice side rendering is not active
- 5:06so if I copy the following title right
- 5:09click on this and search for uh view
- 5:12page Source The View page Source will
- 5:15display the content like search engines
- 5:17will see the content and if we search
- 5:20for the following text we see that this
- 5:22is used only one place and that place
- 5:25actually is the only place uh where the
- 5:30inertia pushes puts that data for the
- 5:33react okay however we have that content
- 5:37used in uh several places like one's
- 5:40here second here but we don't see this
- 5:44right here on two places because all
- 5:46that content here and here is generated
- 5:49on the client side and we don't see this
- 5:52in the page source to fix that we're
- 5:56going to see everything every single
- 5:57detail of that but we're going to
- 5:59execute mpm run build for this and then
- 6:03we're going to start inertia server by
- 6:05executing PHP Artisan inertia start SSR
- 6:08just make sure that mpm run build is
- 6:11fully completed when we execute inera
- 6:13start SSR now once the inera SSR server
- 6:17is started we're going to refresh the
- 6:20page now this is fully serers side
- 6:22rendered content and if we open that
- 6:25page we can copy the title again view
- 6:29page
- 6:31Source search for that and now we see
- 6:33this in four places one is inside the
- 6:36browser's head tag inside title second
- 6:40is inside this content we provided
- 6:42through inertia and we also have this
- 6:44inside h2 tag which is the following
- 6:48area and we also have this in another h2
- 6:51tag which is the following area and just
- 6:54like this now every page on the
- 6:56following website is fully server side
- 6:59rendered and finally we're going to
- 7:02learn how to set up the project on a
- 7:04custom domain L
- 7:07react. hit the enter and this is where
- 7:09we have our application deployed we can
- 7:12authenticate with the same
- 7:14user and we're going to see all the
- 7:16features users we can edit the users and
- 7:20do pretty much everything so I'm not
- 7:21going to bother you just explaining the
- 7:24same things building such types of
- 7:26projects require a lot of time and
- 7:28energy I have to plan the project then
- 7:31create it once and then I have to create
- 7:33it second time for recording then
- 7:35editing and so on if the project excites
- 7:38you single best thing what you can do
- 7:40right now is to hit the like And
- 7:42subscribe
- 7:43button okay there are two things you
- 7:46need to do the project covers how to
- 7:48create fullstack application with LL and
- 7:50react but the project doesn't cover very
- 7:53basics of LEL if you don't know what is
- 7:57LEL or how to create very simple applic
- 7:59with LL on its own then I recommend to
- 8:02check my course LL for beginners which
- 8:05is for absolute beginners as well as for
- 8:08kind of the people who is already
- 8:10familiar with Lal and want to just
- 8:12remember a few things and refresh their
- 8:15Lal skills that is a course complete
- 8:17course which covers which has 300 videos
- 8:2024 hours of content it has a quizzes
- 8:23challenges it has certificate of
- 8:25completion and it gives you basically
- 8:27the whole knowledge you need to create
- 8:29the project from start to finish and
- 8:31during the course we're going to also
- 8:32deploy the project on VPS server if
- 8:35you're interested check the website the
- 8:37cod.com you will find my course right
- 8:39there the course also includes written
- 8:41notes for every lesson and you can also
- 8:43get the PDF which is kind of 400 page
- 8:46PDF for the entire course that's almost
- 8:50like a written version of the entire
- 8:52course from time to time I get emails
- 8:55from my subscribers that they want to
- 8:57enroll on this course but they cannot
- 8:59for this and asking me to give them
- 9:02access to the course for free um I want
- 9:04to help to as many people as possible
- 9:07but obviously I cannot give this course
- 9:09for free for everyone uh but because I
- 9:12want to do something for such type of
- 9:15students who cannot really afford this
- 9:17but genuinely want to enroll in this
- 9:19course and start learning LEL so this is
- 9:22what I decided in every video I'm going
- 9:24to generate one or two 100% coupon codes
- 9:27for my Lal 4 beginers course and it's
- 9:31addon which is a PDF file as well and
- 9:33I'm going to put those coupon codes in
- 9:36my YouTube videos you can get this and
- 9:39you can access the course for free in
- 9:41this specific video there are two such
- 9:43type of coupon codes 100% coupon codes
- 9:45for Lal 4 beginners course and for the
- 9:48PDF as well not for the other course
- 9:50which is for Lal e-commerce website
- 9:52course not for the other one but for
- 9:54beginners and for the PDF uh and the
- 9:57coupon code actually has the following
- 9:59format so it's a 16 character coupon
- 10:02code and it is one coupon code it is
- 10:06splitted into two parts the first eight
- 10:08characters and the second eight
- 10:10characters so totally during this video
- 10:14there are four places uh where you will
- 10:17find the parts for those coupon codes so
- 10:21one place contains the first part of the
- 10:23C coupon code second place contains the
- 10:25um second part of the first coupon code
- 10:27and so when you get the idea you you're
- 10:29going to also see on the screen the
- 10:31format how you're going to find that
- 10:33small note on screen that basically is a
- 10:37indicator that's a part of the coupon
- 10:39code so and just like this if you really
- 10:42want that course you're going to go
- 10:44through the video find those parts of
- 10:46the coupon code and you can get this
- 10:48coupon code for free but I also
- 10:50encourage you to if you don't need if
- 10:52you can afford this course don't take
- 10:54this opportunity from others who cannot
- 10:57really afford such types of courses and
- 11:01uh genuinely want to learn it that's all
- 11:03what I want to say so good luck whoever
- 11:05is going to take that coupon codes and I
- 11:07will be genuinely happy and yes one more
- 11:09thing whenever you find the coupon code
- 11:11please send me a DM on Twitter on EX
- 11:14because I want to announce whoever is
- 11:16going to win this I want to announce
- 11:18this on Twitter so that others know that
- 11:21all coupon codes are already revealed
- 11:23and used okay please let me know in the
- 11:27comment section or on Twitter send me a
- 11:29DM that you found the coupon code at the
- 11:32end of this project as I mentioned we're
- 11:34going to deploy the project on VPS
- 11:35server with custom domain as a choice of
- 11:38the hosting provider we're going to use
- 11:40hostinger which is very kindly
- 11:42sponsoring this video hostinger is one
- 11:45of the best hosting providers out there
- 11:48offering you a lot of different kinds of
- 11:50Hosting services such as shared hosting
- 11:53VPS hosting email hosting Cloud hosting
- 11:56and so on I personally have been using
- 11:58hostinger for p three years and I'm
- 12:01extremely happy with your services and
- 12:03and I actually moved all my websites
- 12:05from different other hosting provider
- 12:08into the hostinger sometimes I use
- 12:10shared hosting sometimes I use VPS
- 12:12hosting depending on the use cases if
- 12:14you're application is very simple I
- 12:16recommend sheared hosting if you don't
- 12:18want some background jobs running as
- 12:20well I recommend sheared hosting in this
- 12:22specific case we want inertia server up
- 12:25and running so we're going to choose VPS
- 12:27hosting just go to the website hosting
- 12:29er.com theod holic and right now they
- 12:32have amazing Black Friday sales so just
- 12:35go to the hosting section and click on
- 12:37VPS hosting the hosting actually starts
- 12:39with $6 per month uh you can find all
- 12:42the available options what is right
- 12:44there so this $5 it starts with a $5 per
- 12:47month but that is the price actually is
- 12:50only for if you grab it for 24 months
- 12:53plan you can choose whichever version
- 12:56you want here you have the resources of
- 12:58the VPS server let's click on the most
- 13:01popular one right here you can choose
- 13:03this period 12 months or 24 months as I
- 13:06mention the best deal you're going to
- 13:08get if you choose this for uh 24 months
- 13:11and uh just make sure if you decide to
- 13:14grab the hosting use a coupon code the
- 13:15code holic which will give you extra 10%
- 13:19off on already quite great price if you
- 13:23decide to grab the hosting just click on
- 13:25continue then you have to fill up your
- 13:27cred card details and at the end of this
- 13:29tutorial when we see how we can deploy
- 13:32the project you can use the following
- 13:34VPS server um for the tutorial
- 13:38$129 for 24 months for the server which
- 13:42has eight gigs of RAM two CPUs 8 uh
- 13:46terabyte bandwidth and 100 of gigabyte
- 13:48of NVM dis space I think it's pretty
- 13:51good deal and the deal doesn't last uh
- 13:54so long because it's right now it's a
- 13:56for Black Friday so I recommend just get
- 13:58it right now if you plan to deploy
- 14:00something on the VPS server go to the
- 14:02website hostinger.com theod holic or
- 14:04click on the very first link in the
- 14:06video description and thank you
- 14:08hostinger for sponsoring this video and
- 14:10supporting my channel for quite some
- 14:11time already now we can start building
- 14:14this project all right my friends now we
- 14:16can start working on the project and
- 14:18first let's just make sure we have
- 14:20correct Lal development environment
- 14:23setup locally so if you don't have any
- 14:26environment setup locally I generally
- 14:28prefer lot heard and this is what I
- 14:30recommend it is available on Windows and
- 14:33on Mac OS if you have your preferred
- 14:36development environment for LL you can
- 14:39stick with that whether this is zamp or
- 14:41this is Docker Just go with it if you
- 14:43feel comfortable in it okay in case of
- 14:46Lal her if you don't know so this is
- 14:49actually one program which provides PHP
- 14:52engine server nodejs and pretty much
- 14:54everything what you need to get started
- 14:56creating your Lal projects so from this
- 14:58interface you can actually install PHP
- 15:00versions from the dashboard you can
- 15:02switch between between different PHP
- 15:04versions you can install nodejs and so
- 15:07on and by default this is free but there
- 15:10are a couple of pro features available
- 15:12which we are not going to actually use
- 15:14okay we're going to go with SQ light
- 15:17which is actually uh available with Lal
- 15:19herd but in the Pro features you also
- 15:21have MySQL if you want so and if we go
- 15:23in the dashboard and click this open
- 15:25sides this going to open second window
- 15:27and right here we have all the pro
- 15:29projects and what I'm going to do
- 15:30actually is to create new project but
- 15:34not from the interface however you can
- 15:36do this from the interface as well just
- 15:38if you click this added button and
- 15:40choose the new larel project click on
- 15:42next choose the uh starter key and just
- 15:45follow this wizard you can actually do
- 15:47this but I'm going to do this through
- 15:49terminal actually this is the same
- 15:53folder I want to name to my project so
- 15:55I'm going to actually delete this site
- 15:57just created this uh when I was actually
- 16:00testing okay that was deleted let's
- 16:02close Lal her this one as well and let's
- 16:05now open Terminal here it goes and let's
- 16:09go inside Lal her folder and right here
- 16:13we have those projects and let's create
- 16:15new Lal project for this I'm going to
- 16:18use Lal command Global command available
- 16:22and if you don't have a lot of global
- 16:24command available you need to execute
- 16:26composer Global required
- 16:29oops require leral slash
- 16:35installer okay this is going to just
- 16:37require Lal installer and make the Lal
- 16:40comment globally available and once you
- 16:42do this we can execute LEL new and then
- 16:45we have to provide the local folder name
- 16:47inside which we need to create the
- 16:49project I'm going to call this Lal D
- 16:53react full st- SSR let's see the enter
- 16:57now we have to choose the starter kit
- 16:59I'm going to choose Breeze we have to
- 17:01choose the Breeze St I'm going to choose
- 17:03react then we have to choose additional
- 17:06features I'm going to choose dark mode
- 17:08comma then I'm going to choose serde
- 17:10rendering and typescript so we need all
- 17:14these three features I'm going to hit
- 17:16the enter and I'm going to choose the
- 17:17testing framework to be passed now this
- 17:20is going to take few seconds to scaffold
- 17:22the project and install that now it asks
- 17:25us which database we want to use the
- 17:27default one is SQL so we're going to
- 17:29stick with that hit the enter and
- 17:31whether we want to run the default
- 17:33database migrations the default one is
- 17:35yes I'm going to hit the enter now it it
- 17:38executed all the
- 17:39migrations and then it is going to
- 17:42require Lal breeze so so far that
- 17:45actually created the Lal projects with a
- 17:49default uh with a default um like the
- 17:54default project template excuse me so
- 17:57but then it takes executed to require
- 18:00Lal Bree and then it's going to also go
- 18:04with and install inertia with inera LEL
- 18:07and right now it is installing inera 1.3
- 18:12but we're going to update this into the
- 18:13latest version which is 2 point
- 18:15something which is still in beta at the
- 18:18moment okay so then it is removing PHP
- 18:21unit and installing pest
- 18:25framework let's scroll down below I
- 18:27think this actually actually finished
- 18:31everything or it is finishing now right
- 18:35here it
- 18:36actually uh right here it is building
- 18:39the project it installed everything and
- 18:41it is building the project executing mpm
- 18:43run build with a typescript command and
- 18:45everything and right here we have the
- 18:47following error so that error actually
- 18:50right now at the moment exists inside
- 18:52the SSR do TSX file which we're going to
- 18:56fix but in the future probably that
- 18:59error will not exist so we you probably
- 19:01don't need to do anything now let's
- 19:03scroll down below okay the project was
- 19:06finished we need to navigate into the
- 19:07following folder let's execute CD
- 19:12LEL uh LEL react full stack okay and let
- 19:17me actually open this folder using PHP
- 19:19store and then I'm going to use the PHP
- 19:22storms integrated terminal to execute
- 19:25every other
- 19:27comment all right so let's use explorer.
- 19:32XM okay that was opened here we go LEL
- 19:37react full stake
- 19:39SSR and let's open this folder as PHP
- 19:43showroom project we have to trust this
- 19:45project and I'm going to trust projects
- 19:47inside the her folder okay so it's going
- 19:50to take a few seconds to index the
- 19:52project now it asks me to ELO this uh
- 19:56folder inside the defender and and
- 19:58actually I'm going to do this this will
- 20:00speed up the performance of the project
- 20:03okay now we can open the terminal uh
- 20:05when we allo this we have to agree
- 20:10that okay that's that's good now let's
- 20:12open
- 20:14Terminal and we're going to do a few
- 20:16things first let me try to start the
- 20:18project so for this we need to execute
- 20:21composer run Dev this is relatively new
- 20:25comment available in the latest LEL
- 20:27version which will do a couple of things
- 20:30it is going to execute mpm run Dev um
- 20:33PHP Artisan serve as well and it's going
- 20:36to execute few other comms as well it is
- 20:38using um no JS concurrently package for
- 20:42this and it's going to also take few
- 20:44seconds to actually uh execute the
- 20:48comment and start with that so for pale
- 20:52actually now I get the following error
- 20:55that PC and TL extension is required to
- 20:58run pale uh which I don't have locally
- 21:00installed in it is not a problem
- 21:02actually so I don't want to just uh run
- 21:06the pale so that's totally fine the main
- 21:09thing is that the V server is running
- 21:11Artisan server is running so right now
- 21:13we can access the
- 21:15project in the browser so we can
- 21:18execute Local Host Port
- 21:228,000 or actually we should use 127 001
- 21:27we could use that as well but the main
- 21:29thing is that the project is up and
- 21:30running and this is our project and we
- 21:32have this login and register as well
- 21:35which is actually um single page
- 21:38application through um inertia and
- 21:41react now if you open Terminal again and
- 21:44stop this and try to execute mpm run
- 21:48build we have the following error what
- 21:51we already saw previously and this is
- 21:54this is coming from the SSR do TSX file
- 21:58let's let's open that
- 22:00file and this is coming from the
- 22:02following lines so I'm going to actually
- 22:05remove those um I'm not quite sure why
- 22:09uh these lines are here probably
- 22:11different typescript settings so I can
- 22:13just remove this no problem it is not
- 22:16going to hurt and then we execute mpm
- 22:18run build it's going to execute this
- 22:20typescript command then V build and then
- 22:23it's going to execute V build with D-
- 22:27SSR flag okay now that was built awesome
- 22:32we can check our browser again reload
- 22:35the
- 22:36page uh this is actually uh killed
- 22:39because we have just closed composer R
- 22:41de we can execute a um PHP Artisan serve
- 22:46separately and mpm runev separately as
- 22:49well okay reload the
- 22:53page okay that was open we can go back
- 22:56this is the homepage and and it works
- 22:59slightly slow slow because now we have
- 23:02server side rendering version of the
- 23:05application okay and because of that
- 23:09when actually we reload the page it is
- 23:12kind of slow it needs two three seconds
- 23:13to reload the page then when we navigate
- 23:16it is pretty fast okay so on production
- 23:20when we deploy this this project we need
- 23:23to start the SSR server as well so now
- 23:26let's use inertia
- 23:28serice side rendering from the
- 23:30documentation and if you scroll down
- 23:32below there are a few things to do which
- 23:34we already did most of the things but
- 23:37one thing what we haven't done is to
- 23:39start the iner
- 23:42server um the SSR server so for this we
- 23:45need to execute PHP Artisan iners shot
- 23:47start SSR I'm going to open now new
- 23:50terminal inside one terminal I have PHP
- 23:53Artisan server
- 23:55running here I'm going to paste this
- 23:58here hit the enter and now it started
- 24:01the SSR server and it is serving the
- 24:04built files um which we build through
- 24:09mpm run build comment okay now if we
- 24:13reload the page let's see now this is
- 24:15super fast okay it is serving those
- 24:18pre-build files of course navigation is
- 24:20also super
- 24:22fast okay this is awesome but again so
- 24:25this is fast as we noticed but if we
- 24:29close that inertia server and reload the
- 24:31page it is kind of a little bit slow so
- 24:34on development we don't need this SSR
- 24:36server up and running and we also don't
- 24:39need to execute mpm run build every time
- 24:41when we change something we need to uh
- 24:44start the project with mpm run de so
- 24:47basically we need two commments PHP
- 24:49Artisan serve and mpm run Dave up and
- 24:53running okay awesome now we need to
- 24:56update into latest version of inertia
- 24:59because we're going to use the latest
- 25:01version of inertia features so let's
- 25:03search for or we can directly access
- 25:06version two do inera JS let's hit the
- 25:11enter let's click on this upgrade guide
- 25:14scroll down below uh here are a couple
- 25:16of the main features basically in inera
- 25:192 there are five or six main features so
- 25:22we have to update these first we are
- 25:24going to copy mpm install common to
- 25:27update the in j s react and we can also
- 25:30check inside package Json we have intial
- 25:35JS react version 1.0 something now let's
- 25:39paste this command npm install injs
- 25:42react H next hit the enter then we can
- 25:46copy this composer require as well okay
- 25:49this was finished and right here that
- 25:52was changed into 2. 0.0 beta do2 now
- 25:57let's p paste this composer require as
- 25:59well hit the enter we can open composer
- 26:03Json as well and we can see now this was
- 26:07already switched into version
- 26:102.x this is actually updating the
- 26:12autoload
- 26:13[Music]
- 26:14files again it's going to take few
- 26:16seconds and that
- 26:19was
- 26:21updated so right here um this is the
- 26:24install version but I guess this is
- 26:26actually coming from cach so so that was
- 26:30installed that was switched from 1.3.0
- 26:33into
- 26:352.x okay Alo maybe this is just cache
- 26:38displaying incorrect installed version
- 26:41anyway we have the latest version of
- 26:43inertia and one thing additional thing
- 26:46I'm going to do generally when I um
- 26:49create this L react projects I'm going
- 26:51to change the indent size for TS file
- 26:55TSX file JS file and jsx
- 27:00file okay so now if we open any um TSX
- 27:06file like dashboard TSX we have Force
- 27:09Space indentation right here which I'm
- 27:11going to change which I already changed
- 27:14into two space and if we just format
- 27:17code right here it is going to switch
- 27:19into two spaces this is awesome and the
- 27:22last thing is to actually actually
- 27:23initialize git project because I want to
- 27:25comment everything and put this on my
- 27:27GitHub
- 27:28clear doesn't work so let's execute CLS
- 27:31uh then we need to execute kit in it hit
- 27:34the enter initialized empty repository
- 27:36actually when working with Git I
- 27:38generally use git BH so I have a git
- 27:42bash installed locally on Windows you
- 27:44have to download git this is git B
- 27:46actually and if we if you use PHP storm
- 27:50which is by the way awesome uh the best
- 27:52ID for LEL so right here we can switch
- 27:55to different terminal and I'm going to
- 27:57open know git bash and this is going to
- 28:00be actually to comit and push so because
- 28:02we already initialized this uh with uh
- 28:05git in it now we have we see right here
- 28:08the master branch and if we T type just
- 28:11git status we're going to see everything
- 28:13so let's just add everything here K git
- 28:16comit DM let's call this initial
- 28:21Comet now we're going to install spoty
- 28:24package for roles and permissions and
- 28:26we're going to Define roles and
- 28:28permissions as well so let's bring up
- 28:30the terminal now we have three terminals
- 28:32this is for PHP Artisan surf we can call
- 28:35this surf I General like to give it
- 28:37descriptive names then this is going to
- 28:39be for vit and this is actually gitbash
- 28:42it has proper name and the other
- 28:44terminal is going to be to install new
- 28:46packages or to to run some Artisan
- 28:49commments so in this case we're going to
- 28:51uh install LEL spatty package so we're
- 28:53going to execute composer require spatty
- 28:56LEL permission and actually let's open
- 28:58the documentation as well if you don't
- 29:00know where is that um spotty
- 29:05permissions and the first one is going
- 29:07to be uh LEL permissions package if you
- 29:09scroll down below here is the int
- 29:11introduction we can go into installation
- 29:13in LEL scroll down below and you're
- 29:16going to see the following Artis uh
- 29:17sorry composer comment so you can copy
- 29:21this and hit the enter and then we need
- 29:24to do a few more things so this is kind
- 29:26of optional we don't need to do this but
- 29:28we need to publish the migration in the
- 29:30config file as well so we're going to
- 29:32copy the following command the
- 29:35installation was done so let's paste
- 29:37this hit the enter and it published two
- 29:40files so pay
- 29:42attention copying file into from here
- 29:47into our project config permission PHP
- 29:51done and the second is the new migration
- 29:54file because we already have a git
- 29:56project we can go into to the changes of
- 29:59the PHP storm and we can see these two
- 30:01new files and inside the composer Json
- 30:04we also have this spati Lal permission
- 30:06package is now
- 30:08installed okay so now we need to execute
- 30:11my grade command so we can clear this
- 30:15up and we can execute PHP Artisan
- 30:19migrate hit the enter the migrations we
- 30:21are applied and we have the permissions
- 30:24and roles table already available in the
- 30:27database and while we are talking about
- 30:29this we can also open the database and
- 30:31have a look double click on the database
- 30:34SQ light in PH stor uh click okay and
- 30:39right here we have the project opened
- 30:41will with all the
- 30:43tables uh right here okay and we see
- 30:46permissions rols has permissions rols
- 30:48and everything basically what we need
- 30:50okay the next is actually um I'm going
- 30:53to Define roles and permissions in our
- 30:56project first first let's open user
- 30:59model and we're going to use
- 31:03trade um we have two trades has Factory
- 31:06and notifiable and we're going to use
- 31:08additional trait which is has roles this
- 31:12is coming from spati uh package and we
- 31:15also need to create permissions enam and
- 31:19rules enam for this we can open Terminal
- 31:22and we can execute Artis and commands as
- 31:24well but if you just double click on
- 31:26control on your keyboard This is is
- 31:28going to open this run everything okay
- 31:30and here I can execute PHP artisan make
- 31:34enum and this is going to create a class
- 31:37an Anam not class but Anam inside the
- 31:40app folder but I want to create that
- 31:42inside enam subfolder so enam back slash
- 31:47and I'm going to call this
- 31:50permissions Anam we hit the enter that
- 31:54file was created under up enam
- 31:56permissions en exactly where I want it
- 31:59double click on control again PHP
- 32:03artisan make enm inside enm folder and
- 32:06the second one is going to be
- 32:08rolls uh rolls an we hit the enter that
- 32:12was also created and now let's open
- 32:15permissions enam and we're going to
- 32:18Define couple of permissions so this
- 32:20should be picked enam so we want to have
- 32:23this type of string and let's define a
- 32:26couple of uh cases
- 32:28here so this is for permissions so let's
- 32:31define a couple of permissions like
- 32:32manage
- 32:34features um and I'm using the PHP storms
- 32:39uh autoc completion for the entire line
- 32:41which is awesome feature added into the
- 32:44uh latest version of PHP STM this is
- 32:46awesome so I'm going to use this and
- 32:48it's going to out to complete a couple
- 32:49of things for me so the second case is
- 32:51going to be manage
- 32:56users uh where we're going to have also
- 33:00manage uh
- 33:02comments and we're going to have manage
- 33:06not the manage but um up vote down
- 33:11vote up vote down vote not in plural
- 33:15vote down vote that's additional feature
- 33:19okay uh cool now let's open rules inam
- 33:23and we're going to Define couple of
- 33:26rules right here
- 33:29so we need admin role case admin
- 33:34equals
- 33:37admin case uh user we need user as well
- 33:41in case
- 33:44commenter equals commenter okay and
- 33:47let's also Define um public function uh
- 33:55label labels actually to return all the
- 33:59labels U for those cases so we're going
- 34:02to
- 34:04return we can have like um labels which
- 34:07simply returns uh all the labels and we
- 34:10can also have label which simply returns
- 34:13just one label for that specific uh case
- 34:17so in case of labels probably we should
- 34:19make this
- 34:21static public static function labels and
- 34:24we are going to return um the key key of
- 34:28the enam case and the corresponding user
- 34:32friendly label of that so in this case
- 34:35we are going to do the following so
- 34:37self
- 34:39admin actually self admin uh value is
- 34:44the key and the corresponding value is
- 34:47going to be the label so we don't use um
- 34:51translations it's going to be everything
- 34:52in s into a single language so we just
- 34:55associate admin to it so now let's
- 34:58duplicate these two times here we're
- 35:00going to have
- 35:02commenter commenter and here we're going
- 35:05to have uh
- 35:09user so these are just uh labels which
- 35:13simply returns uh
- 35:16array but we can Define label as well
- 35:20which returns a label of a single case
- 35:23of the enem in this case we're going to
- 35:26return uh m
- 35:28we're going to use
- 35:30this and
- 35:33then uh self admin and in this case we
- 35:38are going to
- 35:40return admin and we can duplicate
- 35:44this uh self user we're going to return
- 35:49user and self uh commenter we're going
- 35:53to return commenter
- 35:58okay awesome so we have
- 36:00actually uh defined the um methods and
- 36:05the um enms and I think we can create
- 36:10those roles and permissions in the
- 36:14database now let's open database Cedar
- 36:18and we're going to create uh roles
- 36:20permissions and users and Associate
- 36:23users to roles and permissions from here
- 36:25so let me actually delete this part or I
- 36:28think we need that user creation part I
- 36:31can remove this and now let's define
- 36:34first roles and then permissions so user
- 36:39Ro is going to be roll spy permissions
- 36:44models role we're going to execute
- 36:47create and we have to provide right here
- 36:50the name of the role so this is going to
- 36:53be roles enam user
- 36:57value now let's duplicate these two
- 37:00times in here we have
- 37:04commenter commenter
- 37:07role here and then we need admin
- 37:13role admin here now let's define
- 37:16permissions so manage we have actually
- 37:19Four permissions manage
- 37:23features
- 37:26permission and the this is going to be
- 37:29permission spy permissions models okay
- 37:34create and we have to provide name to be
- 37:39we're going to use permissions enam here
- 37:42permissions enam manage features value
- 37:47okay awesome now we need to duplicate
- 37:48this three times and the second one is
- 37:53going to be manage comments this one is
- 37:57going to be manage users and this one is
- 38:01going to be upvote downvote and let's
- 38:05give proper names to these variables
- 38:07this is going to be manage
- 38:11comments this is going to be manage
- 38:14users permission and this is going to be
- 38:18up vote down vote permission so now we
- 38:23have roles and we have permissions and
- 38:25we have to associate them them um to
- 38:29each other basically okay so let's use
- 38:33user
- 38:34role and we're going to execute sync
- 38:37permissions and we're going to provide
- 38:39user actually has only one permission
- 38:42and that permission is to up Vote or
- 38:44down vote so this is all regular user
- 38:48can do we have commenter rooll let's
- 38:52called sync permissions and we have to
- 38:55provide two permissions to the
- 38:57commentary so it can actually up vote
- 39:00and down vote but it can also manage
- 39:05comments and that pretty much means to
- 39:09create a new comment or delete uh
- 39:13comment or his own comment or her own
- 39:15comment or uh edit we don't we I think
- 39:18we aren't going to even Implement edit
- 39:19so because we're doing some um just for
- 39:23the demonstration purposes okay of the
- 39:25roles and permissions
- 39:28okay awesome and next we're going to
- 39:30have admin
- 39:32rle again let's call sync permissions
- 39:35but in this case we're going to have all
- 39:37um available permissions like we need up
- 39:40vote down vote permission manage
- 39:43users manage comments and manage um
- 39:47features we don't need users twice
- 39:50manage features
- 39:52permission okay now we have roles
- 39:54permissions Associated users um sorry
- 39:58the roles to permissions and now I think
- 40:00it's time to create users and Associate
- 40:04roles to those users so we have user
- 40:07creation code right here let's call this
- 40:10user user and let's give it email user
- 40:14example.com and then we are going to
- 40:17call assign role and we have to provide
- 40:21right here the RO name which we want to
- 40:25assign to the user and and we can use
- 40:28roles
- 40:30enam user right here okay so this is the
- 40:35rule we want to assign to that specific
- 40:38user now we need to duplicate these two
- 40:40more times one this is the user now this
- 40:43is going to be commenter user let's give
- 40:47it also email commenter and we're going
- 40:50to assign roll commenter roll to it now
- 40:54this is going to be admin user
- 40:57admin example.com and this is going to
- 41:00have admin role now we have defined
- 41:03roles permissions users assign
- 41:04everything to it and I think we can
- 41:06execute now migrations or we can simply
- 41:09execute uh seed command or migrations
- 41:12with the seed comment so let's execute
- 41:15PHP Artisan migrate fresh D- seat let's
- 41:20hit the enter we could simply execute
- 41:22seed commment as well now it it seeded
- 41:24the database and if we check in the
- 41:26users table we see three users if we
- 41:28check roles table we see three roles if
- 41:31we check also uh R has permissions we
- 41:34see a couple of Records here as well and
- 41:36inside permissions as well we see those
- 41:40permissions okay this is actually pretty
- 41:44cool if we also want to check uh which
- 41:47roles are associated to the user we need
- 41:50to see that inside model has permissions
- 41:53and model has roles tables which are
- 41:55actually for abstract
- 41:57for polymorphic relations so here we see
- 42:00modle ID one two and three and the modle
- 42:03type is the user class name so basically
- 42:06user with ID one has the following C
- 42:09user with id2 has the following C and so
- 42:13one and in the same thing inside the
- 42:15model has permissions we see what
- 42:18permissions are actually assigned to
- 42:21models and in our case we haven't
- 42:23assigned any specific permissions to the
- 42:25users we just assigned roll to to them
- 42:28when the new user is registered on our
- 42:31website basically the user is
- 42:33automatically verified but we want to
- 42:35enable email verification that's
- 42:38why let's open user PHP and we are going
- 42:42to implement an interface must verify
- 42:46email okay and now when the user tries
- 42:49to register the user will receive an
- 42:51email however I want to also set up test
- 42:56mail fake mail client locally which is
- 42:59called mail pit so this is actually very
- 43:02awesome for just a local mail sending so
- 43:05mail ped just type in the Google ma mail
- 43:08ped open the very first link so then we
- 43:11can click on installation scroll down
- 43:13below and find the on on Windows
- 43:17basically find the following section
- 43:19download static binary click on releases
- 43:22so this is going to open GitHub page
- 43:24scroll down below and we have right here
- 43:27the assets for the latest release and
- 43:30just open the just download the latest
- 43:34version for your operating system which
- 43:37I actually have already downloaded so
- 43:39I'm going to open this right now and I
- 43:43have that folder I put that folder in my
- 43:46home directory under mail mail pit
- 43:49folder and right here I have this mail
- 43:51pit XEL and we actually need to start
- 43:54that mail pit XEL however I'm I'm going
- 43:57to I also made that mail pit comment
- 43:59globally available by adding the
- 44:02following path into systems variable
- 44:05path which means that if I open new
- 44:08terminal which I actually have opened
- 44:11right here this is where I created the
- 44:13project I can actually clear this up and
- 44:16let's go into home folder and right here
- 44:19I can execute mail pit so this is the
- 44:24global command available right now on my
- 44:26computer here the enter and it's going
- 44:27to start mail pit server listening on
- 44:30two ports 1025 and 825 so I recommend to
- 44:35add this into your systems variable the
- 44:38path of the mail pit as well so that you
- 44:40can have this mail pit common globally
- 44:42available or if you don't want to add
- 44:45that into like systems variable you can
- 44:48always go into the folder where you have
- 44:51that mail pit XA file you download it
- 44:53probably it's going to be inside
- 44:55downloads just go into the folder and
- 44:57right here you need to open the terminal
- 45:00so we can open new
- 45:02terminal here we can navigate into the
- 45:05following folder and here we have this
- 45:07mail pit also so we hit the enter and
- 45:11the mail pit was started on 10 25 and
- 45:148025 now we can open this 8025 in the
- 45:17browser and this is the client and we
- 45:20have to configure the SMTP in our
- 45:24project so let's open file and find the
- 45:28mail section and here we have this mail
- 45:31mailer which is by default log so every
- 45:34new mail uh is sent into the log files
- 45:37which we want to change into
- 45:39SMTP so the host is going to be
- 45:421271 the port is going to be the mail
- 45:45pit port and this is going to be SMTP
- 45:48Port 1025 no encryption so we're going
- 45:52to provide 10 25 and there is nothing we
- 45:55need to do uh right here so that's
- 45:59already done SMTP host and
- 46:03Port now let's try to create new account
- 46:07let's close this tab this tab as well we
- 46:10can leave the permissions we can leave
- 46:11the iner as well so now let's try to
- 46:14register using Zur zoraa example.com
- 46:17let's provide some secure password
- 46:22Here we hit the enter and we save this
- 46:26and and look at this so now we are not
- 46:28verified and it tells us that we need to
- 46:30check the email so here is the mail ped
- 46:32we see one here so we received new email
- 46:35just click on this and this displays our
- 46:38email nicely in the browser we click on
- 46:40this verify email address and here it
- 46:44goes now we are verified and we see the
- 46:46dashboard we can reload this page as
- 46:48well and we are going to see dashboard
- 46:50right here as well so let's close this
- 46:52we have this mail pit local client which
- 46:54is awesome for local testing of s emails
- 46:57and also make sure you don't kill that
- 47:00mail pit command that should be running
- 47:03in the background so that whenever we
- 47:05are testing we need to have this comment
- 47:06running otherwise simply we won't
- 47:09receive any emails right here now let's
- 47:12open PHP
- 47:15stor first let me actually comment the
- 47:17changes I made so I just implemented
- 47:21this must verify email so add email send
- 47:27in on
- 47:29registration so let's comment
- 47:31this awesome so now let's open handle
- 47:36inera JS request by the way the comment
- 47:38I made right now was only for the file
- 47:41user PHP but previously I made some
- 47:43changes when I edit rols and permissions
- 47:46in the database Seer I actually already
- 47:48made the comment for this and we can see
- 47:50this in the G comment history so the
- 47:51initial comment to find roles and
- 47:53permissions and then I added the
- 47:55following comment add send sending email
- 47:57sending on
- 47:59registration okay cool now I want to
- 48:02open this handle inera JS request and
- 48:05from here we have these shared props for
- 48:10the um react component so we have out
- 48:13user which is the request user which I
- 48:16want to change so I want to Define two
- 48:18resources for
- 48:20users I'm going to double click on
- 48:22control on the keyboard PHP artisan make
- 48:28resource first I'm going to Define out
- 48:30user resource which is going to be the
- 48:34resource for the authenticated user hit
- 48:36the enter
- 48:38next I'm going to Define just user
- 48:42resource hit the enter okay now I have
- 48:45two resources first let's open user
- 48:48resource which is going to be simpler
- 48:50and from here I want to return the
- 48:53properties for the other users like if
- 48:56one user is just viewing the um page the
- 49:00application and if other users left some
- 49:03comment or create to the Future the
- 49:06other users information will uh
- 49:09basically run inside this
- 49:12resource so we just need
- 49:15ID this ID duplicate this two times we
- 49:21need
- 49:23name and we need email so this is this
- 49:26is for user resource now let's open out
- 49:30user
- 49:31resource and here we need few more
- 49:34things than just ID name and email so
- 49:38obviously we need those fields as well
- 49:42this ID duplicate this few more times we
- 49:46need
- 49:47name we need email but we need a couple
- 49:51of other things like we can also add
- 49:54email verified ad
- 49:59uh but we also want to return roles and
- 50:02permissions so what roles and
- 50:04permissions the current user has so
- 50:06let's define permissions first here and
- 50:09this is going to be this which is user
- 50:12in this case this get all permissions so
- 50:17this basically this get all permissions
- 50:20is coming from this has rules trait
- 50:25because we added it into this user now
- 50:27user has this get all permissions and we
- 50:31this is going to return actually
- 50:32instances of the eloquent models of the
- 50:34permission so we are going to uh run
- 50:37this inside the map
- 50:40function uh let's move this map actually
- 50:44down and then from here we are going to
- 50:46Simply return the permission name so we
- 50:48only want permission names not the
- 50:50entire objects on uh front end in react
- 50:54so next we need r roles and there is uh
- 50:59this is actually simpler so we have this
- 51:03get roll names get R names method
- 51:08available inside um this H roles trait
- 51:13so in just like this we are returning
- 51:14permissions and rules for the user and
- 51:17actually we can check that so if we open
- 51:20dashboard
- 51:22TSX scroll up uh and open this authentic
- 51:26ated layout here we are accessing this
- 51:29user which is coming from this page
- 51:32props out user that out user is exactly
- 51:35what we are returning from here but
- 51:37first we need to change this into
- 51:40resource so we have this request user
- 51:42which I'm going to extract into a
- 51:44variable called user then I'm going to
- 51:46check if the user exists then I'm going
- 51:49to run this in Inside Out user resource
- 51:53actually we need to use new out user
- 51:55resource Prov providing that user
- 51:57otherwise we're going to return
- 52:00null now right here that user basically
- 52:03will be a result of out user resource if
- 52:06the user exists otherwise it's going to
- 52:07be null so what we can do is just print
- 52:11the user and because we changed the
- 52:13indentation into two spaces by default
- 52:16that was set to four now uh the default
- 52:20um now when I generated this console log
- 52:23basically it was set like this with two
- 52:26spaces actually we have to Simply
- 52:28reformat the file contrl alt and L on
- 52:32the keyboard so that reformatted the
- 52:34file let's just print the user save that
- 52:38and let's open developer tools go into
- 52:40console here we see the object this is
- 52:42the user object and let's reload the
- 52:46page and have a look so we have the data
- 52:50actually I don't want the data so let's
- 52:53open Al user resource and we are going
- 52:56to said R equals
- 52:59false that WP basically creates that
- 53:02additional data which we don't want so
- 53:05we set the W equals false and we
- 53:08probably need to do the same thing in
- 53:10the user
- 53:13resource R equals
- 53:17false awesome now we reload the
- 53:21page and now we see here user and that
- 53:24user has permissions and r as well and
- 53:28actually both of them are null because
- 53:31right now I'm authenticated as user zura
- 53:33Zur is just created user and that user
- 53:35doesn't have any roles and permissions
- 53:38but if we log out and if we try to log
- 53:40in with admin n example.com
- 53:44hit the
- 53:46[Music]
- 53:47enter okay let's open the developer
- 53:49tools reload the
- 53:51page and here we see the uh user admin
- 53:55and we see that that user has four
- 53:58permissions and one role admin role okay
- 54:02that's awesome and just like this we
- 54:04have the the necessary uh resources for
- 54:08the authenticated user as well as for
- 54:10the general user which we are going to
- 54:11use in the future now let's define
- 54:14migrations models uh and controller in
- 54:19case if we need that for our project
- 54:22basically so we're going to work on the
- 54:23database schema first let's come into
- 54:26again everything would we change so far
- 54:29uh create new user
- 54:36resources awesome our files were
- 54:38committed now let's close
- 54:42everything and let's double click on
- 54:44control and we execute PHP artisan make
- 54:48model first we're going to create
- 54:51feature model and I'm going to generate
- 54:53this with migration file as well
- 54:57we need to generate controller as well
- 54:59and that controller should be resource
- 55:02controller okay so we hit the
- 55:05enter these files were generated so we
- 55:09see model we see migration and we see
- 55:12controller okay next is to create the
- 55:16upfold model so PHP artisan make model
- 55:23upvote model and we need to generate
- 55:25only migration for
- 55:28that we hit the enter and the next one
- 55:31is
- 55:32to actually
- 55:34create comment model so we hit the enter
- 55:38the comment model and the migration was
- 55:40created now let's open create features
- 55:45table and right here we need to define a
- 55:48couple of columns like we need table
- 55:50string name that's correct we need
- 55:54table uh long text description and we're
- 55:58going to make this nullable and on table
- 56:02we also want to Define um foring ID for
- 56:08user
- 56:11model awesome now let's open second
- 56:14migration file create up folds table and
- 56:19here we need to Define foring
- 56:24ID ping ID um feature
- 56:29ID this is
- 56:32constrained by
- 56:35features and we can move this down and
- 56:39we need Cascade on delete as well so if
- 56:43the feature is deleted its uploads are
- 56:45deleted as well and in the same way we
- 56:48need foring ID on user the column name
- 56:52is the user ID it it is constrained by
- 56:55users
- 56:56and Cascade on delete as well and I
- 56:59think we don't need time stamps so we
- 57:01can remove that we can simplify things a
- 57:04little bit and then we need Boolean
- 57:07upvote so that table basically
- 57:10defines if that specific user has
- 57:13upvoted that feature or downvoted that
- 57:16feature so inside up vote we have one
- 57:18and zero one means that the user upvoted
- 57:21that feature zero means that user
- 57:24downvoted that feature that's all now
- 57:27let's open third migration file
- 57:31create uh comments table and here we
- 57:35need to
- 57:37Define um
- 57:40string comment which can be a little bit
- 57:43larger text like 2,000 but it should be
- 57:47required then we need a foring ID that
- 57:51should be feature ID constrainted on
- 57:56features and we can provide Cascade on
- 57:58delete as well let's move this down and
- 58:03we need also user so that's going to be
- 58:06user ID constraint on users and Cascade
- 58:11on delete and we can have also time
- 58:13stamp on the comments because sometimes
- 58:15we need to display at what time the
- 58:17comment was
- 58:18made okay this is good now let's open
- 58:22feature PHP model and we def find
- 58:26relations here we are going to use has
- 58:29many keyword which comes with I think
- 58:31with a lot um blade sorry with Lal ID
- 58:36plugin so then we need up votes here and
- 58:40we need to use up vote
- 58:44class we have another has many or
- 58:49comments here we need comment class and
- 58:53we have belongs to
- 58:56uh user and here we need user
- 59:04class okay so we need to open comment
- 59:07model as well and we need to Define
- 59:10belongs to user so comment belongs to a
- 59:15user let's use user
- 59:18here and comment also belongs to
- 59:24feature so here here we need feature and
- 59:28we have to open user as well and user
- 59:33has
- 59:34many uh
- 59:38features and user also has many comments
- 59:42but I think we don't need that actually
- 59:44so we can Define this but we are not
- 59:46going to use this because we are
- 59:48interested comments for the specific
- 59:50feature not General all the available
- 59:53comments of the user so we don't need
- 59:54that uh again again let's go back into
- 59:58feature and we need to open this up v as
- 1:00:01well and we can also Define this uh
- 1:00:04belongs to belongs to feature maybe we
- 1:00:08are not even going to use all the
- 1:00:10relations what we defined right here um
- 1:00:13but I'm just defining I think that's all
- 1:00:16so we we created the migrations we
- 1:00:19created the models uh we Define the
- 1:00:22relations and let's just open feature
- 1:00:24controller and I think now we're going
- 1:00:26to focus on the feature controller which
- 1:00:28is actually a resource controller right
- 1:00:30now for feature model now let's comment
- 1:00:34all the changes what we made so far
- 1:00:36Define models in migrations is going to
- 1:00:38be the comment message click on
- 1:00:40comment and that was done now let's
- 1:00:43close
- 1:00:44everything and we are going to uh focus
- 1:00:47on the next step and this is going to be
- 1:00:49to render features but to render
- 1:00:53features first we we have to create some
- 1:00:56seed data so for this I want to actually
- 1:00:59create a factory class for the features
- 1:01:03PHP artisan
- 1:01:05make Factory and let's call this feature
- 1:01:11Factory we hit the enter feature Factory
- 1:01:13was created now let's open feature
- 1:01:17Factory and we have to return a couple
- 1:01:20of things so we have the name instead of
- 1:01:23this Faker I'm going to use actually
- 1:01:25fake function
- 1:01:26we need fake um name okay I don't want
- 1:01:30name I just want fake text okay because
- 1:01:33feature name is not going to be a name
- 1:01:35it's going to be some
- 1:01:37text okay so we have name to be feature
- 1:01:40text we have the description which going
- 1:01:42to be again text but we have to provide
- 1:01:44uh larger number of characters and we
- 1:01:48have to provide the user ID as well so
- 1:01:51for user ID I'm going to assign every
- 1:01:54feature to the admin user because admin
- 1:01:56user is going to be only user who is
- 1:01:59able to create new features so let's use
- 1:02:02user we so right now because we are
- 1:02:05actually faking the data now we have one
- 1:02:08admin user which has email admin at
- 1:02:11example.com so I'm going to just select
- 1:02:13the user which has email admin
- 1:02:16example.com and first and we are going
- 1:02:20to Simply get its ID of that user ID and
- 1:02:24just like this we have that field
- 1:02:26defined now let's open database Cedar
- 1:02:29scroll down below and right here I'm
- 1:02:31going to call uh feature
- 1:02:35Factory we have to provide 100 here I'm
- 1:02:38going to create 100 features and then
- 1:02:40let's call
- 1:02:42create now let's save everything uh we
- 1:02:45can open Terminal or we can hit double
- 1:02:49um on control and execute PHP Artisan
- 1:02:53migrate actually we have to to execute
- 1:02:56migrate fresh with Dash Das seed as well
- 1:02:59because we want that seed data to be
- 1:03:02rerun we hit the
- 1:03:04enter we have an error interesting uh
- 1:03:08okay feature Factory okay that's that's
- 1:03:11uh good so the error actually is not
- 1:03:13good but um we can easily fix
- 1:03:16that let's open feature. PHP model and
- 1:03:21we are going to H use trade has
- 1:03:24Factory now let's re-execute that hit
- 1:03:27the
- 1:03:30enter okay so that was finished now
- 1:03:32let's open the
- 1:03:34database
- 1:03:37open features and we see 100 features
- 1:03:40inside the database we see user ID
- 1:03:43created it updated it and everything is
- 1:03:46there okay that's cool now I think we
- 1:03:48can focus on rendering those features um
- 1:03:52on the front end side first let's open
- 1:03:57uh feature
- 1:04:00controller I'm going to drink
- 1:04:07water return and we have to actually
- 1:04:11select these features and return
- 1:04:15them however we're going to use also
- 1:04:17resource to return the data so I'm going
- 1:04:20to create now feature resource uh PHP
- 1:04:24artisan make
- 1:04:26resource feature resource it is always
- 1:04:30good practice to create resources and
- 1:04:33Define what data you want to be returned
- 1:04:37on the front end which is in our case
- 1:04:39react application because if you return
- 1:04:42everything without resource you might
- 1:04:44expose some uh confidential data which
- 1:04:47we don't
- 1:04:49want okay we created feature
- 1:04:54resource let's let's first open feature
- 1:04:57resource we will come back to the
- 1:04:59controller and we're going to return a
- 1:05:00few things from here so we need ID
- 1:05:04obviously this ID let's duplicate this
- 1:05:07few times uh we need
- 1:05:12name we need a description to return we
- 1:05:17also want to return the user information
- 1:05:20okay so user and here I can directly
- 1:05:24return this user but again this user is
- 1:05:27going to be an instance of the eloquent
- 1:05:28model and I want to put that into
- 1:05:30resource and for exactly this purpose we
- 1:05:33created user resource which we haven't
- 1:05:37used so far okay and we also need to
- 1:05:40return created
- 1:05:44at this created it and we can uh call
- 1:05:48format here with the following format
- 1:05:51year month day h i and S okay now we
- 1:05:56have this feature resource let's go into
- 1:05:58controller and from here I'm going to
- 1:06:01call inertia render and I'm going to
- 1:06:04provide the following component which I
- 1:06:06want to create so that doesn't exist yet
- 1:06:08we're going to create that so and inside
- 1:06:11the feature index we are going to pass
- 1:06:14features which is going to be uh feature
- 1:06:19resource collection okay we have to
- 1:06:22provide the collection here and we have
- 1:06:25to select
- 1:06:28feature
- 1:06:30latest actually let's take this
- 1:06:32out and let's call this
- 1:06:36paginated feature
- 1:06:38latest uh and pinate we have to call
- 1:06:42paginate let's provide the um no
- 1:06:45argument here and by default it's going
- 1:06:47to take the 15 features as I remember so
- 1:06:50we need to take this paginated and
- 1:06:52provide this into collection right here
- 1:06:54now we have to Define this feature index
- 1:06:57so let's go into resources
- 1:07:00JS pages and we have dashboard right
- 1:07:03here now I'm going to create new folder
- 1:07:06this is going to be feature we hit the
- 1:07:09enter now let's copy the dashboard TS6
- 1:07:12and put this inside
- 1:07:14feature and we have to call this index
- 1:07:18TS6 okay so now feature index view file
- 1:07:22actually exists let's open this index
- 1:07:25IND TSX and we have to change this
- 1:07:27dashboard into index and we have to
- 1:07:30accept right here props and we are
- 1:07:33passing actually features from here so
- 1:07:36we have to
- 1:07:38accept
- 1:07:40features now this is actually
- 1:07:42interesting part so we are accepting
- 1:07:44features right here but because we are
- 1:07:47using typescript we have to actually
- 1:07:50Define what type of instance these
- 1:07:53features is
- 1:07:56if we don't Define these types so it is
- 1:07:58going to actually work while we're
- 1:08:00developing this and let's try to now
- 1:08:03authenticate with admin
- 1:08:05user actually we don't uh use that view
- 1:08:10at the moment so let me do the following
- 1:08:12so let's change this dashboard into
- 1:08:15features and here we have the dashboard
- 1:08:18and let's just print inside preag using
- 1:08:22Json stringify
- 1:08:25provide
- 1:08:26features
- 1:08:28undefined
- 1:08:30to okay awesome now let's open web. PP
- 1:08:34and we want to Define this um
- 1:08:38root so first we don't need this welcome
- 1:08:41page anymore so I'm going to remove
- 1:08:45this uh we are going to let me think so
- 1:08:50let's actually do redirect so from slash
- 1:08:52we are going to do redirect into
- 1:08:54dashboard
- 1:08:56Okay cool so now inside the dashboard we
- 1:08:58render this dashboard blade um not plate
- 1:09:02but the react file and this is something
- 1:09:04I want to
- 1:09:05change uh here we have this middleware
- 1:09:08for out and we have this profile
- 1:09:11management and this is what I'm going to
- 1:09:12do inside out I'm going to Define
- 1:09:16another middle wear and this is going to
- 1:09:18be verified middle wear so middle
- 1:09:21wear verified which means that the user
- 1:09:24needs to be authenticated and verified
- 1:09:27to be able to access dashboard this is
- 1:09:29exactly what is written here so let's
- 1:09:33copy this part and we can delete this
- 1:09:35middle
- 1:09:38gear okay user needs to be authenticated
- 1:09:42and verified to be able to access
- 1:09:44dashboard in the same way user needs to
- 1:09:47be authenticated and verified to be able
- 1:09:49to access Feature Feature page and in
- 1:09:52this case we need to provide here
- 1:09:56feature controller index and we have to
- 1:09:59provide the name as well feature index
- 1:10:02and just like this we Define the root
- 1:10:04for feature now let's go into index TSX
- 1:10:10let's open this authenticated layout
- 1:10:12let's find dashboard here this is the
- 1:10:16navigation item dashboard and I'm going
- 1:10:18to copy and paste this and change that
- 1:10:22so we need features index the wrote name
- 1:10:26here we also need features index and the
- 1:10:29menu item to be features and we have
- 1:10:31dashboard also in the second place for
- 1:10:34the responsive nav link and we have to
- 1:10:36copy
- 1:10:38this and adjust this as well so we need
- 1:10:41feature
- 1:10:42index Fe feature index here and features
- 1:10:49here as well now if we save this and
- 1:10:52reload the
- 1:10:53page we
- 1:10:55have couple of
- 1:10:57Errors okay let's see what errors do we
- 1:11:05have dashboard is not in the rot list
- 1:11:08okay makes sense so if you open web PHP
- 1:11:11we we simply remove the name for the
- 1:11:14dashboard Ru so we have to
- 1:11:16provide name to be dashboard save that
- 1:11:20reload that
- 1:11:25and here we go now let's click on
- 1:11:28features and here we have these features
- 1:11:31and here we have the entire data so even
- 1:11:34though at the moment we don't have types
- 1:11:37Associated to these features this is
- 1:11:39going to actually work and we see the
- 1:11:42features object which has data if you
- 1:11:44scroll down below there are 15 features
- 1:11:47I guess by default inside this paginated
- 1:11:48data then we have links and meta and
- 1:11:52that's it basically and we can expand um
- 1:11:55that features I think we don't print
- 1:11:56that features right here but we can
- 1:11:58actually print features here as
- 1:12:02well here it is Data links and meta okay
- 1:12:06so what we need to do is to Define now
- 1:12:10type and again to come back to this so
- 1:12:12even though this works right now it is
- 1:12:14not going to work when we try to build
- 1:12:16the project for production so here we
- 1:12:18have this V server if I close this and
- 1:12:21execute mpm run run build now it is not
- 1:12:27going to work
- 1:12:31anymore so as you see the error is
- 1:12:34coming from here implicitly has any type
- 1:12:37so we can obviously provide that these
- 1:12:39features has any type but this is not
- 1:12:41what we want we want to Define proper
- 1:12:44types because we are using
- 1:12:46typescript so for this I'm going to open
- 1:12:48index. d. TS which has some predefine
- 1:12:52types let's format this into two space
- 1:12:56and we have a couple of interfaces and
- 1:12:58types like for the user interface and we
- 1:13:00have some page props as well and a few
- 1:13:03other
- 1:13:04things first because for the
- 1:13:06authenticated user we addit permissions
- 1:13:09and draws so if we check out user
- 1:13:13resource um right here we have this
- 1:13:16permissions and trols this is something
- 1:13:18we need to also add right here in this
- 1:13:20user because that user is used inside
- 1:13:24the page props
- 1:13:26okay inside out user and if we check the
- 1:13:28usage of page props we're going to see
- 1:13:30this into a couple of places we see this
- 1:13:32in the welcome page and we see in the
- 1:13:34profile page as well uh and if we open
- 1:13:37this for
- 1:13:38example we only use must verified email
- 1:13:41and status in this case if we check
- 1:13:44another example on the welcome page we
- 1:13:48use out LEL and PHP
- 1:13:51version actually I think we don't even
- 1:13:54use user when we use page props but my
- 1:13:57point is that if we
- 1:14:00use let's open this example so right
- 1:14:03here if we decide to use Al and we know
- 1:14:06that that Al actually has user so right
- 1:14:10here we could access al. user and this
- 1:14:14is autoc completed and this is coming
- 1:14:16from these types okay but that user has
- 1:14:21name email verify dat email and ID but
- 1:14:24that user does not have uh permissions
- 1:14:27or roles even though it actually has
- 1:14:31okay because we return that from this
- 1:14:33out user resource the permissions and
- 1:14:36roles that's why we need to Define this
- 1:14:39properly so right here let me Define
- 1:14:42permissions which is actually an array
- 1:14:45of
- 1:14:46strings and roles again array of strings
- 1:14:51now if we go in edit TSX control and
- 1:14:54space is now it has permissions array of
- 1:14:57strings and roles as well okay I'm going
- 1:14:59to undo these changes right here because
- 1:15:01I am not actually making some changes in
- 1:15:03this edit TSX file at the moment so we
- 1:15:05can close this welcome as well now let's
- 1:15:09focus on this um types index DTS file
- 1:15:13okay so we added these roles and
- 1:15:15permissions here now let's define new
- 1:15:17type export type I'm going to call this
- 1:15:22paginated data and that actually
- 1:15:26equals into the following object so we
- 1:15:29have
- 1:15:30data and this is also kind of something
- 1:15:33interesting so we can make this data to
- 1:15:36be something okay the data is actually
- 1:15:40an array of feature
- 1:15:43objects so we have to actually Define
- 1:15:47the feature object as well and make that
- 1:15:51paginated data to know that it is
- 1:15:54actually actually it contains data to be
- 1:15:57an um array of feature objects it sounds
- 1:16:00complicated but let me just make this
- 1:16:02simple okay so inside this pated data we
- 1:16:06going to accept t as a type which can be
- 1:16:09anything okay then the data is going to
- 1:16:12be type of T an array basically of
- 1:16:18T and inside links we're going to have a
- 1:16:23record of
- 1:16:25string and string so it's going to have
- 1:16:27some key value Pi there okay so it's
- 1:16:30going to be record of string and string
- 1:16:33let's just have a look at the data and
- 1:16:34we're going to understand this better
- 1:16:36now we can use this paginated data
- 1:16:39inside right
- 1:16:41here so features actually is a type
- 1:16:46where
- 1:16:47features is pated data and we can
- 1:16:51actually provide type right here what
- 1:16:54type of features what type of data is
- 1:16:57inside features this so far is already
- 1:16:59good and we don't see any errors but for
- 1:17:02additional autoc completion so now we
- 1:17:04see that the features is an paginated
- 1:17:07data but when we try to iterate features
- 1:17:10over data which we're going to do right
- 1:17:12here like features dot let's use
- 1:17:16features. data and when we start
- 1:17:20iterating over that we accept feature
- 1:17:23right here as an example and then we try
- 1:17:27to print feature. name but now um
- 1:17:32typescript doesn't know what is this
- 1:17:34feature okay it doesn't have any idea
- 1:17:36about this that's why we have to define
- 1:17:39feature as well export type
- 1:17:45feature and we need uh basically let me
- 1:17:48just quickly copy and paste this
- 1:17:51part so we need ID name description the
- 1:17:54user user object itself and created that
- 1:17:57this is what we defined in the where is
- 1:18:00that in the feature resource here here
- 1:18:06okay so now if you open
- 1:18:09index. TSX file right here we need to
- 1:18:12provide inside this less than and
- 1:18:15greater than symbol the type feature
- 1:18:18type now typescript knows that right
- 1:18:21here this feature actually has a type of
- 1:18:24feature
- 1:18:25so that's why uh if we save
- 1:18:31that let's actually change this into
- 1:18:34something
- 1:18:36like this the error is actually gone
- 1:18:40okay but without that feature definition
- 1:18:44the
- 1:18:47error yeah implicitly implicitly it has
- 1:18:50type of any so this technically doesn't
- 1:18:53give us an error uh but if we try to
- 1:18:56build that might give us an error let's
- 1:18:58execute mpm run build or it might not
- 1:19:01give us an error but it also doesn't
- 1:19:03autocomplete it so it doesn't give us an
- 1:19:07error but if we try to access some
- 1:19:10fields of the feature it doesn't have
- 1:19:12any idea what fields that feature has
- 1:19:15but as soon as we provide here
- 1:19:20feature scroll down below then it knows
- 1:19:24it has user user name ID description and
- 1:19:27so on couple of other things okay so
- 1:19:29we're going to come back to this now and
- 1:19:31render features okay so for each feature
- 1:19:34I want to create separate component to
- 1:19:36render that feature item so inside
- 1:19:39resources JS components I'm going to
- 1:19:41create
- 1:19:42new feature item um typescript jsx file
- 1:19:48okay let's hit the enter click add now
- 1:19:52export default
- 1:19:55um
- 1:19:56function feature
- 1:20:00item okay we are going to
- 1:20:03return some template from
- 1:20:07here function feature okay we can remove
- 1:20:10these props and actually we're going to
- 1:20:11accept right here feature then we Define
- 1:20:14the type feature as a type of feature
- 1:20:19and we have to import that from types
- 1:20:22cool and if we go into T6 so this is
- 1:20:25actually a card so let me think I think
- 1:20:31we can just take this
- 1:20:34out or I think we should take this part
- 1:20:37out this is card go in the feature item
- 1:20:41put this
- 1:20:43here uh and we are going to render the
- 1:20:46feature item itself so here we need the
- 1:20:49feature item let's use pre-ex and just
- 1:20:52use
- 1:20:53json.
- 1:20:56stringify uh
- 1:20:58provide actually it should be uppercase
- 1:21:00all uppercase Json stringify feature
- 1:21:04undefined
- 1:21:06to cool and right here we need that
- 1:21:12iteration of features
- 1:21:13data and we're going to use feature item
- 1:21:18providing that
- 1:21:20feature okay cool now we save that and
- 1:21:24let's check in the
- 1:21:25browser uh we don't have V server up and
- 1:21:28running mpm run Dev we have to execute
- 1:21:32this okay that's good let me drink a
- 1:21:36little bit of
- 1:21:39water okay it is going to
- 1:21:45reload and here we
- 1:21:47have data for each feature okay we have
- 1:21:51different cards let's actually open this
- 1:21:53feature item and give it also some class
- 1:21:56like margin bottom four maybe something
- 1:21:59like this and we have these cards for
- 1:22:01each feature which is pretty cool um
- 1:22:06okay so we have some width and height
- 1:22:09definition on the dashboard as well as
- 1:22:11on the features which I'm going to move
- 1:22:13in the layout like inside index we have
- 1:22:16this pading y12 MX and so on which you
- 1:22:19have on the dashboard page as well so
- 1:22:22let me cut this delete the closing text
- 1:22:24as
- 1:22:26well and let's open dashboard as well
- 1:22:31and cut this delete this closing D tags
- 1:22:35as well we can leave this here and let's
- 1:22:38open this authenticated layout and if we
- 1:22:41scroll down
- 1:22:42below here we have this main tag and
- 1:22:45we're going to wrap this
- 1:22:48St around this main tag these two divs
- 1:22:51so if I save this reload the page the
- 1:22:54result is not going to change so on
- 1:22:55features we see the same result and on
- 1:22:57dashboard we see the same result let's
- 1:22:59zoom in into 100 and now let's focus on
- 1:23:04rendering um each individual feature
- 1:23:08item okay let's open feature item let's
- 1:23:14delete this
- 1:23:16and actually I'm going to do the
- 1:23:18following so first I'm going to Define
- 1:23:20one div with uh with flex
- 1:23:26okay actually I think we need to give
- 1:23:29Flex to this so let's give it flex and
- 1:23:32let's give it gap of
- 1:23:39eight so then I need two divs one is
- 1:23:43going to be for the title for the name
- 1:23:46of the feature and description of the
- 1:23:47feature and second is going to be for
- 1:23:51the up vote and down vote but
- 1:23:55for that specific feature okay so we
- 1:23:57need two
- 1:23:58divs so I'm going to now use hero
- 1:24:02icons hero econs and we can search for
- 1:24:06Chevon uh I want this icon Chevron up
- 1:24:11this
- 1:24:12one why I can copy this
- 1:24:15okay um this is Chevon up and then I
- 1:24:20need Chevon down as well so I need these
- 1:24:23two SVG icons and I'm going to also put
- 1:24:27them inside span
- 1:24:31Texs okay let's put this inside span as
- 1:24:35well or maybe we should even change this
- 1:24:37into buttons let's make this
- 1:24:40button and button and I'm going to put
- 1:24:45span here which is going to be number of
- 1:24:48um app FS let's put 12 here okay so but
- 1:24:52because we are using react we need we we
- 1:24:54should not use this dashed approach we
- 1:24:57should change this into camel case
- 1:24:59approach um field rule clip
- 1:25:02[Music]
- 1:25:05rule what else do we
- 1:25:12have
- 1:25:14Okay
- 1:25:16cool so I want to put that div in front
- 1:25:20of the name and the description so this
- 1:25:24is going to be so this one has display
- 1:25:26Flex this is going to be in front of it
- 1:25:28and now this one should have Flex of one
- 1:25:31and inside here we need H2 let's give it
- 1:25:36class name of text um two Excel let's
- 1:25:42give it also margin button two and I
- 1:25:44want to Output feature. name the auto
- 1:25:47completion works perfectly okay then I
- 1:25:51want to display the feature description
- 1:25:53so inside paragraph let's output
- 1:25:56feature. description let's save this and
- 1:26:00have a look in the
- 1:26:01browser
- 1:26:03okay what is
- 1:26:05this I probably copied incorrect one so
- 1:26:10that is Chon
- 1:26:12up this is Chon
- 1:26:16up F
- 1:26:19rule rule
- 1:26:21here oops save that
- 1:26:25okay cool uh we just need to give this
- 1:26:29one uh
- 1:26:32FX and flex column and we probably need
- 1:26:37items Center as
- 1:26:41well okay that's nice however we have to
- 1:26:44increase the size a little bit so on
- 1:26:47that SVG let's provide text uh to Excel
- 1:26:52and let's give it font semi Bol as well
- 1:26:56and on that
- 1:26:58SVG we have to adjust the class name
- 1:27:01let's change this into
- 1:27:0312 and here as well we have to change
- 1:27:08this into 12 to increase the size a
- 1:27:11little bit okay that's much better we
- 1:27:13have the title we have the description
- 1:27:16however I want to make that description
- 1:27:18uh kind of um show more show less
- 1:27:22toggling uh type of description so
- 1:27:24here's what I'm going to do so I'm going
- 1:27:26to
- 1:27:28Define State
- 1:27:31const uh we need is
- 1:27:34expanded expanded and
- 1:27:38Set uh set is
- 1:27:42expanded okay we are going to use state
- 1:27:47for this and the default one should be
- 1:27:49false so the by default it is not
- 1:27:52expanded okay and and I'm going to
- 1:27:54Define also toggle read more which is
- 1:27:59going to be
- 1:28:02function and we're going to call set is
- 1:28:05expanded to equal
- 1:28:07not uh
- 1:28:09read more not is
- 1:28:13expanded now we have this let's collapse
- 1:28:17this T which is for these arrows and
- 1:28:21here we have this paragraph and we want
- 1:28:23to check
- 1:28:24so if is expanded if this is expanded
- 1:28:30then we're going to display this feature
- 1:28:32description entire description otherwise
- 1:28:36we are going to do the following
- 1:28:38so I want to take feature
- 1:28:43description slice I want to take first
- 1:28:47200 characters so from 0 to 200 and then
- 1:28:51I want to display three dots okay okay
- 1:28:54and after this paragraph I want to have
- 1:28:57a button which will have a text read
- 1:29:01more or read less depending on if it is
- 1:29:03expanded or not so is
- 1:29:07expanded if it's expanded we're going to
- 1:29:09have read uh less otherwise we're going
- 1:29:13to have read more and let's give some
- 1:29:17styles to this button as well so let's
- 1:29:19give it uh text am 500
- 1:29:25and on Hover let's give it
- 1:29:28underline and we need to listen on click
- 1:29:30to that button and we're going to call
- 1:29:32toggle read
- 1:29:34more okay so we save this and have a
- 1:29:38look so let's click on read more read
- 1:29:42less this is awesome this is exactly um
- 1:29:46how I wanted this all right now we can
- 1:29:49move on and start working on creating
- 1:29:51new features or updating features but
- 1:29:53first let's comment everything what we
- 1:29:55changed so far I'm going to group
- 1:29:58everything and this is basically all
- 1:30:00related into displaying
- 1:30:04features create features page and
- 1:30:12display okay
- 1:30:14cool I guess that should be included as
- 1:30:16well isn't it let's amend the comment
- 1:30:20include this two files as well okay Co
- 1:30:24cool so everything is now included
- 1:30:26inside the comment message all right so
- 1:30:28we're going to open now feature
- 1:30:31controller and we have Index right here
- 1:30:33but we're going to actually start
- 1:30:34working on creating new features as well
- 1:30:36as updating features and so on and we
- 1:30:39are going to create new Implement
- 1:30:41actually these new methods for the
- 1:30:44resource crowd operations okay so let's
- 1:30:47start with create let me first focus on
- 1:30:49the server side inesha render feature
- 1:30:52create okay I think this is exactly what
- 1:30:55we want for store we're going to come
- 1:30:57back to this and implement or maybe we
- 1:31:00can try to implement this right now
- 1:31:02request validate we're going to expect
- 1:31:06uh two things here we're going to expect
- 1:31:08name and this name needs to be required
- 1:31:11and it must be string and we accept
- 1:31:13expect a description which is required
- 1:31:17or it's optional let me double check I
- 1:31:20think it's optional because it doesn't
- 1:31:21have this dot right here it is not
- 1:31:23require Reed it is optional so we're
- 1:31:25going to make it nullable and then
- 1:31:28string so finally we have the
- 1:31:31data inside the data we're going to push
- 1:31:34the currently authenticated user
- 1:31:36information like user ID is out ID and
- 1:31:39then on the feature we're going to call
- 1:31:42create we're going to pass the data this
- 1:31:44is going to return just created the
- 1:31:46feature which we actually don't need but
- 1:31:49we need to go back so we need to
- 1:31:52redirect into feature in index with a
- 1:31:55success message feature created
- 1:31:57successfully okay good now let's open
- 1:31:59feature model and we need to Define
- 1:32:01feable here inside the fieldable we need
- 1:32:05name we need description and we need
- 1:32:09user
- 1:32:11ID cool I think we have implemented
- 1:32:13store we will come back and test this
- 1:32:15when we have the front end side ready
- 1:32:17inside show we're going to just return
- 1:32:20intia render feature show and we're
- 1:32:22going to provide feature to be new
- 1:32:24feature resource passing this feature
- 1:32:27model awesome next we have to implement
- 1:32:30edit so in this case we just need to
- 1:32:32return inera render feature edit and we
- 1:32:36have to provide this feature resource
- 1:32:38okay so we are basically doing something
- 1:32:42very identical to
- 1:32:43show but in case of edit the view is
- 1:32:46going to be different we're going to
- 1:32:47display that information inside the form
- 1:32:50so for update we're going to uh call
- 1:32:53request
- 1:32:54again validate we have name required
- 1:32:58string we have description nullable and
- 1:33:00string uh we take that
- 1:33:03data and then on that feature we're
- 1:33:06going to call update passing the data
- 1:33:09and once this is completed we're going
- 1:33:11to return into root a feature index with
- 1:33:14a message feature updated successfully
- 1:33:17and in Destroy we just take that feature
- 1:33:19call delete and then we redirect user
- 1:33:23into feature index with a message
- 1:33:25feature deleted successfully so the back
- 1:33:27end is kind of ready let's open web
- 1:33:31PHP and right here we have only feature
- 1:33:35um list uh rout defined we're going to
- 1:33:39change this
- 1:33:40into excuse me we're going to change
- 1:33:42this into resource okay so we're going
- 1:33:45to have the resource um the root name
- 1:33:48here and the controller
- 1:33:56and I
- 1:33:58think we can remove the name okay now we
- 1:34:00defined the feature resource and we have
- 1:34:03all seven Roots defined and in fact if
- 1:34:06we execute PHP Artisan root column list
- 1:34:10it's going to give us the following
- 1:34:12output these are all the roots defined
- 1:34:14and if we have a look at the feature we
- 1:34:17see all seven crud uh resource rules
- 1:34:20defined here okay awesome
- 1:34:24now we need to create the react Pages
- 1:34:27under Pages feature we have index and we
- 1:34:30have to duplicate this few times first
- 1:34:34let's create show to just view a single
- 1:34:39feature um let's give it title feature
- 1:34:43and then inside BX I want to Output
- 1:34:47feature. name here instead of accepting
- 1:34:50features we're going to Simply accept
- 1:34:52one feature
- 1:34:55this is going to be just
- 1:34:58feature okay we don't need to iterate
- 1:35:01however we want to display the feature
- 1:35:03and the skeleton template of the feature
- 1:35:06should be very similar to this so I'm
- 1:35:08going to actually copy this part put
- 1:35:12that right here but I'm going to change
- 1:35:15this title from dashboard
- 1:35:18into uh feature actually let's change
- 1:35:21this into binding so
- 1:35:25feature uh plus feature. name and
- 1:35:29because we copied this from index I
- 1:35:32noticed that inside index we also have
- 1:35:34dashboard right here which should be
- 1:35:36features okay
- 1:35:39cool next we don't need this is expanded
- 1:35:42we're going to display the entire
- 1:35:43description so we can remove this part
- 1:35:46we don't need this read more read L and
- 1:35:49we have the feature that's give it name
- 1:35:52show save that now let's open feature
- 1:35:57item find this
- 1:35:59H2 and I'm going to put a link right
- 1:36:04here that should be
- 1:36:07link now that should be inertia link
- 1:36:10we're going to put the feature name and
- 1:36:12we have to provide hre uh with the root
- 1:36:15to be oops feature. show and we have to
- 1:36:20provide the
- 1:36:21feature okay awesome
- 1:36:24now if we just open this in the
- 1:36:32browser I just click on this this is
- 1:36:34going to open the feature view page and
- 1:36:37why don't we see the entire information
- 1:36:40let's open developer tools we probably
- 1:36:41have some error let's reload the
- 1:36:45page no we don't see any
- 1:36:49errors then what's the
- 1:36:52issue we have
- 1:36:54feature we display the feature
- 1:36:58description we display the
- 1:37:00feature
- 1:37:02name H2 and paragraph both are actually
- 1:37:07empty
- 1:37:10okay let's see
- 1:37:13feature show we accept the
- 1:37:16feature we return that feature inside
- 1:37:18feature
- 1:37:19show it should be good
- 1:37:24okay let's print what what is the
- 1:37:27feature we'll receive
- 1:37:34here okay yeah I see the reason so the
- 1:37:37feature resource right here has this
- 1:37:40wrap which needs to be disabled so I'm
- 1:37:42going to set this public static wrap
- 1:37:45equals
- 1:37:47false and
- 1:37:49now we are going to see the data
- 1:37:52displayed correctly okay so feature and
- 1:37:55this is the feature name okay awesome so
- 1:37:57this is the view uh page of the feature
- 1:38:00now let's add a button right here and
- 1:38:02Implement creating new feature for this
- 1:38:06let's open index
- 1:38:08TSX and right here we have this feature
- 1:38:11listing and I'm going to create another
- 1:38:14link here and this is going to have root
- 1:38:19actually it should have H ref and then
- 1:38:22it should have root into feature. create
- 1:38:27okay and let's give it also the same
- 1:38:29class names uh what we have for the
- 1:38:33primary button so we can open oops we
- 1:38:37can open primary button and I'm going to
- 1:38:40just copy these classes
- 1:38:43here and put them on that link and let's
- 1:38:47give it text create new feature this
- 1:38:51going to open feature create page let's
- 1:38:54see if the button is there okay the
- 1:38:55button is there let's give it let's put
- 1:38:58this probably in a div to make it kind
- 1:39:00of a on full width and then give it
- 1:39:04margin bottom
- 1:39:07eight okay awesome now when I click this
- 1:39:09it's not going to do anything because we
- 1:39:11don't have that feature create TSX file
- 1:39:15so let me copy show and call this
- 1:39:20create okay we need form let's open
- 1:39:24index and we have the form uh no we we
- 1:39:27don't have form defined uh
- 1:39:30anywhere actually so let's give it
- 1:39:34create new feature the same text right
- 1:39:40here on this head
- 1:39:42title cool um and we are going
- 1:39:47to
- 1:39:48delete this
- 1:39:52part okay and we have to create the form
- 1:39:55for this I'm going to open edit. tsix
- 1:39:58which is coming from this Pages profile
- 1:40:01and this is an example of the input
- 1:40:03Fields um inside the Lal Breeze default
- 1:40:06template so if we click on profile we
- 1:40:08see the input Fields so we're going to
- 1:40:10just copy a couple of input Fields like
- 1:40:12let's open this update profile
- 1:40:14information and scroll down below and we
- 1:40:17are going to see the following form and
- 1:40:19the following elements so what I want is
- 1:40:21just copy this div okay and open create
- 1:40:26let's create our
- 1:40:28form uh we don't need action we need on
- 1:40:32submit uh let's call this create feature
- 1:40:37we're going to create that um function
- 1:40:39create feature function let's paste it
- 1:40:43and now let's focus on the JavaScript
- 1:40:45side okay so we need to uh create the
- 1:40:49form I'm going to use in user form
- 1:40:54and we have to provide idid of the
- 1:40:56feature well when we create new feature
- 1:40:59we don't need to to have ID we can
- 1:41:02provide ID equals null or we can
- 1:41:04completely skip that so name is actually
- 1:41:07empty string and description is also
- 1:41:11empty string now here we accept data we
- 1:41:15destructure that form and take out the
- 1:41:17data we take out set data we take out
- 1:41:20processing flag um let's move this down
- 1:41:25like
- 1:41:26this okay we take out errors as well and
- 1:41:31we need
- 1:41:33post okay now let's Define con create
- 1:41:38feature
- 1:41:42function
- 1:41:43okay uh and we accept an event
- 1:41:47here okay so now this is uh something
- 1:41:50we're going to handle so this EF we're
- 1:41:53going to going to change basically this
- 1:41:54form into um form Handler or something
- 1:41:59like this similar to what we have in
- 1:42:01this update profile information let's
- 1:42:02scroll down below uh form even Handler
- 1:42:05that's correct so we're going to tell
- 1:42:08typescript that hey this Handler the
- 1:42:12create feature is actually an instance
- 1:42:14of for Ev Handler and then typescript
- 1:42:18knows that this EF is actually react
- 1:42:20form event for element
- 1:42:24on that e we're going to call prevent
- 1:42:27default and then we're going to submit
- 1:42:29the data through post uh the post what
- 1:42:32we take out from this form post we're
- 1:42:36going to
- 1:42:37use
- 1:42:39root um
- 1:42:42feature feature. store and we have to
- 1:42:46provide uh a preserve scroll to be
- 1:42:51true okay that's cool uh we can take
- 1:42:54this processing and we can give it to a
- 1:42:58submit button uh when we create the
- 1:43:01submit button somewhere right here okay
- 1:43:03uh but first let's adjust this so input
- 1:43:06label for name okay that's good it is
- 1:43:08for name um set data name okay so this
- 1:43:12is actually exactly how I want now I can
- 1:43:15duplicate this second time but in this
- 1:43:19case we need text area and if you open
- 1:43:21this text input this is coming coming
- 1:43:23from components folder and there's no
- 1:43:25text area okay so I'm going to duplicate
- 1:43:28this text input and let let's call this
- 1:43:31text area input I cannot call this text
- 1:43:35area because text area is actually the
- 1:43:38native HTML element now let's open this
- 1:43:41text area input and we're going to
- 1:43:42change a few things first scroll down
- 1:43:46below and instead of input we need text
- 1:43:49area we don't need type at all uh text
- 1:43:52area is not self closing so we need
- 1:43:55closing tag as well I think we don't
- 1:43:58need this local ref because this is only
- 1:44:00for fuckus sing if we have um ease
- 1:44:03focused then we're going to autofocus on
- 1:44:05the text area which is something we
- 1:44:06don't need so I'm going to remove this
- 1:44:08ease focused remove this remove this ref
- 1:44:13as
- 1:44:14well uh what else
- 1:44:23uh we can remove this uh oh I think we
- 1:44:26need this local ref but instead of HTML
- 1:44:30input element I guess that should be
- 1:44:32html text area
- 1:44:35element and right here as well so now we
- 1:44:39can have this local ref if we need that
- 1:44:44and what else so we don't need type we
- 1:44:46can remove that we have the class name
- 1:44:48props uh and
- 1:44:55I think we don't need this as
- 1:44:58well let's remove extra Imports use
- 1:45:01effect something we don't need okay
- 1:45:02anyway I think that's enough let's open
- 1:45:05this
- 1:45:06create um
- 1:45:10TSX text area
- 1:45:12input uh and we have to provide the
- 1:45:15value which is going to be
- 1:45:18data description and we use description
- 1:45:21um inside on change
- 1:45:23and inside this errors as well we don't
- 1:45:25need this is focused we don't need
- 1:45:27autocomplete however it should be
- 1:45:29required and the ID should be
- 1:45:32description and we're going to change
- 1:45:34this HTML 4 into description as well and
- 1:45:38the value for label is going to be
- 1:45:43description okay so this is the create
- 1:45:45page now let's open uh features page and
- 1:45:48we're going to click on this create new
- 1:45:50feature and it opens that page now now
- 1:45:54on that form let's give it w full to
- 1:45:58stretch it on full width okay so on this
- 1:46:01div we're going to add margin bottom uh
- 1:46:06eight this is the first div we have in
- 1:46:09distance on the second D again margin
- 1:46:14bottom eight
- 1:46:18oops and finally we need the button uh
- 1:46:21let me grab that button from the profile
- 1:46:23file page
- 1:46:24again scroll down below we have this div
- 1:46:27another
- 1:46:29div something else and finally we have
- 1:46:32this primary button I'm going to get
- 1:46:36this on the create page
- 1:46:39oops right here we need this primary
- 1:46:43button okay it has disabled when
- 1:46:47processing cool now let's have a look
- 1:46:50okay this is awesome so now when we
- 1:46:52click on save it should make the request
- 1:46:54and create new feature let's try this
- 1:46:57new feature one click on save this
- 1:47:01actually required however we have it
- 1:47:04optional so let's just remove this
- 1:47:07required on the text area input click on
- 1:47:10Save okay something happened it was
- 1:47:13failed now we need to understand why it
- 1:47:15was
- 1:47:17failed okay where is that coming from
- 1:47:25can't read properties of null reading
- 1:47:27slice okay something was going to wrong
- 1:47:29let's open features and now we have 101
- 1:47:33features and let's check the latest one
- 1:47:35which we just
- 1:47:40created it has description to be
- 1:47:44null okay so
- 1:47:48what if the description is null okay
- 1:47:50that's causing the problem let's open
- 1:47:54Feature Feature
- 1:47:57item and here we check if is expanded
- 1:48:01okay we by default we take this slice
- 1:48:04instead of that uh accessing this
- 1:48:07feature description immediately when it
- 1:48:10is n this is causing problems we can use
- 1:48:13the following if the feature description
- 1:48:14exists if not let's take empty string
- 1:48:17and then Slice on the empty string will
- 1:48:20work okay now we don't have any
- 1:48:24we don't have any errors except that key
- 1:48:27which we should probably add when
- 1:48:30iterating over feature items so for this
- 1:48:33we need to
- 1:48:34open index and right here we're going to
- 1:48:38add
- 1:48:38key uh feature.
- 1:48:42ID awesome uh however we don't need this
- 1:48:45read more read less because yeah the
- 1:48:47description is actually um very small
- 1:48:51okay what we can do is the following so
- 1:48:54we can take the feature description and
- 1:48:56write the following if statement so if
- 1:48:58the feature description or we can also
- 1:49:01do the following if the feature
- 1:49:02description
- 1:49:04or empty
- 1:49:06string if the length of that is more
- 1:49:11than 200 okay then we do the
- 1:49:17following so we display the following p
- 1:49:23otherwise we don't do
- 1:49:25anything uh and we also display this
- 1:49:27pattern in that case so in this case we
- 1:49:30need to use
- 1:49:32fragment just like
- 1:49:35this awesome now we don't display
- 1:49:38anything we just have the title of the
- 1:49:40feature nothing else but this one has
- 1:49:41read more and read less and just like
- 1:49:44this we are able to implement creating
- 1:49:47new features let's create another one
- 1:49:50another cool feature
- 1:49:54uh with some test description anyway so
- 1:49:59let's just click on Save uh another cool
- 1:50:02okay what's
- 1:50:07that okay yeah that makes sense so the
- 1:50:11length is
- 1:50:13actually
- 1:50:15not more than 200 that's why we don't
- 1:50:18see
- 1:50:20this uh and we can write another
- 1:50:24if
- 1:50:27here so if the description is less than
- 1:50:31or equal to 100 then we simply
- 1:50:35display um inside
- 1:50:37paragraph We display feature.
- 1:50:40description directly without anything
- 1:50:43else so in this case we don't have read
- 1:50:44more read less but we have the entire
- 1:50:47feature and again if we create new one
- 1:50:49with some um lurm ipsum
- 1:50:58text test
- 1:51:00feature click on Save now we see this
- 1:51:03one and it has this read more read less
- 1:51:05which I
- 1:51:06want uh this we can remove okay this is
- 1:51:11cool awesome so now we have this um
- 1:51:15creating of new features
- 1:51:17implemented uh and we have the feature
- 1:51:20Details page
- 1:51:23okay let me clean up the console logs
- 1:51:25what we see right here which is coming
- 1:51:26from the authenticated
- 1:51:30layout authenticated layout we have this
- 1:51:34conso log user we need to remove this
- 1:51:37and what else do we have from show T6 we
- 1:51:41have this feature as well which I am
- 1:51:43going to
- 1:51:45remove cool now we need to comment
- 1:51:48everything what we implemented so far
- 1:51:50this is related to
- 1:51:54Implement creating new feature and
- 1:51:58feature show
- 1:52:02page cool we can push
- 1:52:06everything I think I don't have the
- 1:52:08remote repository defined yet I'm going
- 1:52:10to push it later
- 1:52:12everything and the next is to implement
- 1:52:15feature edit and delete let me close
- 1:52:18everything and I'm going to put a drop-
- 1:52:21down right here in the probably in the
- 1:52:24feature listing as well and I'm going to
- 1:52:27use uh similar drop down like we have in
- 1:52:29this authenticated layout so let's
- 1:52:33open authenticated layout and we're
- 1:52:36going to search for the dropdown here it
- 1:52:39is let me copy the dropdown and next
- 1:52:43let's open feature
- 1:52:47item okay so this is up vote down vote
- 1:52:52this is the content and I'm going to
- 1:52:54create another div right here and I am
- 1:52:57going to paste the drop down but
- 1:52:59actually I'm going to use the same
- 1:53:00dropdown on the feature Details page so
- 1:53:04better to create new component for that
- 1:53:08dropdown so let's call
- 1:53:10this let's call this um feature actions
- 1:53:16dropdown let's hit the
- 1:53:18enter export default function
- 1:53:23feature actions
- 1:53:25dropdown okay we are going to return the
- 1:53:28following HTML or
- 1:53:32j6 uh
- 1:53:34let's fix the
- 1:53:36indentation and instead of username I'm
- 1:53:39going to use the H so-called Ellipsis
- 1:53:44icon so let's search for Ellipsis
- 1:53:47vertical icon this is what I'm going to
- 1:53:49use instead of this SVG
- 1:53:54let me paste this and we're going to
- 1:53:56change this into camel case
- 1:54:01version cool
- 1:54:04and then scroll down below instead of
- 1:54:08profile edit we need uh Feature Feature
- 1:54:12edit but we have to provide the feature
- 1:54:14as well so we have to accept feature
- 1:54:17right here feature and then the def
- 1:54:21let's define the prop a feature is an
- 1:54:23instance of feature so inside edit we're
- 1:54:26going to provide feature. ID and this is
- 1:54:29going to be to delete the feature let's
- 1:54:31change the text edit
- 1:54:34feature and this is going to be
- 1:54:37delete
- 1:54:39feature okay feature. destroy and we
- 1:54:44have to provide feature. ID again now
- 1:54:48let's open feature item and let's use
- 1:54:51feature actions drop down providing the
- 1:54:55feature that's cool now let's have a
- 1:54:58look in the feature listing here we see
- 1:55:01this three dot click on this this going
- 1:55:02to open the drop down edit feature and
- 1:55:05delete feature if we click on this edit
- 1:55:08feature it doesn't do anything because
- 1:55:10we don't have the corresponding um blade
- 1:55:13file if we click on this delete feature
- 1:55:16which by the
- 1:55:17way should make the request with method
- 1:55:21delete
- 1:55:23Okay then if I click on this delete
- 1:55:26feature
- 1:55:28it well what it did it
- 1:55:31do it should have deleted it actually
- 1:55:34deleted that feature so click on delete
- 1:55:37again yeah now this is gone look at this
- 1:55:40so the delete actually works and the
- 1:55:41features are successfully deleted why do
- 1:55:44we have this this is coming from index
- 1:55:48okay let's open index as well and remove
- 1:55:52these
- 1:55:54features now we need to
- 1:55:57create another page under JS Pages
- 1:56:02feature similar to create but this is
- 1:56:04going to be
- 1:56:06edit okay so here inside the
- 1:56:10edit hold on let's open create I noticed
- 1:56:13something so inside create we accept
- 1:56:16this feature probably because we copied
- 1:56:18that create from show which we don't
- 1:56:20need so I'm going to remove
- 1:56:23this cool now let's open edit inside
- 1:56:26edit we definitely need this feature and
- 1:56:28we're going to take and provide um I
- 1:56:32think we don't need ID we don't need ID
- 1:56:35here we just need
- 1:56:36name feature. name and feature dot
- 1:56:44feature.
- 1:56:46description however instead of create
- 1:56:48feature we can rename this and call
- 1:56:51update feature we have to rename it here
- 1:56:55as well but when we make the update
- 1:56:58first from this form we should take put
- 1:57:01not post so here we're going to use put
- 1:57:04and then we should change the root from
- 1:57:06featur tour into feature update and this
- 1:57:09is the place where we provide feature ID
- 1:57:12this is the way how we tell L which
- 1:57:14feature we want to update not putting
- 1:57:16the ID right here so in the following
- 1:57:19way we perform the update uh let's just
- 1:57:22change
- 1:57:23this uh edit feature and let's use
- 1:57:28inside bags feature.
- 1:57:31name okay cool and inside the title we
- 1:57:35need edit let's change this into binding
- 1:57:39edit
- 1:57:41feature plus
- 1:57:43feature.
- 1:57:46name okay now let's have a look so click
- 1:57:51on edit feature it is going to open the
- 1:57:53edit feature page edit feature and this
- 1:57:56is going to be it however I think um
- 1:57:59this B tag doesn't work because I think
- 1:58:02everything is in bold to be
- 1:58:05honest edit
- 1:58:07feature and this is the
- 1:58:10btag yeah everything is actually inside
- 1:58:12the Bold B is the boulder however that
- 1:58:17H2 also
- 1:58:19has font weight 600
- 1:58:24yeah okay anyway it's not big deal I
- 1:58:26just uh I'm used to putting the actual
- 1:58:29name inside um something to easily
- 1:58:32identify that we can also use double
- 1:58:35quotes we know what is the actual
- 1:58:37feature name in this case uh and this is
- 1:58:40the actual feature description by the
- 1:58:42way we can change the number of rules in
- 1:58:45the text area during the edit so we can
- 1:58:48provide um rules we don't have that by
- 1:58:52the way so inside this text area we can
- 1:58:55add
- 1:58:56rules um
- 1:58:59equals by default let's give it two
- 1:59:02rowes but we can overwrite this so let's
- 1:59:05format this by the way because by
- 1:59:07default that was on four spaces but we
- 1:59:09have two spaces configured in the editor
- 1:59:11config so that's good uh however that
- 1:59:15row needs to be
- 1:59:18defined also in the props
- 1:59:23so input HTML
- 1:59:25attributes for the text area element we
- 1:59:29have this is focus which we don't need
- 1:59:31but we need
- 1:59:33rules so rules is
- 1:59:37number basically this defines the type
- 1:59:41inside the typ script so this defines
- 1:59:42the type uh we're going to change this
- 1:59:44into text area input so this defines the
- 1:59:49type what type of props
- 1:59:52uh that component expects and using the
- 1:59:55end symbol we are going to merge two
- 1:59:58types into um single type so now
- 2:00:03whatever is available whatever is
- 2:00:05defined in the following type plus rows
- 2:00:09which should be numbered and that's and
- 2:00:11that's that's the way how we uh Define
- 2:00:14the rows probe here and we can provide
- 2:00:17rowes equals rows and if we go into edit
- 2:00:22now we can provide rows equals six for
- 2:00:25example so if we refresh the page we're
- 2:00:28going to
- 2:00:29see six rows by default and we probably
- 2:00:32need uh something in the description as
- 2:00:35well we have only one and we should
- 2:00:37probably change this default one into
- 2:00:40something like six because we use that
- 2:00:42text area only when creating new feature
- 2:00:45or editing the feature okay now let's
- 2:00:48click on this edit feature and let's put
- 2:00:50some text like updated and let's click
- 2:00:54on
- 2:00:54save it looks like that was updated and
- 2:00:57we will redirect it back however I think
- 2:01:00we don't display the message so if we
- 2:01:03try to create new feature I want the
- 2:01:05message to be displayed as
- 2:01:09well test
- 2:01:11feature some description save yeah the
- 2:01:15message is not displayed however in the
- 2:01:18feature controller when we create those
- 2:01:21features like inside the store we
- 2:01:24redirect user back with the session um
- 2:01:27variable so what we need to do is open
- 2:01:30handle inera request and right here we
- 2:01:34are going to take success message from
- 2:01:39session and we're going to provide to
- 2:01:41every page okay then we are going to
- 2:01:46open authenticated
- 2:01:49layout and let's take that just like we
- 2:01:52are taking the user we are going to take
- 2:01:55message or let's call this success which
- 2:01:59is going to be string and we're going to
- 2:02:02take this through use use page. props do
- 2:02:08success this is the way how we provided
- 2:02:10that success message okay so uh what's
- 2:02:14the
- 2:02:19issue okay unknown is not assignable uh
- 2:02:23to type string so this success is
- 2:02:26actually
- 2:02:28unknown okay what is this props this is
- 2:02:31Page
- 2:02:35props well in this specific case for
- 2:02:39Simplicity I'm going to change this
- 2:02:40success into any okay then we take this
- 2:02:45success and we need to
- 2:02:48display um message somewhere and let me
- 2:02:52put this right here actually I'm going
- 2:02:55to use
- 2:02:56alert template or we can create
- 2:02:59something custom like uh BG
- 2:03:05Emerald Emerald um like
- 2:03:09400 uh we give it pading of uh six let's
- 2:03:15give it
- 2:03:16rounded and then output success message
- 2:03:20here and if success exists then we
- 2:03:24output the entire
- 2:03:26message okay now let's create
- 2:03:31new test okay feature created
- 2:03:34successfully let's change some pings
- 2:03:37instead
- 2:03:39of uh let's give it pting X6 but pting
- 2:03:46y4 that's I think better and let's give
- 2:03:48it also margin bottom of eight
- 2:03:56yeah I think we can change this
- 2:03:59into
- 2:04:01300 and we give it text
- 2:04:06Emerald 700 something like this or even
- 2:04:10800 anyway so this is something uh I
- 2:04:12don't want to spend some time on this
- 2:04:14feature created successfully okay maybe
- 2:04:16we should completely remove that text
- 2:04:18color and we just return this into like
- 2:04:21five
- 2:04:22500 okay that's not bad now if we try to
- 2:04:26edit new feature click on update or say
- 2:04:29or update the feature updated
- 2:04:30successfully we see the following
- 2:04:33message and just like this we have
- 2:04:35implemented creating new features
- 2:04:38updating features as well as deleting
- 2:04:41the features you can go ahead and uh
- 2:04:44like take the challenge and try to add
- 2:04:46the confirmation message into the delete
- 2:04:48feature which I'm not going to do but I
- 2:04:51think it's going to be good challenge
- 2:04:52for you now let's comment the changes
- 2:04:54what we made so far update Implement
- 2:04:56updating and deleting features click on
- 2:04:59comment and now I'm going to focus on up
- 2:05:03vote and down vote functionality so
- 2:05:06first I want to generate new
- 2:05:09controller PHP artisan make controller
- 2:05:14and let's call this up vote
- 2:05:19controller okay the controller was
- 2:05:21created
- 2:05:22let's open up vote controller here it
- 2:05:25goes okay so before I start implementing
- 2:05:29this controller let's talk a little bit
- 2:05:31how we're going to do or what we are
- 2:05:33going to do so the state right here
- 2:05:37basically when everything is white means
- 2:05:39that the current user me I have not
- 2:05:42added my up Vote or down vote to the
- 2:05:45following feature as soon as I add my up
- 2:05:49Vote or down vote then the arrow the
- 2:05:52corresponding Arrow should turn into a
- 2:05:55different color like the following color
- 2:05:58uh I think it's called Amber okay so
- 2:06:01that will indicate that I have
- 2:06:03personally up voted that specific
- 2:06:07feature okay and whenever I also refresh
- 2:06:09the page I want to display uh the
- 2:06:13corresponding color on the Up vot Down
- 2:06:16vs okay so this is something we are
- 2:06:19going to do okay let's focus on uh
- 2:06:22actually displaying that information
- 2:06:24first and then we're going to
- 2:06:26implement um actually up voting and down
- 2:06:29voting so for this let's open up votes
- 2:06:33table and we're going to add a couple of
- 2:06:36Records right
- 2:06:38here let's add three records so feature
- 2:06:42uh the latest feature which
- 2:06:44is whatever which has ID one actually I
- 2:06:48think the latest features or which
- 2:06:51features should be at the top that's a
- 2:06:52good question uh okay let's leave it
- 2:06:54everything as it is right now we can
- 2:06:55come back to this so feature
- 2:06:58one uh user one user two user three one
- 2:07:01user can have only one up Vote or down
- 2:07:04vote and now let's add all ones so all
- 2:07:07users gave uh up folds to the specific
- 2:07:11feature now if I save this everything we
- 2:07:13need to display this information right
- 2:07:15here the count should be three instead
- 2:07:18of 12 here let's start with this feature
- 2:07:23controller scroll up find this index and
- 2:07:27we are going to do a few things so we
- 2:07:32want we want to um take the count which
- 2:07:36going to be UPF count so for this I'm
- 2:07:39going to use with count and we have to
- 2:07:43provide the relations so the relation in
- 2:07:47this case is going to be up folds
- 2:07:49relation up Folds and we're going to
- 2:07:52select this as upvote count then we
- 2:07:56provide the function here we accept that
- 2:07:58quy uh and on that quy we are going to
- 2:08:02execute select we just want to select
- 2:08:05one information and in this case let me
- 2:08:07use just TB rule uh I'm using eliminate
- 2:08:11support facets TB rule select and we are
- 2:08:14going to execute sum so I want to take
- 2:08:19the sum of the upvs if the UPF is one or
- 2:08:26um let me just write this I think it's
- 2:08:29going to be better to just write this
- 2:08:31and then explain okay so case I'm going
- 2:08:34to use case
- 2:08:37when um
- 2:08:40upb actually I think it was uh
- 2:08:42completing something actually nice okay
- 2:08:46anyway um up vote equals 1 then one else
- 2:08:53we're going to take minus one so I'm
- 2:08:57basically creating a semicolon T I'm
- 2:09:00creating a sum of ones and minus ones so
- 2:09:05if the up is one then I simply take it
- 2:09:08as one otherwise if the UPF is not one
- 2:09:11which means it's zero I'm taking minus
- 2:09:14one and I'm creating this sum and I'm
- 2:09:17taking this sum and selecting this
- 2:09:20inside the up folds relation and just
- 2:09:22give it an alas upfold count now if we
- 2:09:25open this feature resource and we can
- 2:09:28dump uh the object here this object and
- 2:09:32when we just refresh the page we're
- 2:09:34going to see a single
- 2:09:36resource uh single model which has
- 2:09:39upvote count three this is exactly what
- 2:09:42I want from here we can return upvote
- 2:09:46count equals this up vote
- 2:09:53account save that refresh the page
- 2:09:56nothing will happen probably because we
- 2:09:58have to open feature item
- 2:10:01and right here instead of 12 we are
- 2:10:05going to Output feature. dot uh upfold
- 2:10:09count but we will have typescript error
- 2:10:12because the feature model this model
- 2:10:15does not have upfold count so we add
- 2:10:18upfold count to be number
- 2:10:21now we save that and look at this uh
- 2:10:25actually we should take also zero if it
- 2:10:28is uh null because we don't want uh
- 2:10:31empty strings right here so we can do
- 2:10:33this in two ways first we can do this
- 2:10:36right here if that doesn't exist we can
- 2:10:38take just zero or we can also return
- 2:10:41zero from
- 2:10:44here I think it's going to be better to
- 2:10:46return this from the back end so we can
- 2:10:49just take this out reload the page and
- 2:10:53we see three Z zero and everywhere there
- 2:10:57will be zero now let's open up votes and
- 2:11:00I'm going to change let's say that user
- 2:11:02three actually downvoted that specific
- 2:11:06feature so instead of one we're going to
- 2:11:08put right there zero so it is not up
- 2:11:11vote meaning it is down vote so now if I
- 2:11:14refresh the
- 2:11:16page we see instead of three we see just
- 2:11:20one okay that one means that this up
- 2:11:24voted and this upvoted but this down
- 2:11:27voted so two upvotes one down vote
- 2:11:30totally the score is actually one so if
- 2:11:34I simply don't want to down vote don't
- 2:11:37want to up vote I delete the record and
- 2:11:40then we're going to see two right
- 2:11:43here okay that's pretty cool now we need
- 2:11:46to also identify if the current user has
- 2:11:49up voted or downvoted voted so for this
- 2:11:53I'm going to again open this feature
- 2:11:55controller and I'm going to add um the
- 2:11:58following relation with
- 2:12:01exists so with exists we Define the
- 2:12:04relation here and I need two relations
- 2:12:08right here okay so the first one
- 2:12:12actually I'm going to access um upvs in
- 2:12:15any case but I'm going to select two
- 2:12:18different columns first is going to be
- 2:12:20user
- 2:12:21has
- 2:12:23upvoted okay this is going to be the
- 2:12:26function and second is going to be user
- 2:12:30has
- 2:12:32downvoted so two flags will be added
- 2:12:35into the total uh the the query of each
- 2:12:38feature so inside this we on that query
- 2:12:43I'm going to execute the following we so
- 2:12:46we user ID equals to the currently
- 2:12:50authentic user ID which I can select
- 2:12:54from here current user ID this is going
- 2:12:59to be
- 2:13:02out
- 2:13:04ID cool now I have this current user ID
- 2:13:07which I can use here and then I'm
- 2:13:12providing current user ID here and I'm
- 2:13:15going to add additional we upvote equals
- 2:13:191 now let me me copy this put this down
- 2:13:23below uh the current user ID is the user
- 2:13:26ID but the upfold is zero so basically
- 2:13:30now this will select if the current user
- 2:13:33has upvoted if that exists we because we
- 2:13:36are using here with exists so if that
- 2:13:39cury exists this is going to return uh
- 2:13:42true user has upvoted and this is going
- 2:13:45to return
- 2:13:47false now we save this again let's open
- 2:13:49feature resource Let's uh print this DD
- 2:13:53we need zero here save refresh the page
- 2:13:59and now let's have a look out manager
- 2:14:06ID let's use
- 2:14:08out user ID or simply out ID should work
- 2:14:13as
- 2:14:17well
- 2:14:19cool look at this user has up voted
- 2:14:22equals zero user has downvoted equals
- 2:14:25zero this means that the particular user
- 2:14:28which is admin user has neither upvoted
- 2:14:31neither downvoted but if we add the
- 2:14:34record user three upvoted one now
- 2:14:39refresh the page we're going to see user
- 2:14:41has upvoted one user has downvoted zero
- 2:14:45now if we change this into zero refresh
- 2:14:48the page user has uped is zero Z and
- 2:14:51user has downloaded is actually one
- 2:14:55that's pretty cool let's open this
- 2:14:57feature resource remove this and we have
- 2:15:01to return these two columns user has
- 2:15:10upvoted this user has up
- 2:15:16voted and duplicate this user has
- 2:15:20downvoted
- 2:15:22here we need user has downvoted as well
- 2:15:26now if we open this feature item we have
- 2:15:29to mark if the current user has up voted
- 2:15:31this or not and for this I'm going to
- 2:15:34add extra CSS classes so inside the
- 2:15:37class
- 2:15:38name uh I'm going to do the following so
- 2:15:41if feature uh actually we have to again
- 2:15:44open feature and add those two flags
- 2:15:47user has uploaded
- 2:15:51and user has
- 2:15:54downvoted and both actually should be
- 2:15:59Boolean and from this feature Resource
- 2:16:01as well we can cast them into
- 2:16:06Boolean cool in the feature item now we
- 2:16:09can access user has upvoted if the user
- 2:16:13has upvoted we can add text
- 2:16:17Ember 500 otherwise we don't add
- 2:16:20anything
- 2:16:22and right here this is the second button
- 2:16:24if feature user the current user has
- 2:16:28down voted we add text Ember 500
- 2:16:34otherwise we don't add anything we save
- 2:16:37that refresh the
- 2:16:39page and have a look so right here it
- 2:16:43seems like user has
- 2:16:46downvoted now let's open up votes that's
- 2:16:49correct we can change this into one
- 2:16:52refresh the page and now we see user has
- 2:16:56upfold it I'm going to do two tiny
- 2:16:59changes first is that I'm going to
- 2:17:01increase this 500 into 600 here and here
- 2:17:05and then I'm going to make these three
- 2:17:08also in Amber style if the user has up
- 2:17:12voted or
- 2:17:13downvoted
- 2:17:15so let's change this into the following
- 2:17:18way if
- 2:17:21feature has user has up voted or if
- 2:17:26feature user has down
- 2:17:29voted then I am going to add text
- 2:17:34Ember let's move this down
- 2:17:37text uh where is that 600 otherwise an
- 2:17:40empty string okay awesome this is this
- 2:17:44is cool
- 2:17:45now I
- 2:17:47think yeah from the UI perspective i' I
- 2:17:50think everything is done now we can
- 2:17:52focus on actually implementing the
- 2:17:54functionality to up vote and down vote
- 2:17:58so for this let's open up V controller
- 2:18:02and create the function store we're
- 2:18:04going to accept request here and then
- 2:18:08from that request we are going to take
- 2:18:10two
- 2:18:12things um so let's execute valid dat
- 2:18:16we're going to take feature ID
- 2:18:20okay and this is going to be required
- 2:18:23and it must exist inside the features
- 2:18:26table inside the ID column and we're
- 2:18:28going to also
- 2:18:29take
- 2:18:31upvote which is going to be required and
- 2:18:34it needs to be bullan so now we take
- 2:18:37that
- 2:18:39data and then I'm going to execute on
- 2:18:43upfold um update or create because if
- 2:18:49the user has up voted and then if the
- 2:18:52user clicked on the down vad that is
- 2:18:55going to actually update the record and
- 2:18:58change the upload flag from one into
- 2:19:01zero and this is what we are going to do
- 2:19:04here so we need actually attributes and
- 2:19:07values so inside the attributes uh we
- 2:19:11have to provide the feature ID as well
- 2:19:13as the user
- 2:19:16ID cool so we have to update the record
- 2:19:19for the following feature feature and
- 2:19:21for the following um
- 2:19:25user
- 2:19:28next uh we have to perform the update by
- 2:19:32providing the data right
- 2:19:34here okay so this will do update or
- 2:19:37create and once this is done we have to
- 2:19:40return to
- 2:19:43root feature.
- 2:19:48index okay we perform the the redirect
- 2:19:51into feature Index this is cool now
- 2:19:53let's open web.php and we have to work
- 2:19:58right
- 2:20:00here so let's define
- 2:20:03root host
- 2:20:06on
- 2:20:08on okay let me think well we can just
- 2:20:11write here up vote and nothing else or
- 2:20:14we can do the following feature we can
- 2:20:17provide the actual feature which needs
- 2:20:19to be a full
- 2:20:21and then we can provide um up vote so
- 2:20:26I'm going to do the following way so
- 2:20:28then we're going to use upvote
- 2:20:30controller
- 2:20:32class uh and this is going to be store
- 2:20:36I'm going to just rename this into store
- 2:20:38it is actually called store so we have
- 2:20:40to use store here and here I'm going to
- 2:20:43call this
- 2:20:45feature uh not feature
- 2:20:48H how should we call this
- 2:20:52upfold store probably let's call this
- 2:20:55upfold
- 2:20:57store now let's open feature
- 2:21:02item and we're going to open also show
- 2:21:05because we
- 2:21:07have that up vote down vades on both and
- 2:21:12in our case if we open the details page
- 2:21:14we don't display anything right here
- 2:21:16because we have done this on the in the
- 2:21:18listing feature item component so I
- 2:21:21should probably create a component out
- 2:21:24of this so
- 2:21:28this is something I'm going to extract
- 2:21:31into resources JS components and let's
- 2:21:34create new
- 2:21:36component
- 2:21:38feature
- 2:21:41upfold um feature app vote okay let's
- 2:21:46call this feature app
- 2:21:47vote down vote
- 2:21:51okay longer but more descriptive export
- 2:21:54default
- 2:21:56function uh feature up vote
- 2:22:00down
- 2:22:01[Music]
- 2:22:03vote and then we return the following
- 2:22:08js6 and obviously we're going to accept
- 2:22:12right here
- 2:22:17feature we need to import that type
- 2:22:20let's accept feature here now we have
- 2:22:25the entire
- 2:22:26feature and we have to use
- 2:22:30that here feature uplo down vote
- 2:22:34providing the feature and we can use
- 2:22:37that component in show as
- 2:22:43well okay now if you open the show page
- 2:22:45we're going to
- 2:22:47see okay we don't see some thing because
- 2:22:51we don't actually select everything what
- 2:22:54we have this with count and with exist
- 2:22:58we don't select this on the um show page
- 2:23:02right here we're going to come back to
- 2:23:04this and select that as well but let's
- 2:23:08actually try to implement or maybe we
- 2:23:10can do this right now uh scroll down
- 2:23:12below um where's this
- 2:23:16show this is index we're going to
- 2:23:18collapse this create
- 2:23:21store show here it is and on
- 2:23:25that uh feature we have to yeah we we
- 2:23:30can execute a separate cures because
- 2:23:33this is for listing that's clear but for
- 2:23:36cures is we're going to do it
- 2:23:37differently
- 2:23:39so let me actually take this DB Ru or
- 2:23:44maybe we can tell take this entire
- 2:23:47select and
- 2:23:50here so on the
- 2:23:52feature app vot
- 2:23:56count
- 2:23:57equals um from from upfold model we're
- 2:24:03going to
- 2:24:05select okay where's that we're going to
- 2:24:08select
- 2:24:12tbu let's have a
- 2:24:15look we're going to select um some and
- 2:24:20then we're going to add extra where
- 2:24:23we're going to select only those records
- 2:24:26where feature ID is the given feature
- 2:24:31and finally we just need a single um I
- 2:24:36think count exists single
- 2:24:40value uh let's actually DD
- 2:24:45feature on the show page reload it
- 2:24:50up
- 2:24:52count the reason for this is that we
- 2:24:55have feature instead of feature ID so if
- 2:24:58we save this right now refresh the
- 2:25:01page uh then we're going to see the
- 2:25:03upload count to be
- 2:25:06three okay however um I'm going to just
- 2:25:10turn this into more elegant solution so
- 2:25:13I'm going to take this DB rule here we
- 2:25:16need we and finally I'm going to call
- 2:25:21uh
- 2:25:22sum and inside this we are going to just
- 2:25:25select
- 2:25:27Case Case when I put one then one lse
- 2:25:30minus one we don't need this parenthesis
- 2:25:33and this is going to do the exact same
- 2:25:35thing so where feature ID is the given
- 2:25:37feature ID we're going to sum of these
- 2:25:40things so I save this uh we can actually
- 2:25:45remove this
- 2:25:46completely and have a look in the
- 2:25:49browser and and we should see three
- 2:25:52right here which is the correct now we
- 2:25:54are going to do something similar for
- 2:25:57this user has up voted user has down
- 2:26:00voted so we just need the names nothing
- 2:26:03else um scroll down
- 2:26:08below feature user has upvoted and now
- 2:26:12from upvote we're going to execute
- 2:26:16where feature ID is the feature
- 2:26:23ID uh user ID is the out ID and we need
- 2:26:28another we a vote equals one and we're
- 2:26:32going to call
- 2:26:35exists user has up voted if that exists
- 2:26:38duplicate this user
- 2:26:41has
- 2:26:43downvoted if up vote equals zero now we
- 2:26:48save this refresh the page
- 2:26:52and we see the correct uh coloring on
- 2:26:54this so this indicates that the admin
- 2:26:57user has just um has upvoted that
- 2:27:02specific um feature now we're going to
- 2:27:05focus on actually upload and download
- 2:27:08functionality so for this right here
- 2:27:11we're going to define the
- 2:27:13form
- 2:27:15use form and we are going to Define
- 2:27:19actually two forms one is going to be up
- 2:27:22vote form and second is going to be down
- 2:27:27vote
- 2:27:29form so let's call this up vote form and
- 2:27:35we need up vote to be true for up vote
- 2:27:39for now let's duplicate this and this is
- 2:27:44going to
- 2:27:45be downvote form and up vote is going to
- 2:27:50be false in this case so now I'm going
- 2:27:53to Define
- 2:27:56upvote um
- 2:27:59downvote
- 2:28:02function and here inside this up down
- 2:28:05function we're going to accept flag up
- 2:28:08vote which is going to be Boolean okay
- 2:28:11and we're going to do a couple of checks
- 2:28:13like if the
- 2:28:17feature has user has up voted okay if
- 2:28:22the feature is already uploaded by the
- 2:28:25current user and user clicked on
- 2:28:30upfold
- 2:28:31or if the current
- 2:28:34feature um is downvoted by the user and
- 2:28:40user clicked on down vote not up vote it
- 2:28:44means that we are going to delete our up
- 2:28:47Vote or down vote whatever it is okay so
- 2:28:51in our example the up arrow is Ember if
- 2:28:55I click on up Arrow my vote simply
- 2:28:59should be deleted should be removed and
- 2:29:01there this will become two okay so this
- 2:29:05is the case what we're going to do and
- 2:29:08so in this case on the up form or on
- 2:29:12download form actually doesn't matter
- 2:29:14we're going to call delete and we're
- 2:29:16going to provide root feature
- 2:29:21feature destroy not the feature destroy
- 2:29:23sorry up. destroy which doesn't exist in
- 2:29:27the roots so let's open web.php
- 2:29:31and we are going to duplicate
- 2:29:34this up
- 2:29:36vote
- 2:29:38upot and the method will be delete upot
- 2:29:45destroy and the method is going to be
- 2:29:48dis d destroy as
- 2:29:52well now let's create that public
- 2:29:56function destroy we're going to accept
- 2:29:58upvote
- 2:30:00here then on the upvote we are going to
- 2:30:03call delete and return to Road feature
- 2:30:09index uh actually it should be either
- 2:30:13feature
- 2:30:14index or it should
- 2:30:16be the specific feature page depending
- 2:30:21on from where it is coming um can we
- 2:30:25actually go back so if we call back is
- 2:30:29it going to work let's try this now we
- 2:30:31have this upload destroy which we can
- 2:30:34use here and we have to provide um the
- 2:30:41actual now let me think for the up
- 2:30:44destroy I think we need to accept in the
- 2:30:48up destroy not the up V itself but the
- 2:30:51feature okay so we need feature here
- 2:30:55yeah this is it let's import the feature
- 2:30:59and we're going to do the following on
- 2:31:01that feature we're going to call up
- 2:31:03folds and we are going to find those up
- 2:31:07folds where user ID is the currently
- 2:31:11authenticated user ID and then execute
- 2:31:13delete on
- 2:31:15this this is it this is how we're going
- 2:31:17to do that uh in the root in the delete
- 2:31:22we need feature
- 2:31:24here and in the up vote down vote right
- 2:31:28here when we call up vote destroy we
- 2:31:30have to provide feature
- 2:31:32ID okay this is good now this is going
- 2:31:38to actually work however we have a
- 2:31:41couple of other cases actually I think
- 2:31:43we need also to provide preserve scroll
- 2:31:47to be
- 2:31:48true okay now we need
- 2:31:51else inside else um I'm going to do the
- 2:31:54following let's define the form equals
- 2:31:57null then if upvote is true then form
- 2:32:04equals upvote
- 2:32:06form uh else form equals downward
- 2:32:14form then on the form I'm going to call
- 2:32:17Post provide
- 2:32:23upvote
- 2:32:24store to store the
- 2:32:27upvote and we have to provide Reserve
- 2:32:32scroll to be true okay so depending on
- 2:32:35whether this form is upload form or
- 2:32:37download form we're going to have
- 2:32:40different data upload true or upload
- 2:32:42false and just like this we're making
- 2:32:45correct request now we need to take this
- 2:32:48up vote down vote and add event
- 2:32:51listeners on these buttons on
- 2:32:53click uh we are going to call upv
- 2:32:57downward with true this is for up vote
- 2:33:02and on click here up vote down
- 2:33:06vote
- 2:33:08actually like this in this case we have
- 2:33:10to provide
- 2:33:12false okay let's save it and have a look
- 2:33:18let's open Dev Dev tools I'm going to
- 2:33:20click on up vote which should remove my
- 2:33:23up vote completely now there's only two
- 2:33:26refresh the page um it stays there now
- 2:33:29I'm going to hit on up vote and we have
- 2:33:31this air up vote store parameter is
- 2:33:35required for up store that's actually
- 2:33:39correct for upold
- 2:33:42store uh where's that I think right here
- 2:33:47so for upv store right here we have to
- 2:33:50provide feature.
- 2:33:54ID cool now let's try uplo
- 2:34:01again okay it probably didn't do
- 2:34:06anything click on
- 2:34:07[Music]
- 2:34:09upot click on
- 2:34:11upot okay let's see nothing happens what
- 2:34:14request is made
- 2:34:20okay it returns with 200 status code
- 2:34:24we're going to check inside
- 2:34:26upvs click on
- 2:34:30this no the record is not
- 2:34:39created feature ID field is required I
- 2:34:44think I know the reason up
- 2:34:48vote we need to inside the
- 2:34:51fillable this is going to be feature
- 2:34:55ID user ID and
- 2:35:01upfold save that click on
- 2:35:08upfold okay it's still not
- 2:35:16working okay inside store I expect
- 2:35:19feature ID to be required and that must
- 2:35:23exist inside the features table uh okay
- 2:35:26so we have two ways either inside the
- 2:35:30store uh we we take this feature we
- 2:35:33actually expect this feature so we have
- 2:35:35to take that
- 2:35:37Feature Feature Feature from here this
- 2:35:40is one way to do it and we need to
- 2:35:42remove this feature ID from
- 2:35:44here and we have to provide feature ID
- 2:35:49here we don't need to dollar sign that's
- 2:35:53one way second way is to just return
- 2:35:56everything how it was and from the front
- 2:35:58end side we have to put a feature ID
- 2:36:02here and here as well so that's the
- 2:36:04second way okay so I'm going to do in
- 2:36:06the following way let's have a look
- 2:36:08click on
- 2:36:09upot we have something going on table
- 2:36:13upot has no column okay updated at we
- 2:36:16don't have that inside upvs so we should
- 2:36:19open upload model again and set time
- 2:36:23stamps to be false to disable the time
- 2:36:26stamps now let's try this again click on
- 2:36:28up vote now we see this turned into
- 2:36:32something but we will are redirected
- 2:36:34into feature
- 2:36:37index okay if I click on
- 2:36:43upfold we stay here click on up vote we
- 2:36:48will are redirected
- 2:36:50into feature
- 2:36:53index okay so upload download itself
- 2:36:57seems like to be working if you remove
- 2:37:00it is to download remove it is to upload
- 2:37:05download uplo downward if we go
- 2:37:09inside uplo and we go back into feature
- 2:37:13index which is something I don't
- 2:37:15want uh if we open upload controller we
- 2:37:19have we are redirecting into feature
- 2:37:21Index right here but on Destroy we go
- 2:37:24back so I think that's the reason so if
- 2:37:26I remove we stay here but if I upload we
- 2:37:30go into index and if we just change this
- 2:37:33into
- 2:37:35back this should work as well so I
- 2:37:38remove I stay here I upot I stay here
- 2:37:42and just like this I'm on the same page
- 2:37:46where I up voted or downvoted now we
- 2:37:49have almost everything ready we have
- 2:37:51Crow of the features we have up vote
- 2:37:54down vote displaying the correct number
- 2:37:56of up votes on the um on the feature and
- 2:38:01I think we can focus on leaving
- 2:38:04comments for this let's first open p
- 2:38:07chor and I'm going to comment everything
- 2:38:09what we changed so far
- 2:38:13Implement up
- 2:38:15vote down vote
- 2:38:20cool okay so I'm going to do the
- 2:38:22following I'm going to display number of
- 2:38:26comments for each feature right here and
- 2:38:31it's it's going to be like kind of
- 2:38:32clickable button and when clicking on
- 2:38:35that it's going to open that specific
- 2:38:36feature Details page where you're going
- 2:38:39to see all the comments as well as the
- 2:38:42feature
- 2:38:44details so let's
- 2:38:46open um feature
- 2:38:51feature
- 2:38:53item
- 2:38:55and so this is the up V down vote this
- 2:39:00is the
- 2:39:01description this is the
- 2:39:04um this is the actions drop down and I
- 2:39:08actually
- 2:39:10want the comments button to be inside
- 2:39:14here
- 2:39:20so right here I'm going to create a div
- 2:39:23then I'm going to have a link inside
- 2:39:26that and that link will go into root
- 2:39:31feature. show providing the feature so
- 2:39:35that link will have a comment
- 2:39:38of um not the comment but
- 2:39:44the let's just write comments
- 2:39:47here okay let's let's just write
- 2:39:50comments nothing else okay I'm going to
- 2:39:52also copy and paste some TN cisss
- 2:39:55classes because just typing those
- 2:39:56classes will take a lot of time
- 2:39:59so class name equals this let's all this
- 2:40:06on its own line and those are basically
- 2:40:08the classes
- 2:40:10which um should I enable
- 2:40:17R yeah I I think I should should
- 2:40:22enable soft
- 2:40:25wrap
- 2:40:28lines we need this
- 2:40:33for for TS
- 2:40:39and Dot
- 2:40:41TSX files as
- 2:40:45well okay
- 2:40:49okay good so these are the classes um
- 2:40:52which I added and we can have a look
- 2:40:56comments okay not bad let's give it um
- 2:41:00margin
- 2:41:01top margin top um or maybe or we can
- 2:41:06give it hiding y4 something like this
- 2:41:11okay when I click on this comments it's
- 2:41:12going to open the details page and right
- 2:41:13here I'm going to display all the
- 2:41:16comments so let's open show
- 2:41:20uh and right here we have this um title
- 2:41:26the name and the description and this is
- 2:41:29the place where I want to display the
- 2:41:33comments and I also want to display the
- 2:41:35new comment form so let's first create
- 2:41:38div and inside the div we need margin
- 2:41:43top let's give it margin top eight and
- 2:41:46then I want two components to create and
- 2:41:49and let me do this right now inside
- 2:41:52components uh new comment
- 2:41:57form this one and second is going to be
- 2:42:01comment
- 2:42:02item comment
- 2:42:07item okay now let's use new
- 2:42:11comment
- 2:42:13com excuse me so we have to create the
- 2:42:17components export d default
- 2:42:21function new comment
- 2:42:25form return
- 2:42:29this new comment form uh we can already
- 2:42:34use this new comment form here but this
- 2:42:37new comment form needs feature as well
- 2:42:40for the for which feature it is going to
- 2:42:42create the
- 2:42:44comment so let's accept right
- 2:42:47here feature
- 2:42:59okay uh I'm I'm going to come back to
- 2:43:03this so far this is good now on the
- 2:43:05feature uh we are going to return
- 2:43:08comments as well so let's open feature
- 2:43:13controller and find that index method we
- 2:43:18have with count
- 2:43:19with exists um paginate and I'm going to
- 2:43:24add right here with comments and I also
- 2:43:29want each comment to be selected with
- 2:43:32user just like this just make sure if we
- 2:43:35open comment.php it has a user there and
- 2:43:39if we open Feature Feature has comments
- 2:43:42there okay we have the relations defined
- 2:43:44properly and I'm selecting this with the
- 2:43:46comments user now if I open in feature
- 2:43:50resource from here I am going to return
- 2:43:55comments comments is going to be um
- 2:44:01collection okay so here uh I'm going to
- 2:44:04execute these
- 2:44:08comments
- 2:44:09map function for each comment I am going
- 2:44:13to return um array where we need the
- 2:44:17comment ID we need the actual comment we
- 2:44:21need the user information through this
- 2:44:23new user resource and I also need
- 2:44:27created it uh in the following way okay
- 2:44:32now each feature has
- 2:44:35comments the thing is that we are
- 2:44:38actually returning those comments in the
- 2:44:42feature uh listing as well which is
- 2:44:45something I don't want so I should not
- 2:44:48actually I shouldn't have actually added
- 2:44:50this
- 2:44:52here and we also don't
- 2:44:56need um we also don't
- 2:45:00need uh comments in the listing so
- 2:45:04either we have to Define new Resource
- 2:45:07One is going to be feature list resource
- 2:45:10and second is going to be feature
- 2:45:12resource for The Details page uh for
- 2:45:15comments or without comments
- 2:45:20uh okay I'm going to create Now new
- 2:45:22resource I can easily duplicate this
- 2:45:25feature
- 2:45:26resource let's call this feature
- 2:45:29list list
- 2:45:33resource uh okay and inside the feature
- 2:45:36list we don't need comments so we can
- 2:45:38remove that and if we go into feature
- 2:45:41controller we're going to use feature
- 2:45:43list resource
- 2:45:46here and we can remove this with
- 2:45:49we don't need that if I scroll down
- 2:45:51below and find this store not the store
- 2:45:55let's go upstairs and not the create but
- 2:45:58we are interested in show here we are
- 2:46:00using this feature resource and in the
- 2:46:02feature resource we are returning
- 2:46:03comments but not in the least
- 2:46:06resource okay now let's go into show
- 2:46:12again and on the feature we have now
- 2:46:16comments and this is something we have
- 2:46:18to to describe right here as
- 2:46:24well so we have this uh feature above
- 2:46:28that let's export type
- 2:46:34comment and we need ID to be
- 2:46:38number we need comment to be
- 2:46:42string and we need created it to be
- 2:46:46string as well and we need user to be
- 2:46:51user now on the feature we can provide
- 2:46:55that it has comments array in
- 2:46:58instance array of comment type now in
- 2:47:02the show we can iterate over comments we
- 2:47:06can call map we can take each
- 2:47:09comment and we need to return the
- 2:47:16comment item from here so I'm going to
- 2:47:18use comment
- 2:47:20item uh which we don't have defined we
- 2:47:26just created the file
- 2:47:28export um
- 2:47:31function export default
- 2:47:34function comment
- 2:47:37item return something I'm going to come
- 2:47:41back to this and then I'm using this
- 2:47:43comment item and we're going to accept
- 2:47:46we're going to provide comment
- 2:47:50here and we're going to provide key to
- 2:47:52be comment ID let's accept the comment
- 2:47:58here comment to be an instance of common
- 2:48:05type
- 2:48:07okay so now we have to implement these
- 2:48:10two files new comment form and the
- 2:48:14comment item so for comment item uh I am
- 2:48:18going to
- 2:48:21actually uh it's a very repetitive thing
- 2:48:24so I'm I was thinking about copying and
- 2:48:26pasting um few
- 2:48:32things okay uh let me just try to type
- 2:48:36it okay so we're going to have one div
- 2:48:40which will have display of um
- 2:48:43flex and gap of four and margin bottom
- 2:48:48three
- 2:48:49okay then we're going to have three divs
- 2:48:51the first one is going to be for the
- 2:48:53user Avatar second is going to be for
- 2:48:56the actual comment itself and the third
- 2:48:58one is going to be for the comment
- 2:49:00delete okay now the first one which is
- 2:49:03going to be for the user Avatar let's
- 2:49:05give it proper classes like W12
- 2:49:09h12 let's give it rounded full PG gray
- 2:49:14um 600 and give it Flex items Center and
- 2:49:20justify Center and inside here we're
- 2:49:23going to put the icon user icon so let's
- 2:49:27search for
- 2:49:29user outline let's copy the first one
- 2:49:32paste here and check change this stroke
- 2:49:37with line cap line
- 2:49:42join okay so this is the user
- 2:49:46now for the
- 2:49:50actual comment itself first we're going
- 2:49:51to display the user uh name so let's
- 2:49:56give it uh font bold and give it margin
- 2:50:00top of one and we're going to Output
- 2:50:05comment comment usern name okay and I'm
- 2:50:10going to also provide right here span
- 2:50:14which will have the following CSS
- 2:50:17classes like text
- 2:50:19gray uh 500 text extra small and margin
- 2:50:24left four and this is going to be
- 2:50:27comment created at when the comment was
- 2:50:30created after this we're going to have
- 2:50:32div and this is going to be an actual
- 2:50:35comment let's give it italic class we
- 2:50:38output
- 2:50:40comment. comment and let's also give it
- 2:50:43margin top
- 2:50:45one okay and finally finally we need
- 2:50:49that delete button so right here I'm
- 2:50:52going to put button and then inside we
- 2:50:56need this trash icon to delete the
- 2:51:01comment let's paste
- 2:51:04this
- 2:51:06with line cap and line join so then on
- 2:51:11that we need onclick which should call
- 2:51:14something like delete delete comment as
- 2:51:18an example ex Le we are going to create
- 2:51:19that um what else do we need I'm not
- 2:51:23going to put anything else here we just
- 2:51:26need to provide on that div Flex items
- 2:51:33Center flex and item Center that's it
- 2:51:37maybe also some uh pading Y 2 pading x
- 2:51:42uh six maybe and let's now Define this
- 2:51:46delete comment
- 2:51:50cons delete comment
- 2:51:54equals the following function and we
- 2:51:57need form as well so const form equals
- 2:52:02use form an empty form nothing else and
- 2:52:06on that form we can call delete we're
- 2:52:09going to
- 2:52:10provide uh comment do destroy which
- 2:52:14doesn't exist we're going to create that
- 2:52:17providing
- 2:52:19comment.
- 2:52:21ID okay and we have to provide right
- 2:52:25here preserve
- 2:52:28scroll true and I also want to provide
- 2:52:31preserve State because uh on that page
- 2:52:35there might be some State modified like
- 2:52:38something might be typed in the add new
- 2:52:41comment field and I don't want that to
- 2:52:44be
- 2:52:44lost so we're going to open web.php
- 2:52:48and we have to Define new rules for
- 2:52:50comments but I think we don't even have
- 2:52:52controller so let's create the
- 2:52:53controller PHP artisan
- 2:52:57make control
- 2:53:00control
- 2:53:02controller comment controller we hit the
- 2:53:06enter comment controller was created uh
- 2:53:09let's open comment controller and the
- 2:53:12only method we need or we need two
- 2:53:15methods basically right here one is
- 2:53:17going to be store and the comment is
- 2:53:19stored for specific feature so we can
- 2:53:22accept feature
- 2:53:24here and we can obviously accept request
- 2:53:28as well and then on
- 2:53:32the on the controller we need to
- 2:53:36validate so
- 2:53:38request
- 2:53:40validate we only need comment which
- 2:53:42needs to be required okay so we take the
- 2:53:46data and we're going to call
- 2:53:49comment create we provide the data
- 2:53:53however inside the data we're going to
- 2:53:55put uh feature ID to be feature ID
- 2:54:02and user ID to be authenticated user ID
- 2:54:09uh out
- 2:54:11ID let's import this
- 2:54:14oops let's import
- 2:54:17this out
- 2:54:19okay let's open comment create and we
- 2:54:21are going to Define
- 2:54:24failable uh
- 2:54:27comment feature ID and user
- 2:54:34ID okay cool now let's return to
- 2:54:40root uh feature.
- 2:54:44show and we have to provide the feature
- 2:54:47as well
- 2:54:49and just like this the creating new
- 2:54:51comment is ready let's define the second
- 2:54:53function which is going to be for
- 2:54:55destroy
- 2:54:56destroy and
- 2:54:59comment that comment needs to be
- 2:55:01destroyed so we call comment delete and
- 2:55:06actually we
- 2:55:07should we should go into feature show
- 2:55:11again but we need the feature ID so
- 2:55:16let's take this feature
- 2:55:18ID comment
- 2:55:22feature uh feature uncore ID and then we
- 2:55:25provide right here the feature ID to go
- 2:55:29to that uh page if we open now Roots
- 2:55:34file root we
- 2:55:38need we need post for uh
- 2:55:44comments um let me think uh actually
- 2:55:48actually it can be
- 2:55:52Feature Feature uh comments so the post
- 2:55:56request on the following URL and we're
- 2:55:59going to use comment
- 2:56:02controller uh
- 2:56:06store comment controller store uh the
- 2:56:09name is going to be comment store and
- 2:56:12let's define the second Road this is
- 2:56:15going to be to delete specific comment
- 2:56:20comment and the comment to be deleted
- 2:56:24the method is destroy the rote name is
- 2:56:27comment
- 2:56:30destroy awesome so this is the comment
- 2:56:33item the delete actually should work but
- 2:56:36we should focus on creating a new
- 2:56:39comment as
- 2:56:42well so here let's create the form it
- 2:56:46needs on sub
- 2:56:49submit uh on submit equals
- 2:56:52create comment we're going to come back
- 2:56:55to this function and create that we need
- 2:56:57label and we can make this just um for
- 2:57:01screen read
- 2:57:02only is R only let's give
- 2:57:07it um your
- 2:57:10comment I think yeah we we have not
- 2:57:14taken care any of the accessibility
- 2:57:16things uh because we're doing something
- 2:57:19um just for learning purposes if you are
- 2:57:23doing something in production obviously
- 2:57:25you should consider this but because so
- 2:57:27far we haven't done anything
- 2:57:29like regarding accessibility I think we
- 2:57:32don't need that label as well um we need
- 2:57:36extra div and the div should contain the
- 2:57:38text area in the primary Button as well
- 2:57:44okay so let's give that div or maybe we
- 2:57:46can just uh use that for let's give it
- 2:57:50Flex items Center we need pading X3 ping
- 2:57:56Y 2 rounded LG BG gray
- 2:58:0350 and on dark
- 2:58:06mode we're going to make p grade
- 2:58:09800 uh and then right here we're going
- 2:58:12to use text area
- 2:58:14input and let's give it um some of the
- 2:58:19properties
- 2:58:21like it should have doesn't need name I
- 2:58:24don't know uh let's give it rowes to be
- 2:58:27equal one let's give it
- 2:58:30value to
- 2:58:34be um we have to define the form as well
- 2:58:37const data equals use
- 2:58:42form okay so we provide
- 2:58:45comment to be an empty string
- 2:58:48and we provide we can provide feature ID
- 2:58:52here or we can put that feature ID in
- 2:58:54the URL so I think we don't need this
- 2:58:56because when creating new comment we
- 2:58:58have this feature in the URL okay so
- 2:59:01let's also Define this create comment
- 2:59:05which is form event handler type of um
- 2:59:13function so we accept
- 2:59:15event then on that event we call prevent
- 2:59:19default and we are going to take we have
- 2:59:22the data we have to take set data we
- 2:59:25have to take post and we have to take
- 2:59:29processing we can put
- 2:59:32them on New
- 2:59:37Line okay
- 2:59:40awesome now we are going to call
- 2:59:45Post um comment
- 2:59:50create comment um not create but
- 2:59:55store so we're going to provide preserve
- 2:59:58scroll to be true and we can provide
- 3:00:01preserve state to be true as
- 3:00:06well okay and we need on success and
- 3:00:09when this happens we have to call set
- 3:00:13data on comment to be an empty string so
- 3:00:17we reset the comment actually when new
- 3:00:19comment is created we reset the comment
- 3:00:22input now instead of value we have to
- 3:00:25provide uh data comment and we have to
- 3:00:29listen on
- 3:00:30change on change um we take the event
- 3:00:36and then call set
- 3:00:38data on comment we provide
- 3:00:42event.
- 3:00:44target. value
- 3:00:48okay and what else do we need we can
- 3:00:50provide some class name a margin top
- 3:00:53block and full width and let's give it
- 3:00:56also
- 3:00:58placeholder um a
- 3:01:02comment uh let's just give
- 3:01:07it your
- 3:01:11comment okay and I need primary button
- 3:01:15primary button right here and let's give
- 3:01:18it text comment and that button should
- 3:01:21be disabled if processing is true now if
- 3:01:26we open
- 3:01:29show we have this new comment form
- 3:01:32everything looks good now let's open the
- 3:01:34show page refresh
- 3:01:38it and have a look okay so this looks
- 3:01:44ugly because
- 3:01:48we have that extra div let's remove this
- 3:01:50extra
- 3:01:53div okay so that doesn't look ideal um
- 3:01:57but I'm not going to spend more time on
- 3:01:59just uh styling this
- 3:02:04thing let's test the functionality okay
- 3:02:07test comment item let's click on
- 3:02:12comment and we're going to see what's
- 3:02:16happened
- 3:02:19comment store feature parameter is
- 3:02:21required for comment store that's
- 3:02:23correct so we have to provide feature.
- 3:02:25ID
- 3:02:27here let's clear this click on comment
- 3:02:31and as you see comment was added that's
- 3:02:36not bad
- 3:02:38so there are some pings which should be
- 3:02:43probably adjusted in the comment form
- 3:02:50I think we don't need padding X at
- 3:02:57all but we need margin bottom
- 3:03:01four something like this and this
- 3:03:06one uh this St needs Flex
- 3:03:10one if we open comment item we have
- 3:03:13three
- 3:03:15divs this one should have
- 3:03:18Le
- 3:03:20one
- 3:03:21okay another comment click on comment
- 3:03:26another comment goes at the top so the
- 3:03:28latest comment should be at the top
- 3:03:30another comment actually went to the
- 3:03:32bottom so the latest comment should be
- 3:03:34at the top so we should open feature.
- 3:03:38PHP and find the comments and we're
- 3:03:40going to provide latest method here
- 3:03:43refresh the page now latest comment is
- 3:03:47going to be
- 3:03:48at the top uh one more click on comment
- 3:03:53now one more is at the top that's
- 3:03:56awesome now if we try to delete
- 3:03:59this it is working
- 3:04:03successfully uh test another comment and
- 3:04:07also the scroll is preserved and if I
- 3:04:10have something written here which is
- 3:04:12part of the State uh if I click on this
- 3:04:16now this also stays here doesn't clear
- 3:04:18and this is exactly
- 3:04:20what this preserve state is
- 3:04:25doing okay so what else do we need so we
- 3:04:28have also added functionality to leave
- 3:04:32comments on the
- 3:04:34feature so we have I think almost the
- 3:04:37whole functionality and I think right
- 3:04:40now uh if I didn't miss anything we can
- 3:04:43focus on um the remaining things which
- 3:04:47are basically inertia version two
- 3:04:50things uh and roles and permissions now
- 3:04:54let's start working on roles and
- 3:04:56permissions and there are few things
- 3:04:58we're going to do first right now at the
- 3:05:01moment every user has possibility to
- 3:05:04create new features we are going to
- 3:05:06restrict this only for admin users and
- 3:05:10also leaving comments is right now
- 3:05:12allowed for every users leaving comments
- 3:05:15is only possible for comment
- 3:05:18users who has Ro commenter now let's
- 3:05:21have a look in the first let me comment
- 3:05:26everything
- 3:05:28so
- 3:05:30Implement comment
- 3:05:33CR okay we actually didn't Implement
- 3:05:36update for comments but that's not
- 3:05:39important um okay let's close everything
- 3:05:41and I'm going to open up enam
- 3:05:44permissions enam so these are the
- 3:05:46permissions what we have and the
- 3:05:48permissions are assigned to roles and
- 3:05:49users have roles so we have manage
- 3:05:52features manage users manage comments
- 3:05:55and upvote and
- 3:05:58downvote so basically users regular
- 3:06:01users can only up vote and downvote
- 3:06:03commenters can only leave comments and
- 3:06:06up vote and down vote uh and admin users
- 3:06:09can manage users can manage features and
- 3:06:12manage comments as well pretty much do
- 3:06:14anything okay so we are returning those
- 3:06:17roles and permissions on the front and
- 3:06:18side and we need to hide certain buttons
- 3:06:22on the front end side but let's first
- 3:06:24focus on the backend
- 3:06:27side and for this let's open spotty
- 3:06:30permissions package because there are
- 3:06:33few things we're going to have a look so
- 3:06:35in the documentation we have this middle
- 3:06:37we section and we're going to add middle
- 3:06:40we um based on the permissions so this
- 3:06:43can basically U is a middle we which
- 3:06:46comes with this party package and we're
- 3:06:48going to provide permission right here
- 3:06:50and we can even provide multiple
- 3:06:53permissions all right now let's open
- 3:06:56web.php and find this resource for
- 3:07:02feature and we can assign this middle
- 3:07:07wear can and we have to provide the
- 3:07:11permission name the permission name in
- 3:07:14our case will
- 3:07:16be per permissions
- 3:07:20inam manage
- 3:07:23features
- 3:07:26so why do I have warning yeah we need
- 3:07:30value so that pretty much means
- 3:07:33that um any rout can only be accessed
- 3:07:38from the user who can manage
- 3:07:43features that is not actually correct
- 3:07:46because uh View features should be
- 3:07:49possible for regular users as well but
- 3:07:54if we have a look in the browser right
- 3:07:56now I'm an admin user I just need to log
- 3:07:59out and I need to access for example
- 3:08:04commenter and just click on features now
- 3:08:08we see these 403 so the middle we works
- 3:08:12but actually we did this incorrectly
- 3:08:14okay so let's define uh let's have a
- 3:08:18look again what roads we have PHP
- 3:08:20Artisan Road list especially I'm
- 3:08:24interested in the features so we have
- 3:08:27possibility to create new feature which
- 3:08:29only should be for um the manage
- 3:08:32features
- 3:08:34permission um this one as well for only
- 3:08:37manage
- 3:08:39features uh features show a single
- 3:08:41feature should be visible for every user
- 3:08:45basically update destroy so we have
- 3:08:49seven right 1 2 3 4 5 six and we have
- 3:08:538it as well basically all the features
- 3:08:56except index and show is only available
- 3:09:01for manage
- 3:09:02users so what we can do is the following
- 3:09:07so here we can provide only or let's
- 3:09:10provide accept
- 3:09:13accept
- 3:09:15index and show so for any route in this
- 3:09:19resource except index and show is only
- 3:09:21possible if the user has permission
- 3:09:24manage features and again this relates
- 3:09:30to what
- 3:09:35that this relates
- 3:09:40to feature create feature update feature
- 3:09:46destroy feature feature
- 3:09:50edit and that's it right feature create
- 3:09:54one 2
- 3:09:573
- 3:10:084 yeah index yeah that makes sense uh
- 3:10:14get confused let's look
- 3:10:16again so here let's rerun this root
- 3:10:23list so these comments and upvote is not
- 3:10:27from the feature controller so this is
- 3:10:30one two
- 3:10:32three four five six and seven so five of
- 3:10:37them
- 3:10:39store
- 3:10:40create
- 3:10:43update destroy and edit so this is only
- 3:10:46possible for manage uh features
- 3:10:49permission okay so let's return this go
- 3:10:53into and rerun this and now we have uh
- 3:10:58only few features we don't have index
- 3:11:00and we don't have show we have to
- 3:11:02register them separately okay so root
- 3:11:08get feature and we're going to use
- 3:11:11feature controller index feature Index
- 3:11:14this doesn't need any middle wear
- 3:11:16because this is available for every user
- 3:11:18if the user is
- 3:11:22authenticated get uh feature specific
- 3:11:25feature and let's give it name feature
- 3:11:29show let's move this down as well okay
- 3:11:34now this is already awesome so if we try
- 3:11:37to access to Features we are actually
- 3:11:40able to access that however if we try to
- 3:11:42access features create page we see this
- 3:11:44forbidden because this is only for admin
- 3:11:46users not not for us in the same way if
- 3:11:49we try to edit the feature we get still
- 3:11:5243 the section is unauthorized and if we
- 3:11:55try to delete the feature we still get
- 3:11:57this 403 this section is unauthorized
- 3:11:59right now we are commenter we cannot
- 3:12:02manage
- 3:12:03features okay now let's log in by
- 3:12:07another user which is
- 3:12:11user okay um let's save this let's go
- 3:12:16into feature
- 3:12:17that user is also not able to do any of
- 3:12:20these actions and if we open now The
- 3:12:24Details page that user should not be
- 3:12:26even able to leave a comment so right
- 3:12:29now the user can leave a comment but
- 3:12:32only commenter role users can do this so
- 3:12:35let's open web.php and find the comment
- 3:12:38section where you destroy you create or
- 3:12:41destroy comment and right here let's use
- 3:12:45middle wear can and permissions enam
- 3:12:49manage comments only those users who
- 3:12:52manage comments can actually create the
- 3:12:56comment or to destroy the comment as
- 3:12:59well so in the same
- 3:13:01way to destroy the comment but to be
- 3:13:04able to destroy the comment there is one
- 3:13:06additional thing we have to consider and
- 3:13:10the user basically must be owner of the
- 3:13:14comment to be able to destroy that
- 3:13:19we can do this check with in two ways
- 3:13:21either we can Define gate or policy or
- 3:13:24we can just write an if statement right
- 3:13:26here so I'm not going to over complicate
- 3:13:28things right now with Gates and policies
- 3:13:30however if you're interested to know
- 3:13:32more about this authorization mechanisms
- 3:13:34in Lal uh that section the entire module
- 3:13:38is actually covered in my laral for
- 3:13:40beginners course which you can find on
- 3:13:42my website the cod.com so right now I'm
- 3:13:45just going to write if statement if
- 3:13:48comment uh user ID is the same as out ID
- 3:13:54uh or if it's not the same it's better
- 3:13:56to do it like this then we simply call
- 3:14:00abort and we can provide right here the
- 3:14:02code 403 which means forbidden so the
- 3:14:07destroy will not be called if the user
- 3:14:11does not have permission to manage
- 3:14:13comments however even if user has that
- 3:14:16permission user should not be able to
- 3:14:18delete somebody else's comment right and
- 3:14:21this is exactly what we are doing in
- 3:14:23this case so now if we check our website
- 3:14:28if I click on this now I get this the
- 3:14:30section is unauthorized and if I try to
- 3:14:32create new
- 3:14:34comment click on comment I get this
- 3:14:36again the section is
- 3:14:38unauthorized okay I think we on the
- 3:14:41backend side I can't remember everything
- 3:14:44else what we need if we have a look in
- 3:14:46the rules tools so let's double check
- 3:14:49these accessing the dashboard the
- 3:14:50dashboard right now is kind of abstruct
- 3:14:52page so we don't we don't display any
- 3:14:54particular information yeah updating the
- 3:14:57profile is for everyone the dashboard is
- 3:15:00for everyone uh managing features is
- 3:15:02only for those who has managed features
- 3:15:05viewing
- 3:15:06features um single feature or um list of
- 3:15:10features is for
- 3:15:12everyone um up vote and delete his own
- 3:15:16app vote is also for everyone however
- 3:15:20let's just make sure that uh user is not
- 3:15:23able to destroy somebody else's upfold
- 3:15:25no we are using the AL ID so basically
- 3:15:27from the this particular feature upfold
- 3:15:30we are deleting the one which is made by
- 3:15:32that user okay so far so good in the
- 3:15:35comment section yeah only manage
- 3:15:37comments can create comment or destroy
- 3:15:40the comment so the permissions on the
- 3:15:41backend side is fully ready now let's
- 3:15:44focus on the front and side and I'm
- 3:15:47going to open index TSX and right here
- 3:15:50we have this button create new features
- 3:15:53which we need to completely hide and we
- 3:15:56don't want to display if the user
- 3:15:58doesn't have the permission to manage
- 3:16:00features okay this is what I am going to
- 3:16:03do right now in the resources JS I'm
- 3:16:06going to create a new typescript file
- 3:16:10called maybe
- 3:16:12helpers and from here I am going to
- 3:16:15export
- 3:16:17um some of the functions which will be
- 3:16:20identical to how you use K functions in
- 3:16:24blade for
- 3:16:27example um from the Lal spati
- 3:16:31permissions package if we check the way
- 3:16:34how you test certain things blade
- 3:16:37directives for example so this is the
- 3:16:39way how you can check if the current
- 3:16:41user can edit articles this is second
- 3:16:45way however we have typescript we have
- 3:16:48react so we don't have that can function
- 3:16:51can directive in react so this is
- 3:16:54exactly what we are going to do at the
- 3:16:57moment so
- 3:16:59export function can we can just use K
- 3:17:03here which equals the function and we WR
- 3:17:08here export function No it should not be
- 3:17:11like this okay so we accept right here
- 3:17:15user to be an in
- 3:17:17of user and we're going to also accept
- 3:17:21permissions permissions which should be
- 3:17:25um array of
- 3:17:28strings like this and this should return
- 3:17:32Boolean if the current user uh can one
- 3:17:37of the permissions one of the
- 3:17:39permissions available um right here uh
- 3:17:42or we can check a specific permission
- 3:17:44just by providing permission here
- 3:17:47and removing the arrow now the the
- 3:17:50square brackets sorry so if we just
- 3:17:52return user do permissions includes the
- 3:17:57given permission this means that the
- 3:17:58user can do the specific permission so
- 3:18:02this is related to permission we can
- 3:18:03duplicate this and create second
- 3:18:06function um which we can call has roll
- 3:18:09as an example and right here we're going
- 3:18:11to
- 3:18:12accept um roll if user roles includes
- 3:18:17that specific role now if we go into
- 3:18:20index TS6 so now we can use that method
- 3:18:25right here so let's just wrap
- 3:18:27this and then I'm going to use can if
- 3:18:31the user and we need also to access the
- 3:18:34current user so we can access current
- 3:18:36user in two ways one way is to use page
- 3:18:42here then access props then access out
- 3:18:46and then access user okay this is the
- 3:18:48current user second way is to access the
- 3:18:51user directly or to access out directly
- 3:18:55okay in which case instead of defining
- 3:19:00the props in in the following way we
- 3:19:03have to modify this and we have to use
- 3:19:05uh page props and then in this we have
- 3:19:09to provide some additional um additional
- 3:19:13types so other than the following page
- 3:19:16props which are defined right here which
- 3:19:18is Al and Ziggy uh we have features as
- 3:19:25well um okay so now inside this can we
- 3:19:28can use
- 3:19:30al.
- 3:19:32user and we have to provide the
- 3:19:34permission so the permission in our case
- 3:19:37is
- 3:19:38manage um how it's called manage
- 3:19:41features so we can take this manage
- 3:19:43features if the current user can manage
- 3:19:46features and then we display the
- 3:19:48following link now if we save this and
- 3:19:51if we check in the
- 3:19:53browser we go in the features we don't
- 3:19:56see that button anymore now we're going
- 3:19:58to do something similar in feature
- 3:20:02actions dropdown we have this delete
- 3:20:05feature and edit feature and we can do
- 3:20:08this for both right now we have just a
- 3:20:11manage features but if you have separate
- 3:20:14features for your project
- 3:20:17sorry separate permissions for your
- 3:20:19project you can do the following so
- 3:20:22right here you can just
- 3:20:26write
- 3:20:28can and in this case we need to access
- 3:20:30the user
- 3:20:32um in the following way const user
- 3:20:37equals uh use
- 3:20:40age.
- 3:20:42crops. out.
- 3:20:45user and
- 3:20:47now if user and right here you need to
- 3:20:51provide the permission name let's finish
- 3:20:54the let's solve the synx errors and if
- 3:20:56you again if you have separate
- 3:20:58permissions for edit feature you can
- 3:20:59just write edit feature here and in the
- 3:21:03same
- 3:21:04way you can just write delete
- 3:21:08feature but we don't have these separate
- 3:21:11permissions okay we have just single
- 3:21:13permission which is called manage
- 3:21:16features
- 3:21:17in which case we have to just write a
- 3:21:20single
- 3:21:22can right here around this or
- 3:21:28even I think we can do this around here
- 3:21:31so let's WRA it
- 3:21:38everything or we can do the
- 3:21:41following so
- 3:21:43if I can c current
- 3:21:47user uh
- 3:21:49manage features if it can manage
- 3:21:53features or if it cannot manage features
- 3:21:56let's do like this then we're going to
- 3:21:58Simply return like empty
- 3:22:01thing uh we can return fragment or we
- 3:22:04can just do a return if user cannot
- 3:22:07manage features otherwise we return the
- 3:22:09following and again the current user
- 3:22:12doesn't have any permissions so this is
- 3:22:14what will happen right now so the
- 3:22:16current user doesn't have uh the manage
- 3:22:18features so nothing is displayed but if
- 3:22:21I comment out this part now we see that
- 3:22:24the button is displayed but none of the
- 3:22:26actions are displayed because we expect
- 3:22:28the current user to have edit feature
- 3:22:31and delete feature again this is not for
- 3:22:34us this is for just to give you an idea
- 3:22:37how you can use different
- 3:22:39permissions uh but in our case we can
- 3:22:42simply remove this part
- 3:22:46because we have just one
- 3:22:49if remove that part as
- 3:22:52well now the menu items will be visible
- 3:22:57but if we uncomment this then this is
- 3:23:00gone so current user cannot manage a
- 3:23:03feature so we don't see any actions
- 3:23:06current user can also not manage
- 3:23:09comments so if we go right here the
- 3:23:11current user should not be able to see
- 3:23:12this comment box as well as the delete
- 3:23:15icon right here so this is how we are
- 3:23:18going to
- 3:23:20do uh let's open new comment form scroll
- 3:23:25down below and we can do the following
- 3:23:28if and we need to access to the current
- 3:23:30user which I am going to
- 3:23:35copy like this okay so if can current
- 3:23:42user
- 3:23:45manage comp comments cannot manage
- 3:23:48comments let's do like this then we
- 3:23:50simply
- 3:23:52return now current user cannot manage
- 3:23:55comments so we don't see this comment
- 3:23:57box at
- 3:23:59all as for the delete button for the
- 3:24:03comment
- 3:24:04item we need to check this is the delete
- 3:24:07button for the comment item and by the
- 3:24:09way I think we need to reduce the size
- 3:24:11of the trash icon the smaller one is
- 3:24:14better and right here
- 3:24:16we need to completely hide the following
- 3:24:19uh div okay so let's do the
- 3:24:24following if current user
- 3:24:30can uh can let's provide current user
- 3:24:33first then can manage
- 3:24:37comments but that's not enough because
- 3:24:40current user might be able to manage
- 3:24:42comments we don't have the user so we
- 3:24:44have to again use
- 3:24:48that but that's not enough the current
- 3:24:50user might be able to manage comments
- 3:24:52but this specific comment might not
- 3:24:54belong to the current user okay so we
- 3:24:57need the following and if the comment
- 3:25:01user
- 3:25:02ID is the same as the
- 3:25:07authenticated user
- 3:25:09ID then we should display the button now
- 3:25:12the comment does not actually have user
- 3:25:15ID it it has user so we should probably
- 3:25:19go back and change this into user.
- 3:25:22ID now let's have a look we don't see
- 3:25:25these trash icons anymore the user
- 3:25:28doesn't see any so this this is a
- 3:25:30regular user it can only up Vote or down
- 3:25:32vote or see comments so they can see
- 3:25:35comment but they cannot leave the
- 3:25:36comment so now they can do down vote
- 3:25:39they can do upfold that's all what they
- 3:25:41are able to they can just browse the
- 3:25:43features and see they can click on
- 3:25:45comments which will open the comment the
- 3:25:47actual view page this
- 3:25:50particular uh this particular feature
- 3:25:52doesn't have any comments that's why the
- 3:25:53user doesn't see anything but yeah
- 3:25:56that's it however uh if the user doesn't
- 3:25:59have um such type of ability to leave a
- 3:26:02comment maybe you want to show the
- 3:26:05corresponding message so for
- 3:26:08example if the user cannot manage
- 3:26:11comments then you might need to show it
- 3:26:16like you don't have permission to leave
- 3:26:23comments okay and we can give it some
- 3:26:26classes like text Center and text Gray
- 3:26:32600 gr something like this um if the
- 3:26:36user cannot manage comments yeah that's
- 3:26:39correct the user cannot manage comments
- 3:26:42this is in inside the comment okay no
- 3:26:44this is inside the comment item we we
- 3:26:46should put this in the new comment form
- 3:26:49maybe if user cannot manage comments
- 3:26:52this is something what we can
- 3:26:57return this is what we can return you
- 3:27:01don't have permission to leave comments
- 3:27:02that's
- 3:27:03it okay I think that's good
- 3:27:08um one thing what I have to consider is
- 3:27:13the
- 3:27:14following uh if I log out right right
- 3:27:16now and log in as admin user the admin
- 3:27:21user can do everything so the admin user
- 3:27:23sees the uh new feature uh it can leave
- 3:27:27the comment and also edit the features
- 3:27:30but the even admin users should that's a
- 3:27:33question basically should the admin user
- 3:27:35be able to edit somebody else's feature
- 3:27:39I think yeah we can give that permission
- 3:27:41so the decision right here is up to you
- 3:27:44but I decided that all users will be
- 3:27:47able to edit uh or delete features even
- 3:27:50created by other admin users so that's
- 3:27:54that's fine that's fine I allow this in
- 3:27:57this application you can decide what you
- 3:27:59want if you don't want one admin user to
- 3:28:02be able to edit or delete another admin
- 3:28:05users um admin users feature you have to
- 3:28:10do some additional things like you have
- 3:28:13to probably put a either Define gate or
- 3:28:16policy or put um if similar to this in
- 3:28:21the feature controller that the feature
- 3:28:23user ID should be the currently
- 3:28:24authenticated user ID when trying to um
- 3:28:27destroy or update and in the same way
- 3:28:32inside this feature actions drop down
- 3:28:35you can hide this link or this link if
- 3:28:40the currently authenticated user ID
- 3:28:42doesn't equal to the feature user ID so
- 3:28:45yeah I just giving you ideas how you can
- 3:28:48do in your applications certain things
- 3:28:50in my case I'm just going to leave it
- 3:28:53and just like this we have roles we have
- 3:28:55permissions uh you can use if you need
- 3:28:59you can use has rooll check as well
- 3:29:02right here so you use has role you
- 3:29:05provide the user ID and you provide the
- 3:29:07role like admin a if the user is admin
- 3:29:10then the user um
- 3:29:13Can display can see the following
- 3:29:16uh item so the decision and
- 3:29:19implementation is up to you so I just
- 3:29:22give you try to give you tools and the
- 3:29:24ways how I generally um would do this in
- 3:29:28um an actual projects so this has really
- 3:29:31something we don't need and I think the
- 3:29:32last thing is that we're going to uh add
- 3:29:35user section and admin user will be able
- 3:29:37to manage users only admin users will be
- 3:29:40able to manage users and admin users
- 3:29:42will be able to give uh other r rules or
- 3:29:47change rules to another users now let me
- 3:29:51comment everything and we can call this
- 3:29:54Implement roles uh
- 3:29:59restriction restrictions based on roles
- 3:30:02and
- 3:30:05permissions okay one thing um I want to
- 3:30:08mention is that in the
- 3:30:11spotty um permissions package you can
- 3:30:13find many other ways how you you can
- 3:30:16restrict that uh in your project so
- 3:30:20right now we use middle we approach but
- 3:30:23you can do a different approach um how
- 3:30:26to restrict that so you you I just
- 3:30:28recommend to check the
- 3:30:30documentation and find out how you can
- 3:30:34do certain things uh there are always
- 3:30:37more than one way how you can solve the
- 3:30:40problem how you can uh restrict access
- 3:30:43to certain things and so on the middle
- 3:30:45we is what I used you can find other
- 3:30:48things in the
- 3:30:50documentation okay now what I'm going to
- 3:30:51do is that when the user is trying to
- 3:30:54register that user doesn't have any
- 3:30:57permission okay so and we want that
- 3:31:00every user basically every new user to
- 3:31:03have a role uh user role and that's it
- 3:31:07for this we're going to open
- 3:31:10authenticated session controller which
- 3:31:13is uh which comes with LEL pre is and we
- 3:31:16have the store and that's it when the
- 3:31:18user basically gets
- 3:31:20authenticated uh session uh not
- 3:31:24authenticated we want registered user
- 3:31:27controller when the user
- 3:31:30registers uh right here the user is
- 3:31:33created and on that user we are going to
- 3:31:37call method assign Ro and we have to
- 3:31:41provide roles enam user V value that's
- 3:31:46it so every new user will have a role of
- 3:31:49the user and thus that user will be able
- 3:31:51to um to up vote and down vote uh
- 3:31:56without that basically right now it's
- 3:31:58going to still work however if we open
- 3:32:00this web PHP and we restrict certain
- 3:32:04things right here for
- 3:32:07example if we find this up vote and
- 3:32:10download this is it so to just um leave
- 3:32:13the upload and uh destroy your own
- 3:32:16upvote we can provide right here middle
- 3:32:20wear in the same way like we did uh for
- 3:32:25the um manage features or manage
- 3:32:28comments okay so we haven't used um
- 3:32:31other manage it's not called manage
- 3:32:34upload download permission but we can
- 3:32:37use this as well and if we actually use
- 3:32:41that upload download permission right
- 3:32:43here and if we don't don't add this line
- 3:32:48if we don't assign user role to the
- 3:32:51newly registered users even these new
- 3:32:54users will not be able to up vote and
- 3:32:57down
- 3:32:58vote okay so this is something we don't
- 3:33:01want so there are two ways one way is
- 3:33:03that we can completely avoid the user
- 3:33:06role and we can assume that everyone who
- 3:33:09doesn't have any roles at all it means
- 3:33:13that they are user roles okay they have
- 3:33:15user rows and we don't assign anything
- 3:33:18here we don't also add the middle we
- 3:33:22here and here and every authenticated
- 3:33:24and verified user we have both checks
- 3:33:27right here verified authenticated they
- 3:33:29will be able to do these things okay or
- 3:33:33we can explicitly Define
- 3:33:36that up vote and down vote is only
- 3:33:39possible for the users who have uh like
- 3:33:43specific permissions Okay so again the
- 3:33:46decision is up to you how you're going
- 3:33:48to do this even if I add those this this
- 3:33:51permission upvote permission right here
- 3:33:54now I don't add the permission in the
- 3:33:56feature show feature index um also the
- 3:34:02dashboard um yeah so my point is that
- 3:34:05the user role is kind of very
- 3:34:08basic and
- 3:34:09everyone if they have that user
- 3:34:12role um they will be able to do pretty
- 3:34:15much anything so what I'm going to do is
- 3:34:17the following just to make these things
- 3:34:19easy verified and
- 3:34:22can or can or we can use the RO let's go
- 3:34:26into
- 3:34:27documentation and find this middle wear
- 3:34:30again and we have two ways one is can
- 3:34:34and second is we can also Define this
- 3:34:38aliases for R permission roll or
- 3:34:43permission and once we Define this then
- 3:34:45we can use role and um user in our case
- 3:34:49so let's actually Define this
- 3:34:53aliases let's open app.php from
- 3:34:57bootstrap app and we can Define these
- 3:35:02aliases for roll and permission and
- 3:35:06now if we go in the web PHP right here
- 3:35:10we can say
- 3:35:13roll rolls andam
- 3:35:16um user value so the user needs to be
- 3:35:21verified and also user needs to have
- 3:35:23role um of the user in which case user
- 3:35:27is able to view the dashboard um just
- 3:35:30see the features leave up Vote or down
- 3:35:33vote and that's pretty much it now again
- 3:35:37if I open this registered user
- 3:35:39controller and if I just comment out
- 3:35:42this line don't don't activate this line
- 3:35:45and then I try to sign up we go
- 3:35:52into register
- 3:35:55page uh I'm going to try
- 3:35:57to maybe I can use zura because I think
- 3:36:01I have created that user let me double
- 3:36:05check no I don't have Zora user okay I
- 3:36:08have to actually sign
- 3:36:12up register
- 3:36:17okay let's now register with user zura Z
- 3:36:19WR example.com
- 3:36:25okay I received an email in mail pit we
- 3:36:29can open Local Host
- 3:36:31Port uh
- 3:36:33825 we have new email I'm going to click
- 3:36:36on this okay I activated I verified my
- 3:36:39email but I get this for Beed that's
- 3:36:41because my user doesn't have user role
- 3:36:45and user roll is actually necessary to
- 3:36:48be able to access the dashboard which is
- 3:36:50what we defined exactly right here in
- 3:36:53the following line
- 3:36:55okay now what we can do is open modu has
- 3:36:59roles we can create new record here app
- 3:37:02modules user and the newly registered
- 3:37:04user will probably be zura uh with uh
- 3:37:07with the id4 so we can provide four here
- 3:37:11save that let's provide four here as
- 3:37:13well save that refresh the
- 3:37:17page
- 3:37:18um yeah and this one needs also
- 3:37:22permission probably roll has
- 3:37:27permission the roll
- 3:37:30um the RO has permissions just the user
- 3:37:33didn't have
- 3:37:40permission uh hold on
- 3:37:46oh wait this should not be
- 3:37:49four the role should be user one my
- 3:37:55bad so this user has a role one which is
- 3:38:00user zura has user RW okay now if we
- 3:38:04refresh the
- 3:38:06page zura is able to access the
- 3:38:08dashboard to view features it user zura
- 3:38:11doesn't see this um create new feature
- 3:38:14or edit features and also Zur is not
- 3:38:17able to leave a comment or delete the
- 3:38:19comment they can um he can just uh view
- 3:38:22existing comments but we're going to do
- 3:38:25this for every new user so we're going
- 3:38:26to put this in this registered user
- 3:38:28controller I'm going to uncomment this
- 3:38:30part right now and if we try to register
- 3:38:34right now with another
- 3:38:37user let's use Mary Mary at example.com
- 3:38:47okay we received an
- 3:38:50email
- 3:38:53verify uh let's see what happened the
- 3:38:56section is unauthorized why it's not
- 3:39:02unauthorized
- 3:39:06okay user assigned
- 3:39:08Ro Let's see we have new user marry 5
- 3:39:13assigned
- 3:39:14rle we see see this five here uh let's
- 3:39:17check the email verified dat okay email
- 3:39:21verifi
- 3:39:22dat probably yeah I opened the same one
- 3:39:25I just opened the same previous URL so
- 3:39:27this is the new one for Mary click on
- 3:39:31this now Mary's account was verified and
- 3:39:35Mary is able to access features leave an
- 3:39:38app
- 3:39:39vote
- 3:39:42awesome now let's Implement a assigning
- 3:39:46roles to other users and removing those
- 3:39:48roles for admin
- 3:39:50users let's open PHP storm and I'm going
- 3:39:53to close everything and I'm going to
- 3:39:57open first let's comment everything we
- 3:40:00can call
- 3:40:01this
- 3:40:03um
- 3:40:05assign user rooll
- 3:40:09to to every new user
- 3:40:17okay so I need to create now user
- 3:40:20controller so let me execute PHP artisan
- 3:40:24make controller
- 3:40:27user controller and this should be
- 3:40:30resource
- 3:40:31controller uh so I have to provide model
- 3:40:34to be user as
- 3:40:37well now let's see user
- 3:40:43controller Okay so so I need to list the
- 3:40:47users I need I'm not going to implement
- 3:40:50creating users from admin users we have
- 3:40:52the user registration so we don't need
- 3:40:57create we don't need store as
- 3:41:00well uh we don't want
- 3:41:03show we want edit and update to assign
- 3:41:07the rules to the user and we also don't
- 3:41:11want destroy
- 3:41:15do we yeah we don't want so our main
- 3:41:18focus is just uh roles and permissions
- 3:41:21so that admin user can manage roles and
- 3:41:23permissions if you want to allow admin
- 3:41:25users to delete other users you can do
- 3:41:27this as well and implement this part as
- 3:41:31well okay
- 3:41:32so let's return now inertia render user
- 3:41:38index and we have to provide in return
- 3:41:42um actually we can do this All users
- 3:41:45okay okay um or we can do the paginated
- 3:41:47result as well but um I don't want also
- 3:41:49to over complicate things with
- 3:41:51pagination um I feel that that's kind of
- 3:41:54out of scope of this specific
- 3:41:56tutorial and um cool so we have to
- 3:42:00Define this react file and we have to
- 3:42:04also use user
- 3:42:08resource uh well this is something else
- 3:42:11we don't want to use existing user
- 3:42:13resource collection because that user
- 3:42:16had that um resource only has ID email
- 3:42:20and name and email but we actually
- 3:42:24want the existing roles uh which only
- 3:42:28admin user should be able to see so let
- 3:42:33me do the following let's just return
- 3:42:35user all at the moment then I will come
- 3:42:38back to this so in the edit we are going
- 3:42:41to return inertia render user edit and
- 3:42:45and we want to return specific uh user
- 3:42:48and in the update yeah I will come back
- 3:42:51to this now let's open web.php
- 3:42:55and only admin user should be able to do
- 3:42:59this uh so let's define a new middle
- 3:43:05wear group right here middle we
- 3:43:10verified and roll should be
- 3:43:16rols
- 3:43:17enam
- 3:43:19admin
- 3:43:20value uh let's import this rules enum
- 3:43:25then we call
- 3:43:27group
- 3:43:29function and then Define the rules so
- 3:43:34root get for
- 3:43:38user we're going to use user
- 3:43:40[Music]
- 3:43:42controller index
- 3:43:45and we have to provide name as well
- 3:43:49user.
- 3:43:50index let's import
- 3:43:54this okay next we need update right so
- 3:43:59we're going to copy this uh get we need
- 3:44:02to get specific
- 3:44:04user
- 3:44:06user and this is going to be edit we can
- 3:44:10give it also edit URL user edit and the
- 3:44:15last one is going to be put
- 3:44:21user
- 3:44:22update and user
- 3:44:25update now let's go into resources JS
- 3:44:30pages and feature and I am going to
- 3:44:35actually copy and paste this feature
- 3:44:37folder and call this
- 3:44:43user uh I don't need need create so I'm
- 3:44:47going to delete the
- 3:44:48create I need a list of the users I
- 3:44:52need edit I don't need show as well so
- 3:44:55I'm going to delete show as well so
- 3:44:57let's open out this index and have a
- 3:45:00look so I'm going to look
- 3:45:02for features let's search for all all
- 3:45:06lowercase features and replace that with
- 3:45:11users okay
- 3:45:17then let's search for uppercase F
- 3:45:20features which is the page Title Here in
- 3:45:23here and replace this uppercase you
- 3:45:26users replace this now let's search for
- 3:45:30if we use features anywhere
- 3:45:35else we have the following
- 3:45:38permission which we actually don't need
- 3:45:41create new feature this is called
- 3:45:42feature let's search for feature this is
- 3:45:44used in 12 places we can use the match
- 3:45:48case and wording maybe we can remove
- 3:45:51this wording and just match case uh and
- 3:45:54replace this uppercase F feature with
- 3:45:57the uppercase U
- 3:45:59user let's replace this
- 3:46:05everywhere we don't have this user item
- 3:46:07after replace which we can
- 3:46:10create but I plan to actually turn this
- 3:46:13into table
- 3:46:17so uh let me just use flow flow byte
- 3:46:23table I want to just copy the table
- 3:46:27example this is simple table I just want
- 3:46:30to get the copy uh the um Talon CSS code
- 3:46:34of that and we have this users data
- 3:46:39map yeah I can completely remove this
- 3:46:46so this is TR and here we're going to
- 3:46:49use
- 3:46:50users. dat. map we have user
- 3:46:56here and then we need to return
- 3:46:59TR where is the end of TR here is the
- 3:47:02end of
- 3:47:03TR parentheses and then the curly brace
- 3:47:07and I think we can delete other two tis
- 3:47:11this and this now we have just one
- 3:47:15TR and we have the table headings that
- 3:47:19should be
- 3:47:21username that should be
- 3:47:25email we can just call this name
- 3:47:28email um we can give it created at when
- 3:47:33the user was
- 3:47:34registered and we can use roles maybe
- 3:47:40here and we probably need some
- 3:47:43actions now let's
- 3:47:48output user.name
- 3:47:55user.
- 3:47:58email user do created
- 3:48:04it and user do roles maybe which we can
- 3:48:11join with common space
- 3:48:15user doesn't have created that and also
- 3:48:19we have some syntax
- 3:48:23error uh this parenthesis ends here but
- 3:48:27this parenthesis doesn't end anywhere so
- 3:48:30we have to put this here as well now
- 3:48:33user doesn't have created yet so we need
- 3:48:38to we can remove this user item we need
- 3:48:40to open this user and we have to provide
- 3:48:46created Created it as
- 3:48:50well uh
- 3:48:53string yeah it can be string we can
- 3:48:56Define it as
- 3:48:58string okay now we have that created
- 3:49:02that as
- 3:49:02[Music]
- 3:49:07well we can remove this use page and I
- 3:49:10think that's good so user controller now
- 3:49:13let's open Authentication
- 3:49:15ated layout and we're going to find
- 3:49:19features I'm going to duplicate this and
- 3:49:23call it
- 3:49:25users then right here we need user index
- 3:49:28and let's find the second place where we
- 3:49:31have these
- 3:49:35features here and here we need user and
- 3:49:40here we need
- 3:49:41users cool let's open open the page
- 3:49:45let's click on
- 3:49:47users okay user doesn't have the right
- 3:49:52roles okay that makes perfect sense and
- 3:49:54I think even the menu should not be
- 3:49:58visible if the user doesn't have the
- 3:50:00correct role so we can use has rooll if
- 3:50:05the current user has rooll admin if it
- 3:50:08doesn't have has roll admin we can use
- 3:50:11has roll or k which checks the permit
- 3:50:15so can if current
- 3:50:18user let's import this can first then we
- 3:50:22have the current user and the permission
- 3:50:24is called manage users if the current
- 3:50:27user can manage users we display the
- 3:50:29following navigation item we're going to
- 3:50:31copy this this is for the responsive Now
- 3:50:34link we're going to search for
- 3:50:38second right here if the current user
- 3:50:41can manage users then we display the
- 3:50:44menual item okay now the current user
- 3:50:46cannot manage users so the user doesn't
- 3:50:48see users um navigation item and even
- 3:50:52the user is not able to access this
- 3:50:54through URL perfect let's log
- 3:50:57out login is
- 3:51:00admin okay what do what's going on user
- 3:51:03doesn't have the right rules
- 3:51:06okay
- 3:51:10user okay let's access dashboard
- 3:51:16now let's let's check uh am I
- 3:51:20authenticated I think I am authenticated
- 3:51:22with admin user right
- 3:51:31so H that's interesting so current
- 3:51:36user current
- 3:51:39user doesn't have user
- 3:51:42role and that's why admin user is not
- 3:51:45able to access the dashboard that's
- 3:51:48actually very interesting
- 3:51:51thing so we we have not defined that the
- 3:51:55admin user is kind of superet of other
- 3:52:01roles okay we have just roles and
- 3:52:03permissions and permissions are
- 3:52:05associated to roles in this case because
- 3:52:07the current user is admin user and
- 3:52:09current user is not doesn't have user
- 3:52:11role the current user is not not
- 3:52:15actually able to access the following
- 3:52:19page now what we can do is to Define
- 3:52:24multiple roles that the current user
- 3:52:27needs to have um one role or second or
- 3:52:31third something like this uh in the
- 3:52:34following way so here we have the RO
- 3:52:39let's move this
- 3:52:42down and I think we can
- 3:52:45use Sprint
- 3:52:48F uh
- 3:52:50roll then one R comma then we can use
- 3:52:55second R comma and third R we have
- 3:52:58actually three rols right so one is user
- 3:53:03second is commenter we can move
- 3:53:08this down as
- 3:53:11well and the last one is
- 3:53:18admin so to be able to access these
- 3:53:21roots the user should have at least one
- 3:53:24of the following
- 3:53:30rules now let's reload the
- 3:53:37page uh actually that was related to
- 3:53:40cards not roles
- 3:53:48yeah we have to use pipe not the comma
- 3:53:51the the comma is for CS so here we need
- 3:53:54pipe here we need
- 3:53:58pipe okay now admin user is able to
- 3:54:02access dashboard
- 3:54:05and uh it should be able to access
- 3:54:09to users page as
- 3:54:12well what station
- 3:54:15page not found page users
- 3:54:19index uh it is user not users so we have
- 3:54:23to open user controller and change this
- 3:54:25into user edit user index and that's
- 3:54:30it refresh
- 3:54:33it click on
- 3:54:37user okay cannot read properties of
- 3:54:40undefined reading map okay that makes
- 3:54:42sense so from here we are rning just
- 3:54:44user all and then in the index of the
- 3:54:48user we just treat that users to be
- 3:54:51paginated data meaning that it has data
- 3:54:54inside there again if you are going to
- 3:54:56do pagination you probably need that but
- 3:54:59in our case I'm just going to change
- 3:55:00this into an array of user so users is
- 3:55:04an array of user and instead
- 3:55:07of uh instead of
- 3:55:10users um. data map I'm just going to do
- 3:55:14user users.
- 3:55:16map refresh
- 3:55:20that okay this is another thing we try
- 3:55:24to call join on roles but the user
- 3:55:28doesn't have
- 3:55:30rooll uh so this is what we are going to
- 3:55:34do uh let me check
- 3:55:37out
- 3:55:39user resource here we have the
- 3:55:42permissions and rules and we probably
- 3:55:45need also created
- 3:55:48at so admin user is
- 3:55:52able basically to view more sensitive
- 3:55:55information than regular users so if if
- 3:55:59we can use this out user resource we can
- 3:56:02create new Resource as well but we can
- 3:56:04use this out user
- 3:56:06resource uh so that these
- 3:56:10users uh user all to go inside that out
- 3:56:14user resource collection provide user
- 3:56:17all here uh yeah I think that should be
- 3:56:22it however the returned response will
- 3:56:24still have data inside
- 3:56:26there users map is not a function so if
- 3:56:30we
- 3:56:31just
- 3:56:34um if we just disable
- 3:56:38WP let me
- 3:56:41think yeah we actually have the r
- 3:56:44disabled so then we probably need to
- 3:56:48access the
- 3:56:49collection and we can just return an
- 3:56:51array of
- 3:56:53that which is going to be plain array
- 3:56:56just like this and we have to add extra
- 3:57:00column which is going to be for
- 3:57:04actions just like this okay so create
- 3:57:08new user name email created at
- 3:57:15okay what do I return inside created
- 3:57:19it okay created at
- 3:57:24format
- 3:57:27this and here we see rules as
- 3:57:31well every user has some
- 3:57:36role and we can provide some additional
- 3:57:38actions like what we want here is just
- 3:57:41edit action so we can open this
- 3:57:44and put a button here or maybe we need
- 3:57:48to put a link with hre which is going to
- 3:57:51be Roots
- 3:57:53dot uh not dot but um user edit
- 3:57:59providing user we can call this
- 3:58:04edit what's wrong with
- 3:58:07that let's see we see this
- 3:58:11edit which is a
- 3:58:15we is regular link we
- 3:58:19can we can make this
- 3:58:23button but why do I hear this
- 3:58:38morning user.
- 3:58:41edit user edit
- 3:58:48where's this user
- 3:58:55edit yeah it expects user not sure
- 3:58:59what's what's wrong with
- 3:59:01that okay so when we click on this it's
- 3:59:04going to open the edit
- 3:59:09page that probably needs some pings
- 3:59:21and
- 3:59:23probably last
- 3:59:26name uh text
- 3:59:29blue 500 something like
- 3:59:33this okay clicking on this should open
- 3:59:35the edit page which we don't have right
- 3:59:38now uh let's just remove that create
- 3:59:42button because we don't want uh uh new
- 3:59:44user creation by admin users we just
- 3:59:46want ass signing roles and permissions
- 3:59:48to them so this edit should
- 3:59:52open uh this edit now let's let's have a
- 3:59:56look so here we have this feature let's
- 3:59:59again do a replace so let's search for
- 4:00:02lowercase feature and replace this with
- 4:00:05user and that's going to be probably in
- 4:00:08multiple
- 4:00:09places let's do this replace then we can
- 4:00:13search for uppercase F feature replace
- 4:00:17this with uppercase U
- 4:00:23user
- 4:00:27okay then do we have any more feature
- 4:00:30here
- 4:00:31available we don't have any more feature
- 4:00:35here so we have
- 4:00:37[Music]
- 4:00:38username uh we can duplicate this we
- 4:00:40have email
- 4:00:46we
- 4:00:47have what information do we
- 4:00:50have email verify that password I don't
- 4:00:53want to manage password or even email or
- 4:00:55anything like this what I want to manage
- 4:00:58is
- 4:00:59roles which is going to be user
- 4:01:05roles now if we scroll down below we
- 4:01:09have the
- 4:01:10description uh I think I'm going to
- 4:01:12remove this
- 4:01:17we don't need this we have just username
- 4:01:21let's see if the form
- 4:01:23opens click on edit okay the form opens
- 4:01:27we just have
- 4:01:32name we have email as well we can
- 4:01:38display so that should be disabled
- 4:01:44okay we should not be able to make
- 4:01:45changes to the name uh
- 4:01:50and we
- 4:01:52can duplicate this for
- 4:01:59email this is for
- 4:02:05email
- 4:02:08oops then we have email here we should
- 4:02:11change
- 4:02:12that let me do this very quickly is
- 4:02:14you I'm going to remove that email here
- 4:02:18and that should be disabled as
- 4:02:20well
- 4:02:22okay now we
- 4:02:24need
- 4:02:26roles now that's
- 4:02:29interesting so we need to use checkbox
- 4:02:32for this let me Define t and we do have
- 4:02:37uh checkbox component which is used
- 4:02:41somewhere probably in login so let's
- 4:02:45search for
- 4:02:46checkbox in the login this is how it is
- 4:02:50used so let me copy this open user
- 4:02:54edit paste this but I want to iterate
- 4:02:57this over user roles so user
- 4:03:02rolls.
- 4:03:04map
- 4:03:07roll I want to display checkboxes for
- 4:03:10each
- 4:03:11role but actually I don't want to to
- 4:03:13iterate over user roles but I want to
- 4:03:15iterate over all the available
- 4:03:19roles uh this is how I'm going to do
- 4:03:22this I'm going to open user controller
- 4:03:24and right here I'm going to select all
- 4:03:29roles
- 4:03:31um
- 4:03:33roll spoty permission model roll
- 4:03:37all let's cure them and return them now
- 4:03:41we have
- 4:03:44current user and we
- 4:03:47have uh we have roles as
- 4:03:51well p uh we can Define that at the
- 4:03:55moment rules has type of
- 4:03:59any and let's just print what is
- 4:04:03rules but we have syntax zos it is not
- 4:04:05going to work so we assume that roles is
- 4:04:08an array we iterate over
- 4:04:11roles and we print some some information
- 4:04:14for each Ro so we can check in the
- 4:04:16database as well rooll has name and
- 4:04:19guard name created it and update that so
- 4:04:22we just need probably
- 4:04:25name we have roll here and let's just
- 4:04:29put the
- 4:04:33checkbox
- 4:04:36unchecked um I will come back to this
- 4:04:39let me just have a visual look
- 4:04:44okay uh the role actually has a type of
- 4:04:47any again let me Define this right
- 4:04:51now console
- 4:04:56refresh okay we need
- 4:04:58um we need key and we need
- 4:05:02this
- 4:05:04here well actually I need to Define
- 4:05:09div checkbox and then I need roll. name
- 4:05:13name
- 4:05:14maybe and we need to give key roll.
- 4:05:21ID okay user commenter
- 4:05:25admin uh where we use this check
- 4:05:32box we have this label as well I'm going
- 4:05:36to copy this
- 4:05:41label and put this here
- 4:05:45and it
- 4:05:47needs key to be r.
- 4:05:51ID again let's remove
- 4:05:53this instead of remember
- 4:05:56me we
- 4:05:58need roll.
- 4:06:02name okay so we can give this
- 4:06:06one uh margin btom
- 4:06:118 Okay so that's not bad however these
- 4:06:15are just the RO names but we have the
- 4:06:17corresponding userfriendly
- 4:06:20uh Ro names so which are inside roles
- 4:06:25Anam so here it goes with uppercase a
- 4:06:28and u and commenter so you might have
- 4:06:31also more complex roles and permissions
- 4:06:34where you have uh multiple names
- 4:06:37multiple words in a name of a role and
- 4:06:40so on so we have to use these labels as
- 4:06:43well I'm going to go into user
- 4:06:46controller and from here we're going to
- 4:06:48return roll uh
- 4:06:51labels this is going to be rolls
- 4:06:55enam uh
- 4:06:58labels now we have this Ro labels which
- 4:07:01we can accept what's that user item we
- 4:07:05can remove this imated data we can
- 4:07:07remove this text are input we can remove
- 4:07:09this so right here we have R labels and
- 4:07:13again we can Define that roll
- 4:07:18labels
- 4:07:19is an array of string or we can Define
- 4:07:24record of string and
- 4:07:28string it has key value peers
- 4:07:34basically so here from this R labels we
- 4:07:39need to access R
- 4:07:41name that's going to be Ro label
- 4:07:44let's have a
- 4:07:47look now as you see we have the uh nice
- 4:07:52um
- 4:07:53labels of the permissions and if we add
- 4:07:57um this is admin as an example we can
- 4:08:03see this is admin here so this is coming
- 4:08:06from here
- 4:08:07also okay now the thing is that we have
- 4:08:10to we have to put that into data and
- 4:08:14send that to the server right
- 4:08:17so let me
- 4:08:20print data here and at the moment in the
- 4:08:26data we have array that's why it's not
- 4:08:31possible to print that so we're going to
- 4:08:32use Json
- 4:08:34stringify data undefined to
- 4:08:39oops cool email name and email only and
- 4:08:44if we check the data we have
- 4:08:47roles as well which
- 4:08:51is user roles however user roles is an
- 4:08:55area
- 4:08:56right why I don't see that user roles
- 4:08:59let me just
- 4:09:02print let's duplicate this and print
- 4:09:05user as
- 4:09:06well user one two three four yeah we
- 4:09:12don't see we don't see user roles and
- 4:09:15probably because from the user
- 4:09:17controller we are just returning this
- 4:09:19user but we should return new out user
- 4:09:23resource because this is what we are
- 4:09:25returning from the
- 4:09:27list now we are going to have roles as
- 4:09:31well and
- 4:09:32permissions and here we have roles as
- 4:09:37well
- 4:09:40okay let me check this checkbox
- 4:09:44which has value
- 4:09:50there let's go into user
- 4:09:56edit and right
- 4:10:00here uh we have to provide value to
- 4:10:05be roll
- 4:10:08dot
- 4:10:10name we have to provide checked as as
- 4:10:13well this should be
- 4:10:15checked
- 4:10:19if let me think if
- 4:10:23user. roles
- 4:10:25includes R
- 4:10:29name now refresh the
- 4:10:34page we have
- 4:10:38this okay we have the checked prop on
- 4:10:41form filled without unchain we need
- 4:10:43unchange Handler as well
- 4:10:46unchange and what we expect here
- 4:10:54event and we have to um we have to
- 4:10:58update data
- 4:11:00rules so here we have event Target
- 4:11:04checked if that specific thing is
- 4:11:07checked or not and we have to put this
- 4:11:09inside data so we're going to call set
- 4:11:12data
- 4:11:13for
- 4:11:21roles uh let me actually change this
- 4:11:24into its own function like on Roll
- 4:11:33change const on Roll
- 4:11:40change okay so we take event here let's
- 4:11:45print the event uh and print the event
- 4:11:50Target value we can provide this this is
- 4:12:01anything okay when I check something we
- 4:12:04get admin even Target value uh that's
- 4:12:11admin okay and we're going to put
- 4:12:14that uh let's also print if it's checked
- 4:12:17or not not only value but
- 4:12:21checked so click on this admin
- 4:12:24true admin true so we are trying to
- 4:12:28check
- 4:12:30that however because we have this
- 4:12:34checked uh the user
- 4:12:38roles it should be data roles includes
- 4:12:42rle name
- 4:12:46so if I remove this
- 4:12:51checked now it is get checked and
- 4:12:54checked look at this so I checked admin
- 4:12:58true then uncheck admin
- 4:13:03false uh let's actually print what we
- 4:13:07had previously Json
- 4:13:11stringify data
- 4:13:13undefined to I'm interested in the rules
- 4:13:18so we're going to put that inside
- 4:13:24rules set
- 4:13:28data
- 4:13:30roles and we're going to see if it's
- 4:13:33checked or unchecked so
- 4:13:36event
- 4:13:38Target uh checked if it's checked
- 4:13:43then we have data
- 4:13:45rules so we are going to do the
- 4:13:47following inside set
- 4:13:51data we are going to put data roles
- 4:13:56filter not filter but actually push
- 4:13:59inside data
- 4:14:01roles we are going to add new rle and
- 4:14:04this is going to be event Target
- 4:14:09value if it is not checked then we are
- 4:14:13going to remove from data roles so we
- 4:14:16are going to
- 4:14:18do data rols
- 4:14:24filter if R does not equal
- 4:14:29to event Target value basically filter
- 4:14:34everything that is not this event Target
- 4:14:39value okay and we need to destructure
- 4:14:42this
- 4:14:44and now we can have a look if I refresh
- 4:14:49it uh commenter
- 4:14:53why hold
- 4:14:57on data okay data rules contains
- 4:15:02commenter okay we need this checked to
- 4:15:05be if data
- 4:15:09roles includes r. name then we Market
- 4:15:13has
- 4:15:14checked now let's let's try
- 4:15:18to test this Okay commenter click on
- 4:15:22this now commenter was removed from rols
- 4:15:24click on this commenter was added into
- 4:15:26rols now we added admin and we edit user
- 4:15:31okay so we we can have this as checkbox
- 4:15:36and give user multiple roles but
- 4:15:38basically uh our implementation
- 4:15:44is um so that one permission actually
- 4:15:49covers another and we are mostly working
- 4:15:51with permissions not roles um on
- 4:15:55the on the router level so we only use
- 4:15:59rules right here and we use all three
- 4:16:02roles but right here we use permissions
- 4:16:04okay and generally it's good practice to
- 4:16:06work with permissions and we should have
- 4:16:08roles and permissions and the user
- 4:16:10should have roles and permissions should
- 4:16:11be part of the roles
- 4:16:14so in this case we can even switch this
- 4:16:15into radio so that that's what I'm
- 4:16:17trying to tell
- 4:16:20you user commenter or admin yeah I think
- 4:16:24we can do this so I'm going to just
- 4:16:25duplicate checkbox call this
- 4:16:31radio uh change this into
- 4:16:34radio type
- 4:16:38radio and inside this edit we can change
- 4:16:43this into
- 4:16:45radio components radio name is not
- 4:16:49remember name
- 4:16:52is
- 4:16:55rolls now
- 4:16:58let's so this looks like a radio but
- 4:17:01it's a square radio because we probably
- 4:17:05have rounded
- 4:17:10oh let's look no this looks like
- 4:17:17radio and and
- 4:17:20and let's give it also margin bottom of
- 4:17:24something like three or it's too much
- 4:17:28one
- 4:17:29oops one so now let's refresh the page
- 4:17:36now user has only one role and that's
- 4:17:38commenter now I click on
- 4:17:40admin okay that gets edit
- 4:17:45uh on Roll change okay if we decide that
- 4:17:49we're going to only
- 4:17:51have one
- 4:17:55roll to the user then if that gets
- 4:17:59checked we're going to add only that
- 4:18:02nothing
- 4:18:04else that's that's how we're going to do
- 4:18:07this we can remove this
- 4:18:11part refresh
- 4:18:14it we have one roll click on user now it
- 4:18:17has only user commenter admin and we can
- 4:18:21have only one role to the user at a
- 4:18:23given moment so this is a commentary
- 4:18:24user and we can click on admin and click
- 4:18:28on Save and now um we're going to go to
- 4:18:31the back end and see uh what information
- 4:18:34we're getting right here so
- 4:18:37request
- 4:18:41validate uh we don't actually need name
- 4:18:44or email we are interested in just roles
- 4:18:48so let's get roles is going to be
- 4:18:52required an
- 4:18:54array and let's take data and let's
- 4:18:59print what data we
- 4:19:02have so we have only admin click on Save
- 4:19:05we have roles and admin that's perfect
- 4:19:07so on the following user we can call
- 4:19:11synchr
- 4:19:12and provide data roles so basically
- 4:19:15every other rle should be removed so if
- 4:19:18we check right now uh model has roles
- 4:19:22the user we are trying to edit has id2
- 4:19:26so it has Ro two which is
- 4:19:29commenter now if we click on hold on um
- 4:19:34let's remove this DD and return
- 4:19:38back
- 4:19:41with success
- 4:19:44roles updated
- 4:19:46successfully okay I'm switching to admin
- 4:19:49click on
- 4:19:50Save rolls updated successfully and we
- 4:19:53can
- 4:19:55check right here now we see that
- 4:19:57something was changed on user which has
- 4:20:02id2 this is it now it has role three and
- 4:20:07that's awesome um now if I log out and
- 4:20:12log in
- 4:20:14with commenter
- 4:20:16[Music]
- 4:20:17role now that commenter user is not
- 4:20:19commenter anymore that user is admin and
- 4:20:22that user can actually create new
- 4:20:23features and manage other users and
- 4:20:27that's actually pretty
- 4:20:30cool okay uh in the web
- 4:20:35PHP managing
- 4:20:38users is only for admin but yes this
- 4:20:42user is able to actually see the users
- 4:20:45and click on this and let's see if the
- 4:20:50that commenter user will just change his
- 4:20:53own role into commenter
- 4:20:57again user doesn't have the right role
- 4:20:59okay something happened and that
- 4:21:01something was that probably the request
- 4:21:03was updated so the role was changed and
- 4:21:06then we were trying to go back into user
- 4:21:09page in which case we got the following
- 4:21:12error now that commenter user is still
- 4:21:14commenter and doesn't have uh admin
- 4:21:17permission to view
- 4:21:20users and that's basically it so I
- 4:21:26can remove this pre from here I can log
- 4:21:31out and I can log in as
- 4:21:35admin and see that admin user can see
- 4:21:38other users can edit and change the roll
- 4:21:43let's just put um label right here
- 4:21:47inside
- 4:21:48H3 uh
- 4:21:53roll
- 4:21:55front bold something like
- 4:21:59this yeah margin buttom
- 4:22:07one uh we have this simp label which is
- 4:22:11just a label
- 4:22:13text
- 4:22:14as yeah we can we can give it something
- 4:22:17like this as
- 4:22:22well value should be
- 4:22:24roll HTML 4 is going to be
- 4:22:29for
- 4:22:32nothing okay that's
- 4:22:35it okay now we have also implemented
- 4:22:40functionality to change roles admin
- 4:22:43users now have ability to change the
- 4:22:45roles on another
- 4:22:48users which is pretty cool so if we
- 4:22:50imagine the following case that there
- 4:22:53are some regular
- 4:22:57users um which are just up voting down
- 4:23:00voting but admin users want to promote
- 4:23:02those regular users they can open that
- 4:23:05regular user and change the role into
- 4:23:09commenter and now that regular user
- 4:23:13which previously wasn't able to leave
- 4:23:14comments now can access
- 4:23:17features and leave a comment as
- 4:23:23well that's awesome and they can also
- 4:23:25delete their own comments obviously now
- 4:23:28let's start working on inertia 2.0 new
- 4:23:32features let's open inertia
- 4:23:34documentation and here we have this
- 4:23:36version to iners js. comom and if we
- 4:23:39check the upgrade guide we see the
- 4:23:40upgrade guide as well as the new
- 4:23:42features ping prefetching deferred props
- 4:23:46infinite scrolling and theay loading
- 4:23:48data on scroll okay let's start one by
- 4:23:53one and the first one which I'm going to
- 4:23:55do is polling so that's actually pretty
- 4:23:57straightforward let let's actually
- 4:23:59implement this in our code and then we
- 4:24:00can cover the documentation as well the
- 4:24:03implementation is super easy uh first
- 4:24:05let me comment everything what uh we
- 4:24:07made so
- 4:24:09far
- 4:24:11implement
- 4:24:12users listing and Rule
- 4:24:20changing cool let's close everything and
- 4:24:24then I'm going to reopen index. TS6
- 4:24:28that's the features uh actually that's
- 4:24:31the users component we want index TSX
- 4:24:34from feature folder that's it okay and
- 4:24:37it's super easy to actually activate
- 4:24:40polling in inertia uh version two and we
- 4:24:44have to use for this use Paul so we just
- 4:24:48use use Paul hook and we provide the
- 4:24:52interval how often we want it to be
- 4:24:54updated I Believe by default this is 2
- 4:24:57seconds we can set this whatever we want
- 4:25:00um the we have to provide number of
- 4:25:02milliseconds right here and that's all
- 4:25:05so now if we open our features page we
- 4:25:08open the developer tools we check the
- 4:25:11network and we see that once in every 3
- 4:25:15second it is making requests and um
- 4:25:19performing long polling actually so if I
- 4:25:22copy this URL right now and we open um
- 4:25:26another guest right here we try to
- 4:25:29access to the features page and I'm
- 4:25:32going to use now different user user at
- 4:25:34example.com provide the password and
- 4:25:38just have a look so now here we see this
- 4:25:40is the admin user admin user is that
- 4:25:42there are three up folds and the admin
- 4:25:45user itself has up folded that now this
- 4:25:47is a regular user and regular user is
- 4:25:50clicking on this upfold now look at this
- 4:25:53what happens in couple of seconds this
- 4:25:56gets updated immediately because of the
- 4:25:59long polling we download this we see two
- 4:26:02here we're going to see two here as well
- 4:26:04so that gets updated like almost in real
- 4:26:07time and that's because of this polling
- 4:26:10now let's check the documentation of the
- 4:26:11polling
- 4:26:12usage is super easy as we saw so we can
- 4:26:15provide right here the number of
- 4:26:17milliseconds and we even can provide on
- 4:26:19start and on finished uh callbacks so we
- 4:26:24if we want to notify the user something
- 4:26:27that the data has been updated once uh
- 4:26:29it has been completed or we can even
- 4:26:31show a toast that the data polling has
- 4:26:33been started or something like this so
- 4:26:35if the operation of updating the UI is
- 4:26:38kind of expensive it takes a couple of
- 4:26:40seconds we can uh use use these hooks
- 4:26:44not the hooks but the callbacks just
- 4:26:47to update the user about this so we can
- 4:26:50also provide update start false if we
- 4:26:53don't want it to be automatically
- 4:26:54started and we can take this start and
- 4:26:57stop functions and we can bind this into
- 4:27:00buttons or into any action uh from where
- 4:27:03we can start and stop the polling so we
- 4:27:06we could put a buttons right here in the
- 4:27:08exact same way which I'm not going to do
- 4:27:10I think because this is very obvious
- 4:27:12and in the following way we could do
- 4:27:14this so I recommend to check the
- 4:27:16documentation regarding polling it's
- 4:27:18super easy to use and we are actually
- 4:27:20already using that um yeah cool now
- 4:27:24let's move on in on the next uh one
- 4:27:27which is deferred props so deferred
- 4:27:29props is another awesome thing we can
- 4:27:32see the documentation as well but the
- 4:27:34whole idea of the differred props is
- 4:27:36that if some of the props which we are
- 4:27:40going to return or the page takes a lot
- 4:27:44of time or quite some time to be fetched
- 4:27:47from the database or fetched from some
- 4:27:49external apis so we can make them as
- 4:27:54deferred and those props uh the page
- 4:27:57will be loaded without those props but
- 4:27:59those props will be added a later stage
- 4:28:02to the page now let's open a single
- 4:28:05feature this is features and now let's
- 4:28:07do the following so we're going to
- 4:28:10display the uh features itself but for
- 4:28:13the comments we are going to return it
- 4:28:15as a deferred prop okay let's try this
- 4:28:19let's open now
- 4:28:22Feature Feature controller and find a
- 4:28:26method called show and from here we have
- 4:28:29couple of things like the upvote count
- 4:28:31user has upvoted and few other things
- 4:28:33and the feature itself has access to
- 4:28:37comments we are returning this in the
- 4:28:38following way so this is what I'm going
- 4:28:40to do let's just remove these comments
- 4:28:42from this uh feature resource okay now
- 4:28:45there will be an error on the front end
- 4:28:47which we're going to fix and we're going
- 4:28:49to put those comments here but we're
- 4:28:52going to make this as deferred prop so
- 4:28:54we're going to use
- 4:28:56inertia defer let's use function here
- 4:29:01use feature and we are going to
- 4:29:07return feature comments now uh let's
- 4:29:12let's imagine that selecting these
- 4:29:13feature comments is actually heavy
- 4:29:15operation and it takes like five 10
- 4:29:18seconds okay so I'm going to use sleep
- 4:29:20here provide
- 4:29:22five and because now feature doesn't
- 4:29:24have comments and comments is a separate
- 4:29:26thing we have to update the front end as
- 4:29:28well so here we are taking now this is
- 4:29:31index we're going to open
- 4:29:34show in here we have this feature and
- 4:29:38feature has comments so we're going to
- 4:29:39search for comments and instead of
- 4:29:42feature comments we can directly access
- 4:29:44comments and we need to directly access
- 4:29:47take these comments from here as well
- 4:29:49and let's just Define the proper type
- 4:29:53feature comments is an array of comment
- 4:29:58like this okay cool uh we can also
- 4:30:01assume that feature doesn't have
- 4:30:03comments but that's not important uh
- 4:30:05right now so the result is not going to
- 4:30:09change let's have a look so we are
- 4:30:11iterating over comments we have comment
- 4:30:14and we're providing comment right here
- 4:30:17what's the
- 4:30:22error the comment
- 4:30:24item yeah it expects the comment so
- 4:30:27what's the
- 4:30:30issue the
- 4:30:32comment hold on so that's a different
- 4:30:35comment my bad so that
- 4:30:39comment should be any import from types
- 4:30:44like
- 4:30:45this and we can remove this feature
- 4:30:47right okay this is how we should have it
- 4:30:50and now if we refresh the
- 4:30:54page let's have a look now the comments
- 4:30:57doesn't exist and we have the following
- 4:30:59error which is something we're going to
- 4:31:00fix so comments at first when the page
- 4:31:03is rendered is null so it doesn't exist
- 4:31:05that's why we try to call map and it
- 4:31:08gives us simply an error so we don't
- 4:31:11need to render the following section if
- 4:31:14the comment doesn't
- 4:31:16exist which will fix the error now we
- 4:31:19refresh the
- 4:31:20page the error is
- 4:31:24gone let's wait the error is gone but
- 4:31:26the comments are not rendered and after
- 4:31:295 Seconds the comments will appear okay
- 4:31:33but if selecting comments is heavy
- 4:31:36operation which takes 5 Seconds let's
- 4:31:39say so if we don't have this as deferred
- 4:31:42prop the page rendering is delayed for 5
- 4:31:46seconds so that's the significant
- 4:31:48difference so if we select those
- 4:31:50comments right here again let's turn
- 4:31:52this out put them right here comments or
- 4:31:56we can directly return them like this
- 4:31:59and we just call sleep for 5 seconds
- 4:32:02because selecting of the comments which
- 4:32:04we we're doing right here takes 5
- 4:32:06seconds I do have some semic clone is
- 4:32:10extra so now if we refresh the page
- 4:32:12we're going to see that rendering of
- 4:32:14this page is actually delayed for 5
- 4:32:17seconds because selecting comments takes
- 4:32:18a lot of time so I'm I know I'm
- 4:32:20repeating this many times but I just
- 4:32:22want to make this very clear so let's
- 4:32:24turn turn this into defer prop and which
- 4:32:28makes the rendering of the page super
- 4:32:31super nice and fast all right let's move
- 4:32:34on the next one which is actually
- 4:32:36prefetching one of my favorite things so
- 4:32:39right now if we just open the dashboard
- 4:32:42for example we have two pages like
- 4:32:45features and users and both of them
- 4:32:48actually have um like they are selecting
- 4:32:52some data from the database right so I
- 4:32:54just refreshed the dashboard page and
- 4:32:56now if I click on features um it's
- 4:33:00really fast let's click on users it's
- 4:33:03not so fast uh let's do the
- 4:33:06following uh we probably have some error
- 4:33:09let's see
- 4:33:11let's go on the
- 4:33:15dashboard let's refresh the
- 4:33:18page click on the features that makes
- 4:33:21request it needs some time this is what
- 4:33:23I'm going to do let's change this into
- 4:33:26slow 4G for
- 4:33:29example let's go into
- 4:33:32dashboard refresh
- 4:33:36it it's low 4G now let's click on
- 4:33:39features and look at this so it is
- 4:33:41loading and finally it got loaded okay
- 4:33:45if the data is large if the uh SQL cure
- 4:33:49is heavy then it's going to take more
- 4:33:52time however in inera 2.0 there is one
- 4:33:56cool thing which is called prefetching
- 4:33:59so if we open authenticated
- 4:34:03layout and if we find this features here
- 4:34:08we see features link and we can simply
- 4:34:11add one attribute which is called
- 4:34:14prefetch and this prefetch means that
- 4:34:18when we Mouse over on this features
- 4:34:21navigation menu item it is going to
- 4:34:23prefetch the content for us okay so
- 4:34:26again I want to let's switch this into
- 4:34:30no throttling to make this fast let's
- 4:34:32remove this prefet and I'm going to make
- 4:34:34the different significant uh we can
- 4:34:37remove this sleep on the comments as
- 4:34:39well but let's put this sleep right
- 4:34:43here sleep right here directly when
- 4:34:46rendering features okay now we refresh
- 4:34:50the dashboard the dashboard Got Loaded
- 4:34:53now I click on the
- 4:34:55features and it should not be that fast
- 4:34:58because we have that was show my bad we
- 4:35:02should put this inside index cool let's
- 4:35:06go into dashboard
- 4:35:08again
- 4:35:10and click on features now it is thinking
- 4:35:14thinking thinking and after some time it
- 4:35:18got loaded right so now let's reduce
- 4:35:21this into like two seconds now if we go
- 4:35:24into authenticated layout and add this
- 4:35:27prefet here now this is what
- 4:35:31happens when we Mouse over on the
- 4:35:33features it is going to make request
- 4:35:35look at the dev tools it's is going to
- 4:35:36make request to fet those features and
- 4:35:39once we click on it it's it's going to
- 4:35:41instantly uh open that and so by Mouse
- 4:35:46overing on this inertia thinks that we
- 4:35:49want to load this and we can make this
- 4:35:51even more optimal and inside prefet we
- 4:35:54can provide um other options like
- 4:35:57whether we want to prefetch on hover or
- 4:36:01on Mount and so on so we can have a look
- 4:36:04at the uh documentation these were on
- 4:36:07the different props we can go back into
- 4:36:09prefetching and we can find in the react
- 4:36:12examples that we can provide the cash
- 4:36:15duration it is going to also cach
- 4:36:19those the prefetched pages for some time
- 4:36:23and by default it's I think 30 seconds
- 4:36:26but inside the prefetch we can provide
- 4:36:28uh click or Mount or can we can even do
- 4:36:31both so if we do these
- 4:36:35both it means the following so again if
- 4:36:38we open the dashboard
- 4:36:41so when we open the dashboard it is
- 4:36:43going to still make the request on the
- 4:36:46features Now features are already loaded
- 4:36:48even if I don't Mouse over on it once I
- 4:36:51click on this the opening is instant and
- 4:36:54that actually uh is cached for 30
- 4:36:58seconds and on Mouse over it is also
- 4:37:00fetching that information um and saving
- 4:37:03that uh for next 30 seconds and that's
- 4:37:07cool right now it uses the polling to
- 4:37:08fetch that information actually so
- 4:37:12now the features is going to open always
- 4:37:15instantly and we can do something
- 4:37:16similar on
- 4:37:20users here we have this nav link and
- 4:37:24let's add pref
- 4:37:28patch and we can provide also on Mount
- 4:37:32and hover but the users is something
- 4:37:34which um you are not going to always
- 4:37:37open so this is also a heavy thing so
- 4:37:39you don't want to uh always load the
- 4:37:43data if you don't think that user is
- 4:37:45going to open that but in this case
- 4:37:47features is the most important page of
- 4:37:48the application that's why we prefetch
- 4:37:51uh those features but not for the users
- 4:37:53for the users we can just provide the
- 4:37:55default one which is um on Hover let's
- 4:37:59go in the features and remove this sleep
- 4:38:01and now if I Mouse over on this actually
- 4:38:04I Mouse
- 4:38:07over okay now user is not loaded i m
- 4:38:09over this it got loaded right click and
- 4:38:12the uh open is actually very instant now
- 4:38:15let's go into prefetch and right here
- 4:38:18I'm going to implement something similar
- 4:38:21for each feature so if I'm Mouse overing
- 4:38:24for each feature it means that I want to
- 4:38:26open that so let's go into feature item
- 4:38:30we have
- 4:38:31this H2 inside where is that H2 inside
- 4:38:37which we have this link and let's add
- 4:38:40prefetch pre
- 4:38:42Fetch and now if I Mouse over on this
- 4:38:46look at this so it made the request uh
- 4:38:49prefetch the feature too I click on this
- 4:38:51opening is instant so let's go back
- 4:38:55let's hover on the other one prefetched
- 4:38:58feature three click on this opening is
- 4:39:01instant and just like this we are
- 4:39:03increasing the user experience like uh
- 4:39:06user is browsing the native application
- 4:39:09where the data is saved on his own
- 4:39:12computer so it's pretty fast and pretty
- 4:39:15awesome functionality I recommend to
- 4:39:17check the prefetching documentation we
- 4:39:19have this programmatic prefetching where
- 4:39:21we can prefetch on button click or on
- 4:39:24some action and we also have additional
- 4:39:26information when it was last prefetched
- 4:39:29uh we can provide the cach duration as
- 4:39:31well if it's prefetching right now if
- 4:39:34it's prefetched and so on and we can
- 4:39:37also Flash the prefet cache by through
- 4:39:40the rotor flash all to flash all the pre
- 4:39:43cach or um to flash a specific URL with
- 4:39:48the method get and with some additional
- 4:39:50data so as always I recommend to check
- 4:39:53the documentation for this but I'm going
- 4:39:55to leave these prefetching for features
- 4:39:57uh for individual feature and we
- 4:40:00probably need to do this for comments as
- 4:40:02well so if I reload right
- 4:40:06now and just have a look if I Mouse over
- 4:40:10on this comments it is not going to
- 4:40:11prefetch that particular feature so I I
- 4:40:13click on this then it makes the request
- 4:40:16and if the opening of that page is not
- 4:40:18that fast then it's going to open
- 4:40:21actually very slow so we can do
- 4:40:23something similar if we search for
- 4:40:27comments here we have that comments and
- 4:40:29we can add
- 4:40:30prefetch and we can also add something
- 4:40:33in the um profile page so we can search
- 4:40:37for profile this is the drop-down link
- 4:40:41and and we can open this drop down link
- 4:40:43from
- 4:40:45here where's that
- 4:40:49link here it is we can add
- 4:40:52additional
- 4:40:55refetch
- 4:40:57here comma as a separate prop uh and now
- 4:41:01this
- 4:41:02one accepts prefetch so we add that not
- 4:41:07for the log out but actually for
- 4:41:10profile okay that was for the desktop
- 4:41:13and I think we need to do something
- 4:41:14similar for
- 4:41:17responsive um does this responsive
- 4:41:20support
- 4:41:22prefetch prefetch okay we format this on
- 4:41:25two
- 4:41:27spaces
- 4:41:29now here we are using
- 4:41:33prefetch cool now if we refresh the
- 4:41:38page then let's clear the network then I
- 4:41:42open this drop down Mouse over on the
- 4:41:45profile
- 4:41:47uh okay why didn't
- 4:41:53prefet uh I ex yeah I took the prefet
- 4:41:56but I didn't add this here and probably
- 4:42:00I have to do something for the other nav
- 4:42:03link search for
- 4:42:06link yeah I took the prefet but have to
- 4:42:09add that here
- 4:42:12fetch so yeah this happens on Mouse over
- 4:42:15on Mouse over like you can add this
- 4:42:18pretty much to every link because if you
- 4:42:21Mouse over on something it's it has
- 4:42:24quite high probability that I'm going to
- 4:42:26click on that right so again I open this
- 4:42:31I Mouse over on this profile was fetched
- 4:42:33click on this and open is now instant
- 4:42:37the next cool feature inside in version
- 4:42:392.0 is uh laser loading data on scroll
- 4:42:42and more specifically infinite scrolling
- 4:42:45so right here we have this features and
- 4:42:46we're displaying only 10 or 15 by
- 4:42:50default and the idea is that when we
- 4:42:52scroll more features should be actually
- 4:42:55loaded however right now inertia 2.0 is
- 4:42:58still in beta and inside the
- 4:43:01documentation I couldn't find a best
- 4:43:04example uh of using this load when
- 4:43:07visible especially related to infinite
- 4:43:10scroll L okay so there are some also
- 4:43:14some articles regarding view I also
- 4:43:16tested this on vuejs and it works
- 4:43:19perfectly but on react it doesn't work
- 4:43:23perfectly and it doesn't even work at
- 4:43:26all the infinite scrolling I mean and I
- 4:43:28can demonstrate this to you so first
- 4:43:31we're going to open this feature
- 4:43:33controller and we're going to change
- 4:43:35these um this is the index we're going
- 4:43:38to change this into uh the following way
- 4:43:41so if we have a look in the
- 4:43:42documentation we're going to change this
- 4:43:43into mergeable props so if we go back
- 4:43:47lazy load on
- 4:43:49data let's search for merge U merging
- 4:43:53props right here we see that so merging
- 4:43:55props is does the following so whenever
- 4:44:00we return something inside this inertia
- 4:44:03merge the inertia will not replace the
- 4:44:07results but it will append the results
- 4:44:11okay so instead of returning this
- 4:44:14paginated result uh of the collection
- 4:44:17which has actually couple of other
- 4:44:20fields other than features in fact we
- 4:44:23can check this
- 4:44:25inside uh the index that the features is
- 4:44:31paginated data paginated data has data
- 4:44:33and links and few other things but we
- 4:44:35only declare data and links but what I
- 4:44:38want that features to be plain array of
- 4:44:41feature objects instead of paginated
- 4:44:43data so this is what I'm going to do I'm
- 4:44:45going to change these features to be
- 4:44:48just array of feature now we need to go
- 4:44:53uh let's scroll down below and the
- 4:44:54iteration should be changed as well
- 4:44:56instead of features data we should
- 4:44:58iterate feature um actually let me
- 4:45:02quickly undo these
- 4:45:05things Okay cool so uh this this is
- 4:45:08something um I mentioned does not work
- 4:45:11in react so I probably have to undo
- 4:45:14these things but I'm going to first make
- 4:45:15comments so uh
- 4:45:19Implement inertia version
- 4:45:222.0 features let's comment
- 4:45:26this and now let's redo the changes I
- 4:45:29made so iterating over features now
- 4:45:32let's open this feature controller and I
- 4:45:34want to return not the paginated result
- 4:45:38and which has data and links inside but
- 4:45:40I want to actually access the collection
- 4:45:43of it and then convert this into an
- 4:45:47array so in the following way I'm just
- 4:45:49returning features now let's save this
- 4:45:52refresh the page feature page and that
- 4:45:55should already work so if we check this
- 4:45:59uh not this one or maybe this one as
- 4:46:01well here we see the features and this
- 4:46:03is now plain array it doesn't have data
- 4:46:05and links inside now we're going to make
- 4:46:08this mergeable so I'm going to going to
- 4:46:11use inertia merge providing this
- 4:46:15here awesome now it is not going to
- 4:46:19change but now we have to implement this
- 4:46:22load when visible and when we do this
- 4:46:25the idea is the following that when we
- 4:46:26hit the bottom area it is going to make
- 4:46:29the request fetch the props and it's
- 4:46:31going to merge it into existing one for
- 4:46:34Simplicity right now I'm going to
- 4:46:36comment out the polling at the moment so
- 4:46:39the idea is the following that if scroll
- 4:46:41down below uh here we are going to use
- 4:46:45after these features we're going to use
- 4:46:47when visible component which has
- 4:46:50fallback and
- 4:46:51data and whenever this is visible
- 4:46:56whenever this gets visible so it's going
- 4:46:58to start the loading so for
- 4:47:01loading uh we are going to write some
- 4:47:05text like loading so and this is one
- 4:47:08thing that is different from the actual
- 4:47:10document mation and from the
- 4:47:11implementation so if we check the
- 4:47:13documentation right
- 4:47:15now so we are going to see inside load
- 4:47:19when visible that the fallback is
- 4:47:21actually a function which Returns the
- 4:47:25jsx but if I make this function then we
- 4:47:29have the typescript errors and if we
- 4:47:32check this load when visible actually it
- 4:47:36has these when visible props and the
- 4:47:39fallback is actually react child it is
- 4:47:42not function so I don't know what's
- 4:47:46what's the thing maybe the documentation
- 4:47:47is not updated um yeah we should
- 4:47:50consider that right now at the moment
- 4:47:52inertia version 2.0 is still in beta and
- 4:47:55that's that's probably the reason but if
- 4:47:58we have this as um react child this is
- 4:48:01okay this is going to work now the next
- 4:48:04thing is regarding this data so load
- 4:48:07when visible is actually has different
- 4:48:09purposes one of them is that whenever
- 4:48:13this component is visible load the
- 4:48:15following data okay which is not
- 4:48:17necessarily connected to infinite
- 4:48:19scrolling so in our specific case we can
- 4:48:22do when this is visible load something
- 4:48:25and that load something can be any prop
- 4:48:28of the component right but we want to
- 4:48:32implement infinite scrolling and this is
- 4:48:34done in the following way which as I
- 4:48:36mentioned works perfectly in vue.js so
- 4:48:38we have to provide params here
- 4:48:42and which the params actually should be
- 4:48:44object okay and we have to provide some
- 4:48:47data here and the data is what will be
- 4:48:50sent to the server uh when this gets
- 4:48:55visible so and because we're going to do
- 4:48:58actually like load more type of thing
- 4:49:01infinite scrolling we have to provide
- 4:49:03page so page is current Page Plus one so
- 4:49:07we actually want to load next page what
- 4:49:10is this current page that's going to be
- 4:49:12a prop right here page which actually
- 4:49:18should be number uh page should be
- 4:49:22number just like this and we should also
- 4:49:26pass that page from feature
- 4:49:28controller so here we're going to pass H
- 4:49:32which needs to be paginated from from
- 4:49:35this we need comma here so from this
- 4:49:39paginated we need to get
- 4:49:41current current
- 4:49:44page okay let's go back into index T6
- 4:49:48and we're going to pass this
- 4:49:51data okay cool and we're going to also
- 4:49:54pass some additional information like
- 4:49:57we're going to pass um
- 4:49:59preserve Reserve URL true so we don't
- 4:50:04want the URL to be updated when we load
- 4:50:07the second page or third page
- 4:50:09information so with without this
- 4:50:11preserve URL in the um true in the URL
- 4:50:15we're going to see page two three and so
- 4:50:17on so we format this and the next is
- 4:50:20that we only want to retrieve the
- 4:50:23information uh
- 4:50:25regarding
- 4:50:28features and
- 4:50:32page now the react itself is complaining
- 4:50:35that the when visible should actually
- 4:50:37have children also and if we follow the
- 4:50:40this we're going to see this right here
- 4:50:42that it requires this uh children fall
- 4:50:44back in data all of them are required
- 4:50:47but those are actually optional but this
- 4:50:49children is something what even has not
- 4:50:52been mentioned inside here children
- 4:50:56inside the documentation of inertial
- 4:50:58version 2.0 so yeah again something is
- 4:51:02kind of not finished regarding this when
- 4:51:05visible on react but now let's have a
- 4:51:07look and also I want to add one extra
- 4:51:09thing always without always whenever the
- 4:51:13browser hits and make this visible it's
- 4:51:15going to load the data and it's going to
- 4:51:17just finish it okay it's not going to do
- 4:51:19this second time or third time but by
- 4:51:21providing always here it is going to
- 4:51:24always try to load the data when this
- 4:51:27gets visible now I save this again we
- 4:51:30have this error but it's still going to
- 4:51:32work if we don't try to build
- 4:51:35that and if we reload the page right now
- 4:51:39let's refresh it
- 4:51:42okay now if you scroll down below it is
- 4:51:45going to load the second page
- 4:51:46information and it actually loaded the
- 4:51:49data but the problem is that if we hit
- 4:51:51that when again it still is sending this
- 4:51:54page to so it should actually increase
- 4:51:58that page two and it should have that uh
- 4:52:01page three page four and so on and it's
- 4:52:03actually just fetching the same
- 4:52:05information over and over again and the
- 4:52:08exact same functionality as I mentioned
- 4:52:10works perfectly in vue.js so that is
- 4:52:13something not finished and if you open
- 4:52:14this feature controller like I tried to
- 4:52:16use inera merge here as well this can be
- 4:52:20also Arrow function but that doesn't
- 4:52:23change it at all we can just turn this
- 4:52:26into Arrow function scroll up refresh
- 4:52:30it so I tried many different
- 4:52:32combinations of that scroll down below
- 4:52:34it is still two and keep scrolling it is
- 4:52:37always two we can again change this into
- 4:52:40inertia merge again use Arrow function
- 4:52:44here and return this paginated current
- 4:52:47page scroll at the very
- 4:52:50top refresh
- 4:52:54it then scroll down below page two
- 4:52:56scroll down below and it's again page
- 4:52:58two page two page two so yeah this will
- 4:53:01get probably fixed in the future and if
- 4:53:03you're watching this in the future um
- 4:53:06probably this is already fixed the
- 4:53:08implementation might be different so I
- 4:53:09recommend to the documentation and uh I
- 4:53:12hope that this video still will be
- 4:53:15helpful especially related to
- 4:53:18this uh when visible now let's talk
- 4:53:21about one of the most important part of
- 4:53:23the fullstack developer and that is
- 4:53:26deploying the project on production
- 4:53:27environment assigning domain to it and
- 4:53:30managing the server side things if you
- 4:53:33grab the VPS with hostinger this is all
- 4:53:35what we need and we probably need just
- 4:53:38to purchase the domain or if you have
- 4:53:39already existing domain or subdomain of
- 4:53:42your domain you can always connect that
- 4:53:45to your application so I previously I
- 4:53:48was actually using a single domain and I
- 4:53:50had different subdomains of this single
- 4:53:52domain to deploy my particular projects
- 4:53:55depending on your use case you can just
- 4:53:57grab a new domain or use the subdomain
- 4:53:59the main thing is that we're going to
- 4:54:00grab the VPS server and you can get this
- 4:54:03from the following place right now they
- 4:54:05have amazing sales for Black Friday and
- 4:54:09you you can just check this and grab it
- 4:54:11so this is for the uh VPS and which
- 4:54:15actually starts with the $2 per month um
- 4:54:19but this is only when we get the four
- 4:54:22year subscription okay so you can check
- 4:54:25their uh the websites uh in terms of the
- 4:54:28pricing and everything and they
- 4:54:30obviously have different tiers as well
- 4:54:33so when you grab the VPS then you're
- 4:54:35going to have something like this the
- 4:54:37VPS um hsg r. Cloud domain assigned to
- 4:54:42it and uh this is what I'm going to set
- 4:54:45up right now we're going to click on set
- 4:54:48up to set up the VPS and we have to
- 4:54:50choose the region where we want to
- 4:54:52deploy this let me choose United States
- 4:54:54click on continue and right here we have
- 4:54:57three options plain o always with panel
- 4:54:59and application and we're going to go
- 4:55:01with the application scroll down below
- 4:55:03and we're going to find this Lal version
- 4:55:06into
- 4:55:10want this click on continue then I have
- 4:55:12to provide the panel password this is
- 4:55:15the cloud panel which uh is a user
- 4:55:18interface from which we can manage uh
- 4:55:20many things regarding our server so I'm
- 4:55:23going to provide some random password
- 4:55:25which I'm going to actually um reset
- 4:55:29later so this is the random password I'm
- 4:55:31going to copy this and I'm going to
- 4:55:32click on continue and I don't want to
- 4:55:35lose this random password so I'm going
- 4:55:37to open new scratch file and put this
- 4:55:39right here
- 4:55:40okay so next we have to provide the root
- 4:55:43password and I'm going to actually
- 4:55:44provide the same root password right
- 4:55:47here that's good and we this is our host
- 4:55:50name VPS host name using which we will
- 4:55:52be able to access that in the browser
- 4:55:54right now it probably doesn't show
- 4:55:56anything and we can add the optional SSH
- 4:55:59key if you know what is SSH key I
- 4:56:01recommend to add this if you don't know
- 4:56:04no worries we can always access this um
- 4:56:07using username and password I just don't
- 4:56:09want to make is very complicated but um
- 4:56:12generally it's recommended to always
- 4:56:14generate public private keys and add
- 4:56:16your public SSH key right here so next
- 4:56:20click on continue uh let me close this
- 4:56:24and this is our overview and we're going
- 4:56:25to click on finish setup which is going
- 4:56:28to take several minutes so right here it
- 4:56:32says that it's going to take up to 10
- 4:56:34minutes but in like from my experience I
- 4:56:37have uh created many servers on hosting
- 4:56:40er uh weps servers and it actually takes
- 4:56:44much less than 10 minutes so just wait
- 4:56:47for a couple of seconds and you will
- 4:56:49receive an email when the setup is
- 4:56:53completed I just received an email that
- 4:56:55the VPS setup has been completed and
- 4:56:59right here we see this
- 4:57:0033% and if I reload this it is going to
- 4:57:04redirect us to the VPS page let's click
- 4:57:07on
- 4:57:08VPS and the IP address what we just set
- 4:57:12up is this one so we can get the
- 4:57:15actually let's click on manage and let's
- 4:57:18refresh the domain also we're going to
- 4:57:20see something yeah the domain is still
- 4:57:23in the setting up process so the VPS is
- 4:57:26done but the domain is in the setting up
- 4:57:28process so what we want is to access
- 4:57:31that um through
- 4:57:34SSH uh here we also see this Pro you w't
- 4:57:37be able to meure well okay so I an email
- 4:57:40is very strange I received an email my
- 4:57:43VPS is using Bo to let's try to access
- 4:57:46on
- 4:57:47SSH and for this I'm going to use um we
- 4:57:52can use Powershell or gitbash I
- 4:57:55generally prefer to use G bash so I'm
- 4:57:57going to open that let's zoom in SSH
- 4:58:01root at we have to provide the IP
- 4:58:05address uh we have to type yes here and
- 4:58:09then we have to provide the root
- 4:58:10password and this is the password what
- 4:58:13we assigned to it click on paste hit the
- 4:58:16enter and we we are able to access to
- 4:58:19the server and
- 4:58:23now let's see what folders and files we
- 4:58:27have in home so inside home we have
- 4:58:30Ubuntu and user that user is the user
- 4:58:34inside which the default LL installation
- 4:58:38will be so we need to authenticate as
- 4:58:41the user and make some changes in the
- 4:58:44project so I'm going to use Sue Das
- 4:58:48user and right now I am authenticated as
- 4:58:51user previously I was
- 4:58:54root so if we now navigate inside HG
- 4:58:57docs this is the place where the project
- 4:58:59is installed and if we type LS we're
- 4:59:02going to see the following domain and
- 4:59:04this is actually a folder so inside that
- 4:59:07folder we have the Lal installation
- 4:59:10and this is the default lateral
- 4:59:12installation which comes with our
- 4:59:14project but this is what we are going to
- 4:59:16do I'm going to actually uh delete
- 4:59:20everything from the following folder
- 4:59:22actually we need to navigate inside
- 4:59:24there and let me delete everything or
- 4:59:26maybe we can just make sure that it
- 4:59:28works first no the domain is still in
- 4:59:32the setting up process if you want you
- 4:59:34can wait this for few more minutes and
- 4:59:37the domain will got activated and then
- 4:59:41when you refresh you're going to see
- 4:59:42latest installed LEL version but I want
- 4:59:46to see my LEL project inside there so
- 4:59:51I'm going to copy now uh my GitHub
- 4:59:55project URL here is my project
- 4:59:57repository which is a private repository
- 5:00:00so if it's public things are a little
- 5:00:01bit easy you can directly clone that
- 5:00:04into the VPS server but because this is
- 5:00:07private repository we have to generate
- 5:00:09public private keys on the server add
- 5:00:12public key on this repository so that
- 5:00:15the server has permission to access to
- 5:00:18the GitHub server and clone that
- 5:00:21repository okay so this is what we're
- 5:00:24going to do let's go into the server and
- 5:00:29before I delete everything in the
- 5:00:31following folder let me actually
- 5:00:33generate public private Keys you can
- 5:00:36just
- 5:00:37Google SSH key
- 5:00:40generate and the very first thing is
- 5:00:43going to be probably what we need if we
- 5:00:45scroll down below generate new SSH key
- 5:00:48and this is the commment we're going to
- 5:00:50execute on the server I'm going to copy
- 5:00:52this go to the server paste that and
- 5:00:55we're going to change the email that's
- 5:00:58actually um identifier of your SSH key
- 5:01:02but very common thing is just to provide
- 5:01:05our email address so here is my email
- 5:01:09address let's hit the enter now this is
- 5:01:12the default location where the public
- 5:01:14private keys will be generated under
- 5:01:16home user SS folder we're going to hit
- 5:01:19enter as for the passphrase I'm going to
- 5:01:22leave this empty so hit the
- 5:01:24enter hit the enter again and the key
- 5:01:27was generated and that is now located
- 5:01:30under SSH folder in my home directory so
- 5:01:33using cut command I can access this SSH
- 5:01:37folder ID Ed whatever do pbpb is the
- 5:01:43public file without PB it's a private
- 5:01:46file so we're going to open this pub
- 5:01:48file and this is actually the uh public
- 5:01:53key so we're going to copy that and we
- 5:01:56are going to open our repository go into
- 5:02:00settings scroll down below and we need
- 5:02:03deploy keys and add deploy key so we're
- 5:02:07going to paste this and we can provide
- 5:02:09this
- 5:02:10hostinger VPS server as a title you can
- 5:02:14name it whatever you want and we can
- 5:02:16also give it optionally write access so
- 5:02:18that VPS server will be able to push
- 5:02:21something on the following
- 5:02:24repository okay I have to approve this
- 5:02:27using my two Factor authentication
- 5:02:30through GitHub
- 5:02:31[Music]
- 5:02:34mobile okay it didn't work sometimes it
- 5:02:36doesn't work so let me provide my
- 5:02:38password
- 5:02:40okay here we go so we added this deploy
- 5:02:43key and now that server is actually able
- 5:02:47to clone the repository uh right here on
- 5:02:50the following folder now let's check
- 5:02:52this one last time if it was set up no
- 5:02:54this is still in the progress no problem
- 5:02:56let's delete everything from the
- 5:02:58following folder rm-rf or maybe we can
- 5:03:02just move everything into another folder
- 5:03:05so here we have just one folder let me
- 5:03:08copy the name of that
- 5:03:11and we're going to move everything into
- 5:03:14a different folder called TMP okay and
- 5:03:17then I'm going to execute git clone here
- 5:03:20I have to provide the repository name
- 5:03:23and then I'm going to provide it right
- 5:03:26now and then I have to provide the local
- 5:03:28folder name inside which I want to clone
- 5:03:31the repository and the local folder name
- 5:03:34is going to be that this server name
- 5:03:37this one okay now let's get the
- 5:03:40repository URL to clone it locally and
- 5:03:43we're going to use SSH URL copy that and
- 5:03:47we have to provide it here so clone the
- 5:03:52following repository in the following
- 5:03:54folder finally let's hit the enter we
- 5:03:57have to type yes here and look at this
- 5:04:00so it was cloned and now we see the
- 5:04:04following folder this is the old project
- 5:04:06which comes with a VPS and this is what
- 5:04:09we cloned now let's navigate into this
- 5:04:13SRV and first let's copy en example
- 5:04:19into and then we need to execute
- 5:04:21composer
- 5:04:23install now it went ahead and install
- 5:04:27all the packages that was actually done
- 5:04:30now let's execute PHP Artisan migrate by
- 5:04:34default this is using SQ light and we
- 5:04:37can leave this or we can switch it into
- 5:04:39my ql uh if you want so I'm just going
- 5:04:42to type yes migrations have been applied
- 5:04:46let's check this in the browser it is
- 5:04:48still in the finishing and we have to
- 5:04:51unfortunately wait for this or we can
- 5:04:53check this in the Incognito and have a
- 5:04:55look no we have to wait for
- 5:04:58that meanwhile we can try to access
- 5:05:02panel through the following uh URL so we
- 5:05:06just click this because we don't have
- 5:05:08the domain assigned to it so it tells us
- 5:05:11the connection is not private we just
- 5:05:13click to Advanced we're going to
- 5:05:15proceed and we have to provide admin and
- 5:05:19the password what we gave to it now we
- 5:05:23click on login and we are on the server
- 5:05:25let me switch to dark mode and here we
- 5:05:27have just one site and this is our site
- 5:05:30we can obviously add more sites if we
- 5:05:33need so if we click on that then we have
- 5:05:36a lot of options so we have the uh
- 5:05:39domain related settings and the path
- 5:05:41where the project installed user related
- 5:05:44settings PHP related settings I'm going
- 5:05:46to switch into PHP
- 5:05:488.3 and from here you can control the
- 5:05:52most common things let's click on Save
- 5:05:55uh we have the virtual host related
- 5:05:57thing here we have this domain and SSL
- 5:06:00certificate path and this is engin
- 5:06:03config we have the database section
- 5:06:05which is something we need to work on
- 5:06:08I'm going to click on database and you
- 5:06:10can call this whatever you want I'm
- 5:06:11going to call this just test database
- 5:06:13username test and this is the user
- 5:06:17password I'm going to copy this add
- 5:06:19database the database has been created
- 5:06:23now we can open Terminal our VPS server
- 5:06:26and we can type Vim or do we have Nano
- 5:06:30Nano is easier to use Nano that's it so
- 5:06:34here we have this application name this
- 5:06:36is our enan now let's scroll down below
- 5:06:39and find the database related things
- 5:06:43here we have the DB connection and we
- 5:06:44can change this into MySQL so now let's
- 5:06:48uncomment the host Port database
- 5:06:51username and password and the
- 5:06:54database is test the username is test
- 5:06:59the password is what we what we copied
- 5:07:04but I lost that for some reason so I
- 5:07:08have to delete that
- 5:07:10database user has been deleted let's
- 5:07:12delete the database as well and a new
- 5:07:16database let's give it test
- 5:07:19test get that a
- 5:07:23database now let's paste
- 5:07:26here and the port and the host is
- 5:07:28actually the default one so we're going
- 5:07:30to leave this now hit contrl and O enter
- 5:07:34contrl and X we we have to reexecute
- 5:07:37migrations so
- 5:07:40PHP
- 5:07:41Artisan Artisan migrate hit the enter
- 5:07:45now the migrations have been applied in
- 5:07:47the myql
- 5:07:48database and now let's check the domain
- 5:07:51again it is still not working so what do
- 5:07:55we have in this Cloud panel we have this
- 5:07:57varnish cache we have this TLS and SSL
- 5:08:00and we see that the following
- 5:08:04domain it is actually not installed so
- 5:08:08let's click on install
- 5:08:10certificate has been installed so this
- 5:08:12is self signed certificate which has one
- 5:08:15year okay
- 5:08:19now okay after some time I installed let
- 5:08:23encrypt certificate back and now I'm
- 5:08:26going to um if it's if it's not possible
- 5:08:29to delete the self-signed I'm going to
- 5:08:32just leave that but the application
- 5:08:33actually started working so we don't
- 5:08:36just don't have this encryption key uh
- 5:08:38specified so we're going to execute PHP
- 5:08:41Artisan uh key generate
- 5:08:45d-i hit the enter application key set
- 5:08:48successfully and if we refresh this now
- 5:08:51we see the following error which is very
- 5:08:53common we don't have the V config file
- 5:08:56and we have two options one we have to
- 5:08:58execute npm run Dev which is generally
- 5:09:00recommended for locally or we have to
- 5:09:03execute mpm run build which is for
- 5:09:05production and which is what we are
- 5:09:07going to do however we don't have mpm
- 5:09:11command installed on this VPS server and
- 5:09:14this is what we are going to do next
- 5:09:17let's open nodejs.org
- 5:09:21download let's actually access the main
- 5:09:23page click on download and then in the
- 5:09:26package manager we are going to click on
- 5:09:28The Following last link package
- 5:09:37managers and what I'm meing interested
- 5:09:40is Debian and Ubunto based Linux
- 5:09:45distributions and we're going to click
- 5:09:47on this this is going to open the GitHub
- 5:09:49link no Source SL distributions and if
- 5:09:53we scroll down below we're going to find
- 5:09:55this Ubuntu
- 5:09:57versions and here we have that so
- 5:09:59depending on which version we want to
- 5:10:02install just check it the LTS version is
- 5:10:05right now 22 so under node.js 22
- 5:10:09I'm going to execute the following code
- 5:10:13first we're going to install
- 5:10:15curl I'm going to paste this hit the
- 5:10:18enter we have to provide the root
- 5:10:21password which I have right here so I'm
- 5:10:24going to paste hit the
- 5:10:27enter uh my bad right now we are
- 5:10:29authenticated as a user but we want to
- 5:10:32install nodejs we must install node.js
- 5:10:35as root user so I'm going to type exit
- 5:10:38now I'm auth indicated as root user and
- 5:10:41I'm going to
- 5:10:43execute the following
- 5:10:46command paste hit the enter okay that
- 5:10:51was completed crl was actually already
- 5:10:53installed now let's execute the second
- 5:10:58command that has been completed as well
- 5:11:02now let's
- 5:11:04follow to read me
- 5:11:09so we have copied and executed this and
- 5:11:12the first the last one is to install the
- 5:11:15node js so I'm going to copy
- 5:11:19this and as soon as this is completed we
- 5:11:22are going to paste the sud sudo op get
- 5:11:25install Dy
- 5:11:29nodejs okay so this has been completed
- 5:11:31we can type node DV we see version 22
- 5:11:35and we can type mpmv and we see this as
- 5:11:38well now now we need to authenticate
- 5:11:41back as user so
- 5:11:43su- user now let's go into HD do folder
- 5:11:48and
- 5:11:49SRV uh whatever is the domain name so
- 5:11:53right here we need to execute mpm
- 5:11:57install and then mpm run
- 5:12:01build now this is building typescript V
- 5:12:04build and V build uh with SSR and right
- 5:12:08here we have the following error and we
- 5:12:11have to fix this error locally push it
- 5:12:13and then we have to pull on the server
- 5:12:16so let's close this and reexecute mpm
- 5:12:19run build on a local environment and see
- 5:12:23if we have the same error we do have the
- 5:12:26same error and which is coming from
- 5:12:28property rows is missing in type ID
- 5:12:32class name value and so on so we're
- 5:12:35going to open html text area let's open
- 5:12:38this
- 5:12:41uh
- 5:12:43create then we have here this text area
- 5:12:47and the rose
- 5:12:49row is missing right here it seems
- 5:13:00like Okay so let's just provide rules
- 5:13:04equals
- 5:13:06six we save that
- 5:13:09um then we execute mpm run
- 5:13:14build so that if that builds we don't
- 5:13:18have any more
- 5:13:19errors now we have to comit
- 5:13:22this fix using text
- 5:13:29area we have to push
- 5:13:32that then we have to open the VPS server
- 5:13:37and we have to execute G pool
- 5:13:40to grab the changes what we just made
- 5:13:43and then we execute mpm run
- 5:13:46build let me clear this up mpm run build
- 5:13:51we hit the enter now it's going to
- 5:13:55build
- 5:13:59everything and finally we can check the
- 5:14:01result in the
- 5:14:03browser and we have the application up
- 5:14:05and running so we have to probably
- 5:14:08execute migrations with seed command PHP
- 5:14:12Artisan
- 5:14:14migrate D-
- 5:14:17seed uh actually let's provide
- 5:14:21migrate fres d d
- 5:14:25seed okay now refresh the database and
- 5:14:28let's try to log in with admin
- 5:14:31example.com provide the password and
- 5:14:35here we go so we are authenticated as
- 5:14:37admin user we can click on features we
- 5:14:39see that this is actually super fast
- 5:14:42very smooth uh we have the prefetching
- 5:14:44as well it's like immediate a thing so
- 5:14:48we can click on this one it's going to
- 5:14:50open scroll down below leave a
- 5:14:55comment we can see the comment right
- 5:14:57here another
- 5:15:01comment okay now we can up vote this
- 5:15:04down vote this so this is awesome now
- 5:15:09let's talk about server side rendering
- 5:15:11so far we have single page application
- 5:15:14everything is working everything seems
- 5:15:16to be good but the whole idea of the
- 5:15:18server side rendering is that the actual
- 5:15:21content is rendered on the server side
- 5:15:23so we have different server uh inertia
- 5:15:26server running node.js server which
- 5:15:28renders the react components on the
- 5:15:31server s side and serves that and we are
- 5:15:33going to have much better ACO
- 5:15:36capabilities on our website or or in any
- 5:15:39project basically where we are going to
- 5:15:41use this react with server side
- 5:15:43rendering right now if we check check
- 5:15:46the page Source let's grab the title or
- 5:15:51part of the title and if we search this
- 5:15:53on the page we're going to see that this
- 5:15:55is used only once and this is the
- 5:15:59entire uh large JavaScript object which
- 5:16:04is bound to that page okay so the only
- 5:16:08place where that title is mentioned is
- 5:16:10that JavaScript part which is bound to
- 5:16:13the component this is not right now
- 5:16:16serers side rendered content to make
- 5:16:18this server side rendered content from
- 5:16:21inside our folder basically we're going
- 5:16:24to execute PHP Artisan
- 5:16:28inertia start SSR this is going to start
- 5:16:31server side rendering server on the
- 5:16:34following Port but the port doesn't
- 5:16:36matter uh the main thing is that if we
- 5:16:39right now refresh that so the content
- 5:16:42right now is served from the server and
- 5:16:44it's again very fast and if we open this
- 5:16:48on the page source and if we search the
- 5:16:50same title actually this is the title
- 5:16:54now we see that it is used in four
- 5:16:56places now this is the place where it
- 5:16:59was used previously but additionally we
- 5:17:02have now this already rendered inside B
- 5:17:05tag inside
- 5:17:07H2 so let me use the horizontal scroll
- 5:17:11we see that feature inside B tag we have
- 5:17:15that information additionally we have
- 5:17:18that inside h2 tag so we have that
- 5:17:23here check this
- 5:17:26here
- 5:17:27here additionally it is inside the title
- 5:17:31tag of the browser so here if we Mouse
- 5:17:35over on the
- 5:17:36title we're going to see that here is as
- 5:17:39well and then the last one is inside
- 5:17:41that uh JavaScript object and just like
- 5:17:44this we have now this server side
- 5:17:46rendered however that is not enough so
- 5:17:48we just started this manually but we
- 5:17:51want this to be automatically started
- 5:17:53and supervised as well for this we're
- 5:17:56going to set up the supervisor so let's
- 5:17:58open
- 5:18:00laravel
- 5:18:02supervisor and we have this probably
- 5:18:05inside cues and if we search for super
- 5:18:08visor
- 5:18:09configuration this is what we are going
- 5:18:12to do but this example is for cues we're
- 5:18:16going to change this into our um command
- 5:18:19which is inertia start SSR let's close
- 5:18:23this and let me copy the following
- 5:18:25common to install the supervisor paste
- 5:18:29actually we have to we are again user
- 5:18:33but we have to exit to be root now we
- 5:18:36are root paste the following Comm
- 5:18:40command paste copy paste hit the enter
- 5:18:45supervisor will be installed let's
- 5:18:47scroll down below and then we have to do
- 5:18:50the following configuration so we have
- 5:18:52to create new file on the following
- 5:18:54directory we can call this whatever we
- 5:18:56want just make sure that it has this
- 5:18:58conf extension okay so the supervisor
- 5:19:02got installed let's
- 5:19:04again now login as user go to HT
- 5:19:09docks uh or first we have to do this as
- 5:19:13root user my bad let's exit
- 5:19:16again so let's navigate into the
- 5:19:18following folder so
- 5:19:20CD supervisor comt in here we don't have
- 5:19:25any files at the moment and we have to
- 5:19:27create new file and we have to copy the
- 5:19:29following common to put that inside the
- 5:19:33file let's define the file and call
- 5:19:36these um
- 5:19:40LEL serid rendering
- 5:19:44docon the extension should be Doc let's
- 5:19:47hit the enter now I'm going to paste the
- 5:19:50following command and we have to modify
- 5:19:53a few things so the program is the name
- 5:19:55and let's call this laravel
- 5:19:59SSR SSR and square
- 5:20:02bracket then we are going to leave the
- 5:20:04process name which is the program name
- 5:20:08um then in so right here we have to
- 5:20:11adjust the path the path is where our
- 5:20:14application is installed so this is
- 5:20:17inside
- 5:20:18home
- 5:20:20user
- 5:20:22slht dox and then we have to use this
- 5:20:26domain name so we can get that
- 5:20:28information from the cloud panel as well
- 5:20:32inside um that was inside V hosts
- 5:20:35probably or right here so that is the
- 5:20:39path where the application is also
- 5:20:43installed and then we can actually
- 5:20:46delete this
- 5:20:48completely paste that and then inside
- 5:20:50that project we have Artisan
- 5:20:54comment next there's this Q worker
- 5:20:57example which we don't need we just need
- 5:20:59inertia start so we provide
- 5:21:03inertia
- 5:21:05inera colum start
- 5:21:09D SSR this is the command we started
- 5:21:12manually so we have to provide auto
- 5:21:14start Auto restart stop his group stop
- 5:21:18okay we can leave everything for the
- 5:21:20user we're going to provide user number
- 5:21:23of processes we can set this to one and
- 5:21:27we have to provide also the log file
- 5:21:29where all logs is going to be saved and
- 5:21:32let's do the
- 5:21:35following I'm going to paste
- 5:21:40the
- 5:21:44path home user HT docs the path and
- 5:21:49inside here or maybe outside here inside
- 5:21:52HT docs we can give it the following
- 5:21:56name let's copy the domain
- 5:21:59name paste. log okay now we're going to
- 5:22:04save that I used VM so I have to type
- 5:22:06escape on the keyboard then colon then W
- 5:22:10and Q on the keyboard hit the enter that
- 5:22:13was saved you can also use Nano to um
- 5:22:18create the same
- 5:22:19file okay now we have that file saved
- 5:22:22and if we check the
- 5:22:24documentation we have to reread this new
- 5:22:29file so we have to execute the following
- 5:22:31commment hit the enter that was
- 5:22:35available now the second common
- 5:22:39that was
- 5:22:42added and instead of Lal worker we have
- 5:22:46to give it name laral SSR we hit the
- 5:22:51enter uh I believe that was already
- 5:22:54started and now if we check the page
- 5:22:56Source refresh
- 5:23:00that now we see that this is used in
- 5:23:03four places so the server side rendering
- 5:23:07is active running and even if we restart
- 5:23:11the server it is going to start
- 5:23:12automatically and it's going to server
- 5:23:14side render the content and the
- 5:23:19pages here we have the um like I don't
- 5:23:23see the common to actually stop a
- 5:23:27supervisor but probably in the similar
- 5:23:30way we executed start Lal SSR we can
- 5:23:34execute stop Lal SSR we hit the enter
- 5:23:39that was stopped and now if we check the
- 5:23:41page
- 5:23:42Source now we see this only once server
- 5:23:45side rendering is off so we have to
- 5:23:49execute start again server side
- 5:23:52rendering is started and we have that
- 5:23:56title used in four places that's
- 5:24:01awesome and we can navigate on the
- 5:24:03website and we see that this is super
- 5:24:05fast it's it's it's using the uh rebuild
- 5:24:09um react components we can edit that
- 5:24:13user try to give it another role click
- 5:24:16on save that got updated and we got
- 5:24:19actually great user experience in the uh
- 5:24:24in the
- 5:24:26browser now let's try to assign custom
- 5:24:29domain to that so in the hosting or AG
- 5:24:33panel you can go to domain section you
- 5:24:35can always get the new domain from here
- 5:24:38you just type your domain name choose
- 5:24:40the extension you want you can search if
- 5:24:42it's available or not and you can get
- 5:24:44the domain for as low as $1 or $2 and I
- 5:24:49have used actually that so in my
- 5:24:52specific case I actually have one of the
- 5:24:55existing uh domains free domains
- 5:24:57available so I'm going to click on claim
- 5:25:00domain uh but the flow whether you're
- 5:25:03going to purchase the domain or just get
- 5:25:05the claim domain uh what I have right
- 5:25:07now doesn't change so I'm going to use
- 5:25:10domain like larar rea.com check the
- 5:25:14availability that is available awesome
- 5:25:17let's click on claim
- 5:25:19domain and I have the domain right here
- 5:25:23so this is my personal contact details
- 5:25:26which generally uh you have to feel if
- 5:25:31you're purchasing the domain very first
- 5:25:33time in hostinger so this is going to be
- 5:25:35blurred out because um I don't want to
- 5:25:37reveal my personal information regarding
- 5:25:39the phone number or anything so but you
- 5:25:42have to feel this information if you're
- 5:25:44purchasing the domain very first time
- 5:25:46then we're going to click on this finish
- 5:25:47registration it is registering the
- 5:25:50domain once it is done we have to
- 5:25:53connect the domain to the VPS
- 5:25:56server it's going to take a few seconds
- 5:25:58okay the domain is ready let's click on
- 5:26:03continue uh even when it is ready it
- 5:26:06might take few seconds meaning
- 5:26:09need uh let's check my
- 5:26:12domains
- 5:26:14Lara Lara react okay that looks like to
- 5:26:18be active let's click on the
- 5:26:22domain Okay order not
- 5:26:25found it might take
- 5:26:29few minutes until the domain actually
- 5:26:31gets fully activated so let's click on L
- 5:26:35react again now we have this domain over
- 5:26:38view we're going to click on this DNS
- 5:26:40and name servers and we have to adjust
- 5:26:44that domain actually if we copy the
- 5:26:47domain L react let's open this in the
- 5:26:50browser Lara rea.com
- 5:26:55yeah we have this SSL Error which is
- 5:26:58okay not a big deal uh but we have to
- 5:27:01associate now the VPS server um IP
- 5:27:05address to that domain okay let's go
- 5:27:09back into home into
- 5:27:12VPS
- 5:27:14and I think this is the one what we just
- 5:27:17set up we're going to copy the IP
- 5:27:19address and go into domain
- 5:27:22portfolio we have to find the domain
- 5:27:25what we just
- 5:27:28purchased L react click on
- 5:27:31manage uh click on DNS and name
- 5:27:35servers
- 5:27:36and right here we have the following a
- 5:27:39record which we have to remove but again
- 5:27:42we can check this before remove just to
- 5:27:45make sure that um it is finally
- 5:27:48available that's it it's available and
- 5:27:50it is uh pointing to the following
- 5:27:53server which we have to remove so we are
- 5:27:56removing this a record and we are going
- 5:27:59to add new a record that domain points
- 5:28:02to the following IP address and that IP
- 5:28:05address is our VPS server IP address DNS
- 5:28:10record created successfully awesome next
- 5:28:13we're going to open the VPS
- 5:28:16server what we just created click on
- 5:28:20manage then I'm going to go into DNS
- 5:28:22manager and right here we have to assign
- 5:28:24the domain to that VPS server let's give
- 5:28:27it Lara rea.com let's click on
- 5:28:33add the domain was detected that it's in
- 5:28:36my account and that we can that that was
- 5:28:39actually added we can go into domain
- 5:28:42dashboard and from here we can manage
- 5:28:44the specific domain not renew but manage
- 5:28:47in terms of the DNS things what we have
- 5:28:49already done so we have cname www which
- 5:28:52is for this lar rea.com and we have this
- 5:28:57um the root domain which points to the
- 5:29:00following IP address next let's go into
- 5:29:03vhost file and we're going to add our
- 5:29:06new domain into the server name name so
- 5:29:09this is lar rea.com and we can also add
- 5:29:14www Lara rea.com we're going to copy
- 5:29:18both of them and there are second usage
- 5:29:22this is for Port at which is without
- 5:29:25SSL um if we scroll down below actually
- 5:29:29so this is for p port at and with SSL as
- 5:29:33well um but if we scroll down below here
- 5:29:35we have the server name used in the
- 5:29:37second place place and we have to add
- 5:29:39this L rea.com with the www as well now
- 5:29:43let's click on Save which is going to to
- 5:29:47the vhost has been so that that's going
- 5:29:49to do the reload of the vhost and now if
- 5:29:52we go into SSL TLS click on new let's
- 5:29:56encrypt certificate and then add domain
- 5:30:00L rea.com click on Create and install
- 5:30:05Okay certificate has been installed and
- 5:30:08now let's open lara.com and we see our
- 5:30:12application up and running on SSL so we
- 5:30:16can authenticate now admin at
- 5:30:18example.com we can provide some
- 5:30:21password okay and we are actually
- 5:30:24authenticated we can navigate on our
- 5:30:27custom domain so because we assigned no
- 5:30:30custom domain to the application we have
- 5:30:33to change the en file as well I was
- 5:30:36actually logged out from the SSH session
- 5:30:39so we have to relog in SSH root at and
- 5:30:43right here instead of IP address right
- 5:30:45now we can provide the domain L rea.com
- 5:30:48we hit the enter we have to we have to
- 5:30:51first type yes here to accept the
- 5:30:53fingerprint and then we're going to copy
- 5:30:56the root password provide it here hit
- 5:31:00the enter we have an authenticated on
- 5:31:02the server let's now authenticate as
- 5:31:04user and navigate into HD Docs and here
- 5:31:08we have the project now we get into SRV
- 5:31:11folder and let's open let's use Nano do
- 5:31:17file we hit the enter and the
- 5:31:20application name is something we can
- 5:31:21leave we can change we create a test
- 5:31:23application so I don't care about the
- 5:31:25application name the an environment
- 5:31:27basically should always be changed into
- 5:31:30production when we deploy the
- 5:31:31application to production we're going to
- 5:31:33change the debug mode into false or we
- 5:31:37can leave the time Zone and we're going
- 5:31:38to change the application URL into
- 5:31:41https
- 5:31:43Lara rea.com
- 5:31:48okay if you scroll down below if you
- 5:31:51haven't actually working SMTP
- 5:31:54credentials you can find this mailing
- 5:32:00section where is it here it is so mail
- 5:32:03mailer and you have to provide the SMTP
- 5:32:05right here provide the host port
- 5:32:07username password of your SMTP server
- 5:32:10and it's going to actually start sending
- 5:32:12emails now let's save that if you don't
- 5:32:15like the following domain name and also
- 5:32:18the folder name is the following domain
- 5:32:20name we can also change this and let's
- 5:32:23give it Lara react. comom however we
- 5:32:27have to move the project into the
- 5:32:30following location
- 5:32:33so let me open this SSH and I'm going to
- 5:32:37go back and we're going to execute move
- 5:32:41SRV into l
- 5:32:44rea.com
- 5:32:46so that's going to be the new folder
- 5:32:48name inside which we're going to have
- 5:32:49our LEL project so we did this uh we did
- 5:32:55that let's click on
- 5:32:57Save however there is one additional
- 5:32:59thing to do I'm going to hit on exit
- 5:33:02here and clear this up and we're going
- 5:33:04to actually go into the supervisor
- 5:33:07location we we have the supervisor
- 5:33:08config let me have a look in the history
- 5:33:13this is inside Etc supervisor DC so
- 5:33:16we're going to navigate into the
- 5:33:18following folder oops I have cd twice so
- 5:33:23here we are let's clear this up and have
- 5:33:26a look so we have only one file now
- 5:33:29let's open this
- 5:33:33Nano and let's have a look so this is
- 5:33:36right now the location which needs to be
- 5:33:37changed okay
- 5:33:40so let's come
- 5:33:42here change into L rea.com let's come
- 5:33:48here as
- 5:33:50well and we're going to change that log
- 5:33:53file into Lara rea.com
- 5:33:58dolog so we save this then we have to
- 5:34:02execute supervisor CTL reread to read
- 5:34:06the new config file
- 5:34:08I actually rerun this so I see no config
- 5:34:10updates to processes but you're going to
- 5:34:12see that um it uh something was changed
- 5:34:16okay so here we need to execute
- 5:34:20updates after this we need to execute
- 5:34:23supervisor
- 5:34:25CTL stop and we have to provide the uh
- 5:34:28service name so ll- SSR colum and
- 5:34:34asterisk hit the enter it got stopped
- 5:34:37and then we have to provide start we hit
- 5:34:41the enter it got started now if we check
- 5:34:45that in the
- 5:34:46browser we are going to see BL rea.com
- 5:34:50so the applications up and running we're
- 5:34:54navigating click on this we can copy the
- 5:34:57title and
- 5:34:59view the page source and we're going to
- 5:35:02see that this is used in four places
- 5:35:04this is server side rendered content
- 5:35:07actually and just like this we change
- 5:35:09the name the location where the
- 5:35:11application is located and that's
- 5:35:13actually pretty useful if you plan to
- 5:35:16have multiple projects in on this VPS
- 5:35:19server if we right now navigate into as
- 5:35:24login as user and then go inside HG dos
- 5:35:29here we see L rea.com we can remove uh
- 5:35:35TMP completely remove remove D
- 5:35:39rfmp and we can also remove this SRV log
- 5:35:43file we can leave the SK ignore uh and
- 5:35:47just like this we have just lara.com and
- 5:35:50you can add new projects in the
- 5:35:53following folder with your own domains
- 5:35:56and then you can just assign different
- 5:35:58domains or subdomains to that project
- 5:36:01this is pretty awesome now let's see one
- 5:36:04of the coolest part of the deployment
- 5:36:06and which is automat deployment through
- 5:36:08GitHub actions for this I just created a
- 5:36:12new yml file inside GitHub workflows
- 5:36:17folder you can name this whatever you
- 5:36:19want I call this hostinger deploy yml
- 5:36:22and it has the following synx you can
- 5:36:24get the following yml in from the
- 5:36:26project repository under GitHub
- 5:36:28workflows folder and now let's explain
- 5:36:31this so here you give the name again
- 5:36:32whatever you want to this and now this
- 5:36:35is the event so we're listening on push
- 5:36:38on the following branches so here inside
- 5:36:41on you can actually listen to multiple
- 5:36:44events like there is support for a
- 5:36:47release when the new release is made uh
- 5:36:50then we can trigger something okay but
- 5:36:53right now we are only listening to push
- 5:36:55events on the main branch and these are
- 5:36:57actually jobs that will be executed we
- 5:37:00have only one job so this is going to
- 5:37:02run so whenever we push something on the
- 5:37:05main branch GitHub will spin up the uh
- 5:37:10Runner server and this Runner server
- 5:37:13everything right here happens on the
- 5:37:15Runner server that Runner will take the
- 5:37:18latest buun okay so it is going to have
- 5:37:22um the following steps to set up so this
- 5:37:25is just the name and the action what
- 5:37:26should happen this action will use this
- 5:37:29actions checkout version two that is
- 5:37:31actually necessary thing for this GitHub
- 5:37:33actions Runner and then we're going to
- 5:37:35use the following image to set up PHP
- 5:37:39and we specify that we want version
- 5:37:428.3 then we're going to set up the
- 5:37:44node.js this is just name and with the
- 5:37:46following action and we use node version
- 5:37:4922 next we are going to do some things
- 5:37:52on that Runner server okay on that
- 5:37:55Runner server we're going to make sure
- 5:37:57that the application is actually started
- 5:38:00at least okay so we create this file
- 5:38:05through just copying en example into Yan
- 5:38:09we're going to execute composer install
- 5:38:10with the following Flex to install the
- 5:38:12dependencies we're going to execute PHP
- 5:38:14Artisan key generate to generate the
- 5:38:16application key we're going to also
- 5:38:18storage the link now we're going to
- 5:38:20execute the migrations mpm install we're
- 5:38:24going now execute mpm run build and
- 5:38:27right here we have this interesting step
- 5:38:29which is PHP Artisan test we haven't
- 5:38:31written any tests but if you have uh
- 5:38:34written tests for your application you
- 5:38:36want to run this
- 5:38:38so we are B basically setting up the
- 5:38:40entire project on GitHub Runner server
- 5:38:42and finally running test just to make
- 5:38:46sure that everything runs before it is
- 5:38:49deployed on the
- 5:38:51server so one if that success uh
- 5:38:55succeeds then we're going to deploy that
- 5:38:57to the server for this we're going to
- 5:38:59use the following SSH action image H
- 5:39:02which has the following variables
- 5:39:05additional variables so we need uh some
- 5:39:09host username port and key to
- 5:39:12authenticate to the server and GitHub
- 5:39:15Runner server needs to authenticate on
- 5:39:19our hostinger server so GitHub Runner
- 5:39:22server needs to connect to the server to
- 5:39:25be able to execute some uh commands
- 5:39:28right here and for this when the
- 5:39:30connection happens with the following uh
- 5:39:33variables then the following scripts
- 5:39:35should be executed
- 5:39:37okay now imagine the
- 5:39:40following whenever the hostinger
- 5:39:43whenever the GitHub Runner server
- 5:39:45authenticates on the server as regular
- 5:39:48user not as root as regular user the
- 5:39:51GitHub Runner server uh will access the
- 5:39:55users's home directory so this is going
- 5:39:57to be the state for the GitHub Runner
- 5:40:00server then the following steps will be
- 5:40:02executed so this will
- 5:40:05happen then this will
- 5:40:08happen so we are already on the main
- 5:40:11bran so that doesn't do anything so
- 5:40:13we're going to execute git pool which is
- 5:40:15going to pull the latest main branch
- 5:40:18right now we don't have anything but
- 5:40:19when there is new push on the main
- 5:40:21branch what we are listening to
- 5:40:24obviously there will be something to
- 5:40:25pull then it's going to execute composer
- 5:40:28install mpm C mpm run build and so on
- 5:40:31and finally it is going to execute a PHP
- 5:40:34Artisan inertia toop SSR this stop SSR
- 5:40:38is necessary to just stop the server
- 5:40:40side rendering server which will be
- 5:40:41automatically started using supervisor
- 5:40:44and once we have that information this
- 5:40:47is all what you need for automatic
- 5:40:49deployment now we have to take care of
- 5:40:53this variables which is coming from
- 5:40:54these secrets the secrets is
- 5:40:57actually
- 5:40:59um let me open the GitHub the secrets is
- 5:41:02a variable is a container inside the
- 5:41:05repository so this is the Repository
- 5:41:08we're going to go into
- 5:41:10settings we need
- 5:41:13actions uh sorry we need secrets and
- 5:41:15variables and click on actions and right
- 5:41:18here we have to add those secret
- 5:41:20variables which are described right here
- 5:41:23so let's add them one after another so
- 5:41:27the first one is SSH host which is going
- 5:41:31to be in our case Lara react Lara
- 5:41:35rea.com so this this is the host on
- 5:41:38which this should connect the GitHub
- 5:41:40Runner server should
- 5:41:42connect okay head
- 5:41:45secret
- 5:41:47next is going to be SSH username which
- 5:41:50is going to be a regular user our user
- 5:41:53is called user so we're going to provide
- 5:41:56user here if your buntu user would be
- 5:41:59called zoraa you would write zoraa here
- 5:42:03add
- 5:42:04secret then we have
- 5:42:08Port SSH
- 5:42:10port and the port is actually
- 5:42:1422 the default SSH Port is always 22 and
- 5:42:18when we don't provide when we try to
- 5:42:20authenticate and when we don't provide
- 5:42:22that it means it is
- 5:42:2422 uh next is the SSH key and this is
- 5:42:28the mo most interesting part so let's
- 5:42:32put this and what we're going to put
- 5:42:34right here so the GitHub Runner server
- 5:42:38we mentioned that needs to talk to the
- 5:42:40our VPS server to be able to connect it
- 5:42:43and execute some scripts right there for
- 5:42:46this there are two types of
- 5:42:48authentication with password or without
- 5:42:51password but through SSH keys so we are
- 5:42:54going to do this authentication through
- 5:42:56SSH keys because we cannot actually
- 5:42:58enter the password uh the password needs
- 5:43:01to be entered when we try to
- 5:43:04authenticate and let me just demonstrate
- 5:43:07at this to you I'm going to log out so
- 5:43:10this is my gitbash server and right now
- 5:43:13I want to authenticate so I execute SSH
- 5:43:16root at larar rea.com hit the enter and
- 5:43:20now it asks me password but if I
- 5:43:22Implement public key authentication it
- 5:43:24will not ask me password and I will be
- 5:43:26authenticated immediately now let's try
- 5:43:29to authenticate with password and I'm
- 5:43:32going to change this as
- 5:43:34well cool now let's go into
- 5:43:37user let's execute su- user and inside
- 5:43:41user I'm going to navigate into SSH
- 5:43:44folder and check what F files we have we
- 5:43:48are interested inside authorized Keys
- 5:43:51okay I'm going
- 5:43:53to now open these authorized Keys which
- 5:43:57is empty at the moment and this is what
- 5:44:00I'm going to do next let's open another
- 5:44:03gitbash server terminal which is my
- 5:44:06local terminal
- 5:44:07okay and I'm going to take my public key
- 5:44:11from my home directory SSH ID whatever.
- 5:44:16PP so this is my public key I'm going to
- 5:44:19take this copy that and paste this
- 5:44:24here yeah so we save this and now by
- 5:44:29providing my personal public key to this
- 5:44:33regular user inside authorized Keys file
- 5:44:37this means that um that server now gives
- 5:44:42me access to it without password and if
- 5:44:46I exit right now two times and I want to
- 5:44:50authenticate using SSH I'm going to use
- 5:44:53SSH I'm going to use right now regular
- 5:44:56user because I added that SSH key inside
- 5:44:59regular user user at larar rea.com we
- 5:45:04hit the
- 5:45:05enter and voila we have been
- 5:45:08authenticated for regular user I'm
- 5:45:10already regular user okay and we have to
- 5:45:14do something similar but we have to do
- 5:45:17this now for GitHub Runner server and
- 5:45:20that SSH key right here should be
- 5:45:22private key because I was able to
- 5:45:26authenticate uh with this public key the
- 5:45:28only reason for that is that I actually
- 5:45:32have public sorry I actually have
- 5:45:35private key here so this is my private
- 5:45:37key which is actually secret and I'm not
- 5:45:39going to show this to you but this is my
- 5:45:41private key and this is the public key
- 5:45:44and when I executed SSH command SSH just
- 5:45:48checked what was my private key used
- 5:45:50that private key for the authentication
- 5:45:53validated that private key with the
- 5:45:55public key which I eded inside
- 5:45:57authorized Keys file on the server and
- 5:46:00they matched and thus I was able to
- 5:46:03authenticate now I'm going to close this
- 5:46:06and this is what we we are going to do
- 5:46:08we already have public private Keys
- 5:46:10generated right here so this is the
- 5:46:12private key this is the public key so
- 5:46:16what we need to do is just take this
- 5:46:18private key and put it right
- 5:46:23here now let's do this cut
- 5:46:27ID this is the private key I'm going to
- 5:46:30take
- 5:46:33this and put it here
- 5:46:40next I am going to take the this is the
- 5:46:43private key which we put right here but
- 5:46:45we need its corresponding public key its
- 5:46:48corresponding public key is this so
- 5:46:50we're going to take that public key cut
- 5:46:58that and we're going to put that public
- 5:47:01key right here inside authorized
- 5:47:04keys cut actually we should use Nano
- 5:47:08inside authorized
- 5:47:10Keys
- 5:47:12paste
- 5:47:16oops uh save no I don't want to make
- 5:47:20up uh I copied something else so this is
- 5:47:25what we need to copy then we open this
- 5:47:29and paste it and now we have two public
- 5:47:33Keys added this is for my personal
- 5:47:36computer and and this is for uh GitHub
- 5:47:39Runner so I'm going to save and quit
- 5:47:43also one thing to make this fully clear
- 5:47:46is that we used the same public key to
- 5:47:49add to the GitHub under deploy keys so
- 5:47:54and that actually is not a bad idea so
- 5:47:58we use the same private key here and the
- 5:48:02same public key in two places so this
- 5:48:05private key is right here on the server
- 5:48:08and its corresponding public key is
- 5:48:10added inside deploy Keys which means
- 5:48:12that this server is able to communicate
- 5:48:16to the following
- 5:48:19project but we also have that SSH
- 5:48:23key which is the following private key
- 5:48:26and the public key added inside
- 5:48:28authorized Keys which means that the
- 5:48:30GitHub Runner server is able to
- 5:48:33authenticate to This Server so this
- 5:48:36private key is actually secret you
- 5:48:37should not tell it to anyone um I'm
- 5:48:40going to actually delete this after the
- 5:48:42video but yeah if it's secret um so
- 5:48:46that's why we have that put that in into
- 5:48:48secret
- 5:48:49variables okay now it's time to test our
- 5:48:52workflows so I'm going to comment
- 5:48:54everything actually I have only one
- 5:48:56change add GitHub
- 5:49:01work
- 5:49:03workflows Okay click on comment
- 5:49:07we're going to push
- 5:49:09this on the
- 5:49:11server and now let's
- 5:49:14check inside
- 5:49:17actions as we see the actions has was
- 5:49:20started the GitHub workflow click on
- 5:49:23this we're going to click on
- 5:49:26build and now let's see so setting up
- 5:49:29job has been done check out code has
- 5:49:31been completed setup PHP was actually
- 5:49:34also completed setup no JS completed and
- 5:49:37it's following and doing
- 5:49:40everything so that was run first on the
- 5:49:43GitHub Runner
- 5:49:44server no JS dependencies building
- 5:49:48assets if building is failing for some
- 5:49:51reason uh because of the typescript it
- 5:49:53is the deploy will not
- 5:49:55happen Okay building assets and here we
- 5:49:59have this problem so run tests the tests
- 5:50:02have been actually failed and
- 5:50:05we uh we can see which test was actually
- 5:50:08failed so this is the test that was
- 5:50:11failed this was failed and we actually
- 5:50:15because we haven't taken care of the
- 5:50:17test I think we just need to comment out
- 5:50:20this part but if you are actually
- 5:50:23building the real application and if you
- 5:50:24have tests up and running you should
- 5:50:26obviously fix the tests so let's comment
- 5:50:29out this
- 5:50:32part remove
- 5:50:35tests click on com
- 5:50:37comit push that was failed the entire
- 5:50:41job so now let's click on actions new
- 5:50:44started with a comment message remove
- 5:50:49tests and we are going to
- 5:50:52wait now the job has been completed and
- 5:50:55we're going to check the following
- 5:50:58part look at this so install no JS
- 5:51:01dependencies building assets that was
- 5:51:04completed the tests were removed and now
- 5:51:06this is the deploy PHP to server so we
- 5:51:10just authenticated to the server and
- 5:51:13then we we are already on Main Branch um
- 5:51:16because we performed the checkout on
- 5:51:18Main then pull happened and the
- 5:51:22following thing was downloaded and then
- 5:51:24we installed all the dependencies
- 5:51:26everything was executed here composer
- 5:51:28install mpm run
- 5:51:31build and finally that was all related
- 5:51:34to build and finally the cash has been
- 5:51:37cleared uh and finally the inertia
- 5:51:40server um stopped and because of the
- 5:51:43inertia server stopped uh supervisor
- 5:51:46catched that and automatically restarted
- 5:51:48this so now if we check our project we
- 5:51:51are going to see that the um server side
- 5:51:54rendering is still working as it should
- 5:52:00work
- 5:52:02oops here we see that in four places
- 5:52:05okay but everything um happened as it
- 5:52:10should happen and we have fully up and
- 5:52:13running project with um roles
- 5:52:17permissions login registration
- 5:52:20everything the only thing what I haven't
- 5:52:21done is the production ready SMTP
- 5:52:25credentials which you can just Google
- 5:52:28how to take these and put this in the
- 5:52:30project I think that's the um that's
- 5:52:33very easy part but we have fully working
- 5:52:35service rendered application up and
- 5:52:37running and deployed on the server and
- 5:52:40if you watch this video so far please
- 5:52:42please hit the like button and subscribe
- 5:52:45if you are not yet subscribed to the
- 5:52:47Channel all right my friends that's it
- 5:52:49for this video and I hope you learn
- 5:52:51something new if you want more tutorials
- 5:52:54like this please hit the like button and
- 5:52:56subscribe because without your support I
- 5:52:59can continue like this because uh the
- 5:53:02videos the projects on which I spent one
- 5:53:05month of work doesn't get that many
- 5:53:07views or engagement that's probably my
- 5:53:09fault if you are not interested in such
- 5:53:12types of projects okay I have to just
- 5:53:14switch to a different direction but if
- 5:53:16you like it don't forget to hit the like
- 5:53:19button and provide a nice comment as
- 5:53:21well if you don't want to provide a nice
- 5:53:23comment just leave a comment and tell me
- 5:53:25what's wrong with the video because I
- 5:53:27want to also improve and provide more
- 5:53:30valuable content in the future if you
- 5:53:32don't like such long videos feel free to
- 5:53:34let me know about this as well if you
- 5:53:36watch this till the end probably you'll
- 5:53:39like long videos but anyway just give me
- 5:53:42your feedback uh in the comment section
- 5:53:44down below all right thanks for watching
- 5:53:47and I will see you in the next video
About this transcript
This page contains the full transcript of Build and Deploy Laravel 11 + React Full Stack App - TypeScript, Inertia v2, SSR, Permissions by The Codeholic, generated from the public captions YouTube serves with the video. The transcript has 45,584 words across 6,951 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.