YouTube2Text

Build and Deploy Laravel 11 + React Full Stack App - TypeScript, Inertia v2, SSR, Permissions — Transcript

by The Codeholic · 45,584 words · 6,951 segments · language en · Watch on YouTube

Full transcript

  1. 0:00in this video you're going to see how to
  2. 0:02create fullstack application with Lal 11
  3. 0:05inera version 2.0 with react typescript
  4. 0:08and server side rendering how to use
  5. 0:11spot's roles and permissions package to
  6. 0:14implement three different roles and
  7. 0:16finally how to deploy the project on VPS
  8. 0:19server on custom domain and set up
  9. 0:22GitHub actions as well whenever we push
  10. 0:25something on the main branch it is going
  11. 0:26to be deployed automatically on the VPS
  12. 0:29server and we also have up and running
  13. 0:31SSR on VPS server so the entire react
  14. 0:34application is serers side rendering
  15. 0:37which gives you great SEO capabilities
  16. 0:40now let's have a look at the demo of the
  17. 0:42project the idea of the entire
  18. 0:44application is to create new features
  19. 0:47and then the other users will have
  20. 0:49ability to upload or download the
  21. 0:51feature or leave comments on the
  22. 0:54specific feature what they like about
  23. 0:56the feature whether they want to
  24. 0:57implement for the project or not we have
  25. 1:00three roles inside the application admin
  26. 1:03role commenter role and the user role
  27. 1:07admin users are able to create new
  28. 1:10features and to also assign roles change
  29. 1:13roles for the users commentary users are
  30. 1:17able to leave comments on the features
  31. 1:20and regular users are only able to
  32. 1:23upvote or downvote the feature and of
  33. 1:26course admin user role covers the
  34. 1:28commenter role in the regular user role
  35. 1:31and also commenter role covers regular
  36. 1:34user role meaning that commenter users
  37. 1:36can also upvote and downvote to be able
  38. 1:40to authenticate on the website and to up
  39. 1:43Vote or downvote or do anything you need
  40. 1:46to First
  41. 1:48register we're going to go into register
  42. 1:50page the registration requires the email
  43. 1:54verification as well and right now I'm
  44. 1:56using local mail pit server which we're
  45. 1:59going to also learn how to set up
  46. 2:00locally on the following Port without
  47. 2:02Docker so we don't uh do this with a
  48. 2:05Docker so here I'm going to provide some
  49. 2:08name John John example.com we hit the
  50. 2:12enter now we have to verify our email
  51. 2:15let's open mail pit we received an email
  52. 2:17click on this email verification has
  53. 2:20been completed now let's reload the page
  54. 2:23and after the email verification we say
  55. 2:26the dashboard the dashboard is basically
  56. 2:27a dumy page it doesn't display anything
  57. 2:30this is just default Lal pre dashboard
  58. 2:32we are we are interested in features but
  59. 2:35pay attention to one thing this is a
  60. 2:38regular user and because it is a regular
  61. 2:40user it doesn't see users menu item so
  62. 2:43that happens through roles and
  63. 2:45permissions if we click on features we
  64. 2:48also don't see right here create new
  65. 2:51feature and if we click on comments this
  66. 2:54user is not also able to leave a comment
  67. 2:57the user can read the comment can can
  68. 3:00browse these features and can check
  69. 3:02every other feature and can do up vot on
  70. 3:05the specific feature but they cannot do
  71. 3:09anything else rather than up Vote or
  72. 3:11downvote that specific feature that is
  73. 3:15um to just make that working we have to
  74. 3:20authenticate as admin user then admin
  75. 3:23user can go into users and find John
  76. 3:27here edit John Give It Up admin
  77. 3:30permission click on Save and then when
  78. 3:34join will authenticate on the
  79. 3:37server JN will see users right here
  80. 3:40features JN can also create new feature
  81. 3:43provide the name and description of the
  82. 3:44feature and just like this um John can
  83. 3:48also edit the feature or delete the
  84. 3:50feature which is the Privileges only for
  85. 3:52the admin users and John right now is
  86. 3:55the admin user for the entire
  87. 3:57application we're going to use laravel
  88. 3:59and react with typescript we're going to
  89. 4:01learn how to define types and how to use
  90. 4:03the inertia version 2.0 several great
  91. 4:06features such as for example deferred
  92. 4:08props when we open the page first the
  93. 4:10content of the feature is loaded and
  94. 4:12then the comments are loaded it we also
  95. 4:15have the prefetching when we click on
  96. 4:17this it's going to the content is
  97. 4:19actually already prefetched and loaded
  98. 4:21for the users as well so the navigation
  99. 4:24between these pages is super smooth
  100. 4:26there are several other great features
  101. 4:28of iner 2.0 and we're going to see all
  102. 4:30of them how we can use and the main
  103. 4:34thing is that the application also uses
  104. 4:37serers side rendering if we click on a
  105. 4:39specific item specific feature so this
  106. 4:43is rendered with react but with the help
  107. 4:46of service side rendering we this is
  108. 4:50actually fully SEO friendly let me show
  109. 4:53you what I mean we have the application
  110. 4:55started with PHP Artisan serve and we
  111. 4:58also have mpm run Dev up and running for
  112. 5:01the react and asset building and right
  113. 5:04now serice side rendering is not active
  114. 5:06so if I copy the following title right
  115. 5:09click on this and search for uh view
  116. 5:12page Source The View page Source will
  117. 5:15display the content like search engines
  118. 5:17will see the content and if we search
  119. 5:20for the following text we see that this
  120. 5:22is used only one place and that place
  121. 5:25actually is the only place uh where the
  122. 5:30inertia pushes puts that data for the
  123. 5:33react okay however we have that content
  124. 5:37used in uh several places like one's
  125. 5:40here second here but we don't see this
  126. 5:44right here on two places because all
  127. 5:46that content here and here is generated
  128. 5:49on the client side and we don't see this
  129. 5:52in the page source to fix that we're
  130. 5:56going to see everything every single
  131. 5:57detail of that but we're going to
  132. 5:59execute mpm run build for this and then
  133. 6:03we're going to start inertia server by
  134. 6:05executing PHP Artisan inertia start SSR
  135. 6:08just make sure that mpm run build is
  136. 6:11fully completed when we execute inera
  137. 6:13start SSR now once the inera SSR server
  138. 6:17is started we're going to refresh the
  139. 6:20page now this is fully serers side
  140. 6:22rendered content and if we open that
  141. 6:25page we can copy the title again view
  142. 6:29page
  143. 6:31Source search for that and now we see
  144. 6:33this in four places one is inside the
  145. 6:36browser's head tag inside title second
  146. 6:40is inside this content we provided
  147. 6:42through inertia and we also have this
  148. 6:44inside h2 tag which is the following
  149. 6:48area and we also have this in another h2
  150. 6:51tag which is the following area and just
  151. 6:54like this now every page on the
  152. 6:56following website is fully server side
  153. 6:59rendered and finally we're going to
  154. 7:02learn how to set up the project on a
  155. 7:04custom domain L
  156. 7:07react. hit the enter and this is where
  157. 7:09we have our application deployed we can
  158. 7:12authenticate with the same
  159. 7:14user and we're going to see all the
  160. 7:16features users we can edit the users and
  161. 7:20do pretty much everything so I'm not
  162. 7:21going to bother you just explaining the
  163. 7:24same things building such types of
  164. 7:26projects require a lot of time and
  165. 7:28energy I have to plan the project then
  166. 7:31create it once and then I have to create
  167. 7:33it second time for recording then
  168. 7:35editing and so on if the project excites
  169. 7:38you single best thing what you can do
  170. 7:40right now is to hit the like And
  171. 7:42subscribe
  172. 7:43button okay there are two things you
  173. 7:46need to do the project covers how to
  174. 7:48create fullstack application with LL and
  175. 7:50react but the project doesn't cover very
  176. 7:53basics of LEL if you don't know what is
  177. 7:57LEL or how to create very simple applic
  178. 7:59with LL on its own then I recommend to
  179. 8:02check my course LL for beginners which
  180. 8:05is for absolute beginners as well as for
  181. 8:08kind of the people who is already
  182. 8:10familiar with Lal and want to just
  183. 8:12remember a few things and refresh their
  184. 8:15Lal skills that is a course complete
  185. 8:17course which covers which has 300 videos
  186. 8:2024 hours of content it has a quizzes
  187. 8:23challenges it has certificate of
  188. 8:25completion and it gives you basically
  189. 8:27the whole knowledge you need to create
  190. 8:29the project from start to finish and
  191. 8:31during the course we're going to also
  192. 8:32deploy the project on VPS server if
  193. 8:35you're interested check the website the
  194. 8:37cod.com you will find my course right
  195. 8:39there the course also includes written
  196. 8:41notes for every lesson and you can also
  197. 8:43get the PDF which is kind of 400 page
  198. 8:46PDF for the entire course that's almost
  199. 8:50like a written version of the entire
  200. 8:52course from time to time I get emails
  201. 8:55from my subscribers that they want to
  202. 8:57enroll on this course but they cannot
  203. 8:59for this and asking me to give them
  204. 9:02access to the course for free um I want
  205. 9:04to help to as many people as possible
  206. 9:07but obviously I cannot give this course
  207. 9:09for free for everyone uh but because I
  208. 9:12want to do something for such type of
  209. 9:15students who cannot really afford this
  210. 9:17but genuinely want to enroll in this
  211. 9:19course and start learning LEL so this is
  212. 9:22what I decided in every video I'm going
  213. 9:24to generate one or two 100% coupon codes
  214. 9:27for my Lal 4 beginers course and it's
  215. 9:31addon which is a PDF file as well and
  216. 9:33I'm going to put those coupon codes in
  217. 9:36my YouTube videos you can get this and
  218. 9:39you can access the course for free in
  219. 9:41this specific video there are two such
  220. 9:43type of coupon codes 100% coupon codes
  221. 9:45for Lal 4 beginners course and for the
  222. 9:48PDF as well not for the other course
  223. 9:50which is for Lal e-commerce website
  224. 9:52course not for the other one but for
  225. 9:54beginners and for the PDF uh and the
  226. 9:57coupon code actually has the following
  227. 9:59format so it's a 16 character coupon
  228. 10:02code and it is one coupon code it is
  229. 10:06splitted into two parts the first eight
  230. 10:08characters and the second eight
  231. 10:10characters so totally during this video
  232. 10:14there are four places uh where you will
  233. 10:17find the parts for those coupon codes so
  234. 10:21one place contains the first part of the
  235. 10:23C coupon code second place contains the
  236. 10:25um second part of the first coupon code
  237. 10:27and so when you get the idea you you're
  238. 10:29going to also see on the screen the
  239. 10:31format how you're going to find that
  240. 10:33small note on screen that basically is a
  241. 10:37indicator that's a part of the coupon
  242. 10:39code so and just like this if you really
  243. 10:42want that course you're going to go
  244. 10:44through the video find those parts of
  245. 10:46the coupon code and you can get this
  246. 10:48coupon code for free but I also
  247. 10:50encourage you to if you don't need if
  248. 10:52you can afford this course don't take
  249. 10:54this opportunity from others who cannot
  250. 10:57really afford such types of courses and
  251. 11:01uh genuinely want to learn it that's all
  252. 11:03what I want to say so good luck whoever
  253. 11:05is going to take that coupon codes and I
  254. 11:07will be genuinely happy and yes one more
  255. 11:09thing whenever you find the coupon code
  256. 11:11please send me a DM on Twitter on EX
  257. 11:14because I want to announce whoever is
  258. 11:16going to win this I want to announce
  259. 11:18this on Twitter so that others know that
  260. 11:21all coupon codes are already revealed
  261. 11:23and used okay please let me know in the
  262. 11:27comment section or on Twitter send me a
  263. 11:29DM that you found the coupon code at the
  264. 11:32end of this project as I mentioned we're
  265. 11:34going to deploy the project on VPS
  266. 11:35server with custom domain as a choice of
  267. 11:38the hosting provider we're going to use
  268. 11:40hostinger which is very kindly
  269. 11:42sponsoring this video hostinger is one
  270. 11:45of the best hosting providers out there
  271. 11:48offering you a lot of different kinds of
  272. 11:50Hosting services such as shared hosting
  273. 11:53VPS hosting email hosting Cloud hosting
  274. 11:56and so on I personally have been using
  275. 11:58hostinger for p three years and I'm
  276. 12:01extremely happy with your services and
  277. 12:03and I actually moved all my websites
  278. 12:05from different other hosting provider
  279. 12:08into the hostinger sometimes I use
  280. 12:10shared hosting sometimes I use VPS
  281. 12:12hosting depending on the use cases if
  282. 12:14you're application is very simple I
  283. 12:16recommend sheared hosting if you don't
  284. 12:18want some background jobs running as
  285. 12:20well I recommend sheared hosting in this
  286. 12:22specific case we want inertia server up
  287. 12:25and running so we're going to choose VPS
  288. 12:27hosting just go to the website hosting
  289. 12:29er.com theod holic and right now they
  290. 12:32have amazing Black Friday sales so just
  291. 12:35go to the hosting section and click on
  292. 12:37VPS hosting the hosting actually starts
  293. 12:39with $6 per month uh you can find all
  294. 12:42the available options what is right
  295. 12:44there so this $5 it starts with a $5 per
  296. 12:47month but that is the price actually is
  297. 12:50only for if you grab it for 24 months
  298. 12:53plan you can choose whichever version
  299. 12:56you want here you have the resources of
  300. 12:58the VPS server let's click on the most
  301. 13:01popular one right here you can choose
  302. 13:03this period 12 months or 24 months as I
  303. 13:06mention the best deal you're going to
  304. 13:08get if you choose this for uh 24 months
  305. 13:11and uh just make sure if you decide to
  306. 13:14grab the hosting use a coupon code the
  307. 13:15code holic which will give you extra 10%
  308. 13:19off on already quite great price if you
  309. 13:23decide to grab the hosting just click on
  310. 13:25continue then you have to fill up your
  311. 13:27cred card details and at the end of this
  312. 13:29tutorial when we see how we can deploy
  313. 13:32the project you can use the following
  314. 13:34VPS server um for the tutorial
  315. 13:38$129 for 24 months for the server which
  316. 13:42has eight gigs of RAM two CPUs 8 uh
  317. 13:46terabyte bandwidth and 100 of gigabyte
  318. 13:48of NVM dis space I think it's pretty
  319. 13:51good deal and the deal doesn't last uh
  320. 13:54so long because it's right now it's a
  321. 13:56for Black Friday so I recommend just get
  322. 13:58it right now if you plan to deploy
  323. 14:00something on the VPS server go to the
  324. 14:02website hostinger.com theod holic or
  325. 14:04click on the very first link in the
  326. 14:06video description and thank you
  327. 14:08hostinger for sponsoring this video and
  328. 14:10supporting my channel for quite some
  329. 14:11time already now we can start building
  330. 14:14this project all right my friends now we
  331. 14:16can start working on the project and
  332. 14:18first let's just make sure we have
  333. 14:20correct Lal development environment
  334. 14:23setup locally so if you don't have any
  335. 14:26environment setup locally I generally
  336. 14:28prefer lot heard and this is what I
  337. 14:30recommend it is available on Windows and
  338. 14:33on Mac OS if you have your preferred
  339. 14:36development environment for LL you can
  340. 14:39stick with that whether this is zamp or
  341. 14:41this is Docker Just go with it if you
  342. 14:43feel comfortable in it okay in case of
  343. 14:46Lal her if you don't know so this is
  344. 14:49actually one program which provides PHP
  345. 14:52engine server nodejs and pretty much
  346. 14:54everything what you need to get started
  347. 14:56creating your Lal projects so from this
  348. 14:58interface you can actually install PHP
  349. 15:00versions from the dashboard you can
  350. 15:02switch between between different PHP
  351. 15:04versions you can install nodejs and so
  352. 15:07on and by default this is free but there
  353. 15:10are a couple of pro features available
  354. 15:12which we are not going to actually use
  355. 15:14okay we're going to go with SQ light
  356. 15:17which is actually uh available with Lal
  357. 15:19herd but in the Pro features you also
  358. 15:21have MySQL if you want so and if we go
  359. 15:23in the dashboard and click this open
  360. 15:25sides this going to open second window
  361. 15:27and right here we have all the pro
  362. 15:29projects and what I'm going to do
  363. 15:30actually is to create new project but
  364. 15:34not from the interface however you can
  365. 15:36do this from the interface as well just
  366. 15:38if you click this added button and
  367. 15:40choose the new larel project click on
  368. 15:42next choose the uh starter key and just
  369. 15:45follow this wizard you can actually do
  370. 15:47this but I'm going to do this through
  371. 15:49terminal actually this is the same
  372. 15:53folder I want to name to my project so
  373. 15:55I'm going to actually delete this site
  374. 15:57just created this uh when I was actually
  375. 16:00testing okay that was deleted let's
  376. 16:02close Lal her this one as well and let's
  377. 16:05now open Terminal here it goes and let's
  378. 16:09go inside Lal her folder and right here
  379. 16:13we have those projects and let's create
  380. 16:15new Lal project for this I'm going to
  381. 16:18use Lal command Global command available
  382. 16:22and if you don't have a lot of global
  383. 16:24command available you need to execute
  384. 16:26composer Global required
  385. 16:29oops require leral slash
  386. 16:35installer okay this is going to just
  387. 16:37require Lal installer and make the Lal
  388. 16:40comment globally available and once you
  389. 16:42do this we can execute LEL new and then
  390. 16:45we have to provide the local folder name
  391. 16:47inside which we need to create the
  392. 16:49project I'm going to call this Lal D
  393. 16:53react full st- SSR let's see the enter
  394. 16:57now we have to choose the starter kit
  395. 16:59I'm going to choose Breeze we have to
  396. 17:01choose the Breeze St I'm going to choose
  397. 17:03react then we have to choose additional
  398. 17:06features I'm going to choose dark mode
  399. 17:08comma then I'm going to choose serde
  400. 17:10rendering and typescript so we need all
  401. 17:14these three features I'm going to hit
  402. 17:16the enter and I'm going to choose the
  403. 17:17testing framework to be passed now this
  404. 17:20is going to take few seconds to scaffold
  405. 17:22the project and install that now it asks
  406. 17:25us which database we want to use the
  407. 17:27default one is SQL so we're going to
  408. 17:29stick with that hit the enter and
  409. 17:31whether we want to run the default
  410. 17:33database migrations the default one is
  411. 17:35yes I'm going to hit the enter now it it
  412. 17:38executed all the
  413. 17:39migrations and then it is going to
  414. 17:42require Lal breeze so so far that
  415. 17:45actually created the Lal projects with a
  416. 17:49default uh with a default um like the
  417. 17:54default project template excuse me so
  418. 17:57but then it takes executed to require
  419. 18:00Lal Bree and then it's going to also go
  420. 18:04with and install inertia with inera LEL
  421. 18:07and right now it is installing inera 1.3
  422. 18:12but we're going to update this into the
  423. 18:13latest version which is 2 point
  424. 18:15something which is still in beta at the
  425. 18:18moment okay so then it is removing PHP
  426. 18:21unit and installing pest
  427. 18:25framework let's scroll down below I
  428. 18:27think this actually actually finished
  429. 18:31everything or it is finishing now right
  430. 18:35here it
  431. 18:36actually uh right here it is building
  432. 18:39the project it installed everything and
  433. 18:41it is building the project executing mpm
  434. 18:43run build with a typescript command and
  435. 18:45everything and right here we have the
  436. 18:47following error so that error actually
  437. 18:50right now at the moment exists inside
  438. 18:52the SSR do TSX file which we're going to
  439. 18:56fix but in the future probably that
  440. 18:59error will not exist so we you probably
  441. 19:01don't need to do anything now let's
  442. 19:03scroll down below okay the project was
  443. 19:06finished we need to navigate into the
  444. 19:07following folder let's execute CD
  445. 19:12LEL uh LEL react full stack okay and let
  446. 19:17me actually open this folder using PHP
  447. 19:19store and then I'm going to use the PHP
  448. 19:22storms integrated terminal to execute
  449. 19:25every other
  450. 19:27comment all right so let's use explorer.
  451. 19:32XM okay that was opened here we go LEL
  452. 19:37react full stake
  453. 19:39SSR and let's open this folder as PHP
  454. 19:43showroom project we have to trust this
  455. 19:45project and I'm going to trust projects
  456. 19:47inside the her folder okay so it's going
  457. 19:50to take a few seconds to index the
  458. 19:52project now it asks me to ELO this uh
  459. 19:56folder inside the defender and and
  460. 19:58actually I'm going to do this this will
  461. 20:00speed up the performance of the project
  462. 20:03okay now we can open the terminal uh
  463. 20:05when we allo this we have to agree
  464. 20:10that okay that's that's good now let's
  465. 20:12open
  466. 20:14Terminal and we're going to do a few
  467. 20:16things first let me try to start the
  468. 20:18project so for this we need to execute
  469. 20:21composer run Dev this is relatively new
  470. 20:25comment available in the latest LEL
  471. 20:27version which will do a couple of things
  472. 20:30it is going to execute mpm run Dev um
  473. 20:33PHP Artisan serve as well and it's going
  474. 20:36to execute few other comms as well it is
  475. 20:38using um no JS concurrently package for
  476. 20:42this and it's going to also take few
  477. 20:44seconds to actually uh execute the
  478. 20:48comment and start with that so for pale
  479. 20:52actually now I get the following error
  480. 20:55that PC and TL extension is required to
  481. 20:58run pale uh which I don't have locally
  482. 21:00installed in it is not a problem
  483. 21:02actually so I don't want to just uh run
  484. 21:06the pale so that's totally fine the main
  485. 21:09thing is that the V server is running
  486. 21:11Artisan server is running so right now
  487. 21:13we can access the
  488. 21:15project in the browser so we can
  489. 21:18execute Local Host Port
  490. 21:228,000 or actually we should use 127 001
  491. 21:27we could use that as well but the main
  492. 21:29thing is that the project is up and
  493. 21:30running and this is our project and we
  494. 21:32have this login and register as well
  495. 21:35which is actually um single page
  496. 21:38application through um inertia and
  497. 21:41react now if you open Terminal again and
  498. 21:44stop this and try to execute mpm run
  499. 21:48build we have the following error what
  500. 21:51we already saw previously and this is
  501. 21:54this is coming from the SSR do TSX file
  502. 21:58let's let's open that
  503. 22:00file and this is coming from the
  504. 22:02following lines so I'm going to actually
  505. 22:05remove those um I'm not quite sure why
  506. 22:09uh these lines are here probably
  507. 22:11different typescript settings so I can
  508. 22:13just remove this no problem it is not
  509. 22:16going to hurt and then we execute mpm
  510. 22:18run build it's going to execute this
  511. 22:20typescript command then V build and then
  512. 22:23it's going to execute V build with D-
  513. 22:27SSR flag okay now that was built awesome
  514. 22:32we can check our browser again reload
  515. 22:35the
  516. 22:36page uh this is actually uh killed
  517. 22:39because we have just closed composer R
  518. 22:41de we can execute a um PHP Artisan serve
  519. 22:46separately and mpm runev separately as
  520. 22:49well okay reload the
  521. 22:53page okay that was open we can go back
  522. 22:56this is the homepage and and it works
  523. 22:59slightly slow slow because now we have
  524. 23:02server side rendering version of the
  525. 23:05application okay and because of that
  526. 23:09when actually we reload the page it is
  527. 23:12kind of slow it needs two three seconds
  528. 23:13to reload the page then when we navigate
  529. 23:16it is pretty fast okay so on production
  530. 23:20when we deploy this this project we need
  531. 23:23to start the SSR server as well so now
  532. 23:26let's use inertia
  533. 23:28serice side rendering from the
  534. 23:30documentation and if you scroll down
  535. 23:32below there are a few things to do which
  536. 23:34we already did most of the things but
  537. 23:37one thing what we haven't done is to
  538. 23:39start the iner
  539. 23:42server um the SSR server so for this we
  540. 23:45need to execute PHP Artisan iners shot
  541. 23:47start SSR I'm going to open now new
  542. 23:50terminal inside one terminal I have PHP
  543. 23:53Artisan server
  544. 23:55running here I'm going to paste this
  545. 23:58here hit the enter and now it started
  546. 24:01the SSR server and it is serving the
  547. 24:04built files um which we build through
  548. 24:09mpm run build comment okay now if we
  549. 24:13reload the page let's see now this is
  550. 24:15super fast okay it is serving those
  551. 24:18pre-build files of course navigation is
  552. 24:20also super
  553. 24:22fast okay this is awesome but again so
  554. 24:25this is fast as we noticed but if we
  555. 24:29close that inertia server and reload the
  556. 24:31page it is kind of a little bit slow so
  557. 24:34on development we don't need this SSR
  558. 24:36server up and running and we also don't
  559. 24:39need to execute mpm run build every time
  560. 24:41when we change something we need to uh
  561. 24:44start the project with mpm run de so
  562. 24:47basically we need two commments PHP
  563. 24:49Artisan serve and mpm run Dave up and
  564. 24:53running okay awesome now we need to
  565. 24:56update into latest version of inertia
  566. 24:59because we're going to use the latest
  567. 25:01version of inertia features so let's
  568. 25:03search for or we can directly access
  569. 25:06version two do inera JS let's hit the
  570. 25:11enter let's click on this upgrade guide
  571. 25:14scroll down below uh here are a couple
  572. 25:16of the main features basically in inera
  573. 25:192 there are five or six main features so
  574. 25:22we have to update these first we are
  575. 25:24going to copy mpm install common to
  576. 25:27update the in j s react and we can also
  577. 25:30check inside package Json we have intial
  578. 25:35JS react version 1.0 something now let's
  579. 25:39paste this command npm install injs
  580. 25:42react H next hit the enter then we can
  581. 25:46copy this composer require as well okay
  582. 25:49this was finished and right here that
  583. 25:52was changed into 2. 0.0 beta do2 now
  584. 25:57let's p paste this composer require as
  585. 25:59well hit the enter we can open composer
  586. 26:03Json as well and we can see now this was
  587. 26:07already switched into version
  588. 26:102.x this is actually updating the
  589. 26:12autoload
  590. 26:13[Music]
  591. 26:14files again it's going to take few
  592. 26:16seconds and that
  593. 26:19was
  594. 26:21updated so right here um this is the
  595. 26:24install version but I guess this is
  596. 26:26actually coming from cach so so that was
  597. 26:30installed that was switched from 1.3.0
  598. 26:33into
  599. 26:352.x okay Alo maybe this is just cache
  600. 26:38displaying incorrect installed version
  601. 26:41anyway we have the latest version of
  602. 26:43inertia and one thing additional thing
  603. 26:46I'm going to do generally when I um
  604. 26:49create this L react projects I'm going
  605. 26:51to change the indent size for TS file
  606. 26:55TSX file JS file and jsx
  607. 27:00file okay so now if we open any um TSX
  608. 27:06file like dashboard TSX we have Force
  609. 27:09Space indentation right here which I'm
  610. 27:11going to change which I already changed
  611. 27:14into two space and if we just format
  612. 27:17code right here it is going to switch
  613. 27:19into two spaces this is awesome and the
  614. 27:22last thing is to actually actually
  615. 27:23initialize git project because I want to
  616. 27:25comment everything and put this on my
  617. 27:27GitHub
  618. 27:28clear doesn't work so let's execute CLS
  619. 27:31uh then we need to execute kit in it hit
  620. 27:34the enter initialized empty repository
  621. 27:36actually when working with Git I
  622. 27:38generally use git BH so I have a git
  623. 27:42bash installed locally on Windows you
  624. 27:44have to download git this is git B
  625. 27:46actually and if we if you use PHP storm
  626. 27:50which is by the way awesome uh the best
  627. 27:52ID for LEL so right here we can switch
  628. 27:55to different terminal and I'm going to
  629. 27:57open know git bash and this is going to
  630. 28:00be actually to comit and push so because
  631. 28:02we already initialized this uh with uh
  632. 28:05git in it now we have we see right here
  633. 28:08the master branch and if we T type just
  634. 28:11git status we're going to see everything
  635. 28:13so let's just add everything here K git
  636. 28:16comit DM let's call this initial
  637. 28:21Comet now we're going to install spoty
  638. 28:24package for roles and permissions and
  639. 28:26we're going to Define roles and
  640. 28:28permissions as well so let's bring up
  641. 28:30the terminal now we have three terminals
  642. 28:32this is for PHP Artisan surf we can call
  643. 28:35this surf I General like to give it
  644. 28:37descriptive names then this is going to
  645. 28:39be for vit and this is actually gitbash
  646. 28:42it has proper name and the other
  647. 28:44terminal is going to be to install new
  648. 28:46packages or to to run some Artisan
  649. 28:49commments so in this case we're going to
  650. 28:51uh install LEL spatty package so we're
  651. 28:53going to execute composer require spatty
  652. 28:56LEL permission and actually let's open
  653. 28:58the documentation as well if you don't
  654. 29:00know where is that um spotty
  655. 29:05permissions and the first one is going
  656. 29:07to be uh LEL permissions package if you
  657. 29:09scroll down below here is the int
  658. 29:11introduction we can go into installation
  659. 29:13in LEL scroll down below and you're
  660. 29:16going to see the following Artis uh
  661. 29:17sorry composer comment so you can copy
  662. 29:21this and hit the enter and then we need
  663. 29:24to do a few more things so this is kind
  664. 29:26of optional we don't need to do this but
  665. 29:28we need to publish the migration in the
  666. 29:30config file as well so we're going to
  667. 29:32copy the following command the
  668. 29:35installation was done so let's paste
  669. 29:37this hit the enter and it published two
  670. 29:40files so pay
  671. 29:42attention copying file into from here
  672. 29:47into our project config permission PHP
  673. 29:51done and the second is the new migration
  674. 29:54file because we already have a git
  675. 29:56project we can go into to the changes of
  676. 29:59the PHP storm and we can see these two
  677. 30:01new files and inside the composer Json
  678. 30:04we also have this spati Lal permission
  679. 30:06package is now
  680. 30:08installed okay so now we need to execute
  681. 30:11my grade command so we can clear this
  682. 30:15up and we can execute PHP Artisan
  683. 30:19migrate hit the enter the migrations we
  684. 30:21are applied and we have the permissions
  685. 30:24and roles table already available in the
  686. 30:27database and while we are talking about
  687. 30:29this we can also open the database and
  688. 30:31have a look double click on the database
  689. 30:34SQ light in PH stor uh click okay and
  690. 30:39right here we have the project opened
  691. 30:41will with all the
  692. 30:43tables uh right here okay and we see
  693. 30:46permissions rols has permissions rols
  694. 30:48and everything basically what we need
  695. 30:50okay the next is actually um I'm going
  696. 30:53to Define roles and permissions in our
  697. 30:56project first first let's open user
  698. 30:59model and we're going to use
  699. 31:03trade um we have two trades has Factory
  700. 31:06and notifiable and we're going to use
  701. 31:08additional trait which is has roles this
  702. 31:12is coming from spati uh package and we
  703. 31:15also need to create permissions enam and
  704. 31:19rules enam for this we can open Terminal
  705. 31:22and we can execute Artis and commands as
  706. 31:24well but if you just double click on
  707. 31:26control on your keyboard This is is
  708. 31:28going to open this run everything okay
  709. 31:30and here I can execute PHP artisan make
  710. 31:34enum and this is going to create a class
  711. 31:37an Anam not class but Anam inside the
  712. 31:40app folder but I want to create that
  713. 31:42inside enam subfolder so enam back slash
  714. 31:47and I'm going to call this
  715. 31:50permissions Anam we hit the enter that
  716. 31:54file was created under up enam
  717. 31:56permissions en exactly where I want it
  718. 31:59double click on control again PHP
  719. 32:03artisan make enm inside enm folder and
  720. 32:06the second one is going to be
  721. 32:08rolls uh rolls an we hit the enter that
  722. 32:12was also created and now let's open
  723. 32:15permissions enam and we're going to
  724. 32:18Define couple of permissions so this
  725. 32:20should be picked enam so we want to have
  726. 32:23this type of string and let's define a
  727. 32:26couple of uh cases
  728. 32:28here so this is for permissions so let's
  729. 32:31define a couple of permissions like
  730. 32:32manage
  731. 32:34features um and I'm using the PHP storms
  732. 32:39uh autoc completion for the entire line
  733. 32:41which is awesome feature added into the
  734. 32:44uh latest version of PHP STM this is
  735. 32:46awesome so I'm going to use this and
  736. 32:48it's going to out to complete a couple
  737. 32:49of things for me so the second case is
  738. 32:51going to be manage
  739. 32:56users uh where we're going to have also
  740. 33:00manage uh
  741. 33:02comments and we're going to have manage
  742. 33:06not the manage but um up vote down
  743. 33:11vote up vote down vote not in plural
  744. 33:15vote down vote that's additional feature
  745. 33:19okay uh cool now let's open rules inam
  746. 33:23and we're going to Define couple of
  747. 33:26rules right here
  748. 33:29so we need admin role case admin
  749. 33:34equals
  750. 33:37admin case uh user we need user as well
  751. 33:41in case
  752. 33:44commenter equals commenter okay and
  753. 33:47let's also Define um public function uh
  754. 33:55label labels actually to return all the
  755. 33:59labels U for those cases so we're going
  756. 34:02to
  757. 34:04return we can have like um labels which
  758. 34:07simply returns uh all the labels and we
  759. 34:10can also have label which simply returns
  760. 34:13just one label for that specific uh case
  761. 34:17so in case of labels probably we should
  762. 34:19make this
  763. 34:21static public static function labels and
  764. 34:24we are going to return um the key key of
  765. 34:28the enam case and the corresponding user
  766. 34:32friendly label of that so in this case
  767. 34:35we are going to do the following so
  768. 34:37self
  769. 34:39admin actually self admin uh value is
  770. 34:44the key and the corresponding value is
  771. 34:47going to be the label so we don't use um
  772. 34:51translations it's going to be everything
  773. 34:52in s into a single language so we just
  774. 34:55associate admin to it so now let's
  775. 34:58duplicate these two times here we're
  776. 35:00going to have
  777. 35:02commenter commenter and here we're going
  778. 35:05to have uh
  779. 35:09user so these are just uh labels which
  780. 35:13simply returns uh
  781. 35:16array but we can Define label as well
  782. 35:20which returns a label of a single case
  783. 35:23of the enem in this case we're going to
  784. 35:26return uh m
  785. 35:28we're going to use
  786. 35:30this and
  787. 35:33then uh self admin and in this case we
  788. 35:38are going to
  789. 35:40return admin and we can duplicate
  790. 35:44this uh self user we're going to return
  791. 35:49user and self uh commenter we're going
  792. 35:53to return commenter
  793. 35:58okay awesome so we have
  794. 36:00actually uh defined the um methods and
  795. 36:05the um enms and I think we can create
  796. 36:10those roles and permissions in the
  797. 36:14database now let's open database Cedar
  798. 36:18and we're going to create uh roles
  799. 36:20permissions and users and Associate
  800. 36:23users to roles and permissions from here
  801. 36:25so let me actually delete this part or I
  802. 36:28think we need that user creation part I
  803. 36:31can remove this and now let's define
  804. 36:34first roles and then permissions so user
  805. 36:39Ro is going to be roll spy permissions
  806. 36:44models role we're going to execute
  807. 36:47create and we have to provide right here
  808. 36:50the name of the role so this is going to
  809. 36:53be roles enam user
  810. 36:57value now let's duplicate these two
  811. 37:00times in here we have
  812. 37:04commenter commenter
  813. 37:07role here and then we need admin
  814. 37:13role admin here now let's define
  815. 37:16permissions so manage we have actually
  816. 37:19Four permissions manage
  817. 37:23features
  818. 37:26permission and the this is going to be
  819. 37:29permission spy permissions models okay
  820. 37:34create and we have to provide name to be
  821. 37:39we're going to use permissions enam here
  822. 37:42permissions enam manage features value
  823. 37:47okay awesome now we need to duplicate
  824. 37:48this three times and the second one is
  825. 37:53going to be manage comments this one is
  826. 37:57going to be manage users and this one is
  827. 38:01going to be upvote downvote and let's
  828. 38:05give proper names to these variables
  829. 38:07this is going to be manage
  830. 38:11comments this is going to be manage
  831. 38:14users permission and this is going to be
  832. 38:18up vote down vote permission so now we
  833. 38:23have roles and we have permissions and
  834. 38:25we have to associate them them um to
  835. 38:29each other basically okay so let's use
  836. 38:33user
  837. 38:34role and we're going to execute sync
  838. 38:37permissions and we're going to provide
  839. 38:39user actually has only one permission
  840. 38:42and that permission is to up Vote or
  841. 38:44down vote so this is all regular user
  842. 38:48can do we have commenter rooll let's
  843. 38:52called sync permissions and we have to
  844. 38:55provide two permissions to the
  845. 38:57commentary so it can actually up vote
  846. 39:00and down vote but it can also manage
  847. 39:05comments and that pretty much means to
  848. 39:09create a new comment or delete uh
  849. 39:13comment or his own comment or her own
  850. 39:15comment or uh edit we don't we I think
  851. 39:18we aren't going to even Implement edit
  852. 39:19so because we're doing some um just for
  853. 39:23the demonstration purposes okay of the
  854. 39:25roles and permissions
  855. 39:28okay awesome and next we're going to
  856. 39:30have admin
  857. 39:32rle again let's call sync permissions
  858. 39:35but in this case we're going to have all
  859. 39:37um available permissions like we need up
  860. 39:40vote down vote permission manage
  861. 39:43users manage comments and manage um
  862. 39:47features we don't need users twice
  863. 39:50manage features
  864. 39:52permission okay now we have roles
  865. 39:54permissions Associated users um sorry
  866. 39:58the roles to permissions and now I think
  867. 40:00it's time to create users and Associate
  868. 40:04roles to those users so we have user
  869. 40:07creation code right here let's call this
  870. 40:10user user and let's give it email user
  871. 40:14example.com and then we are going to
  872. 40:17call assign role and we have to provide
  873. 40:21right here the RO name which we want to
  874. 40:25assign to the user and and we can use
  875. 40:28roles
  876. 40:30enam user right here okay so this is the
  877. 40:35rule we want to assign to that specific
  878. 40:38user now we need to duplicate these two
  879. 40:40more times one this is the user now this
  880. 40:43is going to be commenter user let's give
  881. 40:47it also email commenter and we're going
  882. 40:50to assign roll commenter roll to it now
  883. 40:54this is going to be admin user
  884. 40:57admin example.com and this is going to
  885. 41:00have admin role now we have defined
  886. 41:03roles permissions users assign
  887. 41:04everything to it and I think we can
  888. 41:06execute now migrations or we can simply
  889. 41:09execute uh seed command or migrations
  890. 41:12with the seed comment so let's execute
  891. 41:15PHP Artisan migrate fresh D- seat let's
  892. 41:20hit the enter we could simply execute
  893. 41:22seed commment as well now it it seeded
  894. 41:24the database and if we check in the
  895. 41:26users table we see three users if we
  896. 41:28check roles table we see three roles if
  897. 41:31we check also uh R has permissions we
  898. 41:34see a couple of Records here as well and
  899. 41:36inside permissions as well we see those
  900. 41:40permissions okay this is actually pretty
  901. 41:44cool if we also want to check uh which
  902. 41:47roles are associated to the user we need
  903. 41:50to see that inside model has permissions
  904. 41:53and model has roles tables which are
  905. 41:55actually for abstract
  906. 41:57for polymorphic relations so here we see
  907. 42:00modle ID one two and three and the modle
  908. 42:03type is the user class name so basically
  909. 42:06user with ID one has the following C
  910. 42:09user with id2 has the following C and so
  911. 42:13one and in the same thing inside the
  912. 42:15model has permissions we see what
  913. 42:18permissions are actually assigned to
  914. 42:21models and in our case we haven't
  915. 42:23assigned any specific permissions to the
  916. 42:25users we just assigned roll to to them
  917. 42:28when the new user is registered on our
  918. 42:31website basically the user is
  919. 42:33automatically verified but we want to
  920. 42:35enable email verification that's
  921. 42:38why let's open user PHP and we are going
  922. 42:42to implement an interface must verify
  923. 42:46email okay and now when the user tries
  924. 42:49to register the user will receive an
  925. 42:51email however I want to also set up test
  926. 42:56mail fake mail client locally which is
  927. 42:59called mail pit so this is actually very
  928. 43:02awesome for just a local mail sending so
  929. 43:05mail ped just type in the Google ma mail
  930. 43:08ped open the very first link so then we
  931. 43:11can click on installation scroll down
  932. 43:13below and find the on on Windows
  933. 43:17basically find the following section
  934. 43:19download static binary click on releases
  935. 43:22so this is going to open GitHub page
  936. 43:24scroll down below and we have right here
  937. 43:27the assets for the latest release and
  938. 43:30just open the just download the latest
  939. 43:34version for your operating system which
  940. 43:37I actually have already downloaded so
  941. 43:39I'm going to open this right now and I
  942. 43:43have that folder I put that folder in my
  943. 43:46home directory under mail mail pit
  944. 43:49folder and right here I have this mail
  945. 43:51pit XEL and we actually need to start
  946. 43:54that mail pit XEL however I'm I'm going
  947. 43:57to I also made that mail pit comment
  948. 43:59globally available by adding the
  949. 44:02following path into systems variable
  950. 44:05path which means that if I open new
  951. 44:08terminal which I actually have opened
  952. 44:11right here this is where I created the
  953. 44:13project I can actually clear this up and
  954. 44:16let's go into home folder and right here
  955. 44:19I can execute mail pit so this is the
  956. 44:24global command available right now on my
  957. 44:26computer here the enter and it's going
  958. 44:27to start mail pit server listening on
  959. 44:30two ports 1025 and 825 so I recommend to
  960. 44:35add this into your systems variable the
  961. 44:38path of the mail pit as well so that you
  962. 44:40can have this mail pit common globally
  963. 44:42available or if you don't want to add
  964. 44:45that into like systems variable you can
  965. 44:48always go into the folder where you have
  966. 44:51that mail pit XA file you download it
  967. 44:53probably it's going to be inside
  968. 44:55downloads just go into the folder and
  969. 44:57right here you need to open the terminal
  970. 45:00so we can open new
  971. 45:02terminal here we can navigate into the
  972. 45:05following folder and here we have this
  973. 45:07mail pit also so we hit the enter and
  974. 45:11the mail pit was started on 10 25 and
  975. 45:148025 now we can open this 8025 in the
  976. 45:17browser and this is the client and we
  977. 45:20have to configure the SMTP in our
  978. 45:24project so let's open file and find the
  979. 45:28mail section and here we have this mail
  980. 45:31mailer which is by default log so every
  981. 45:34new mail uh is sent into the log files
  982. 45:37which we want to change into
  983. 45:39SMTP so the host is going to be
  984. 45:421271 the port is going to be the mail
  985. 45:45pit port and this is going to be SMTP
  986. 45:48Port 1025 no encryption so we're going
  987. 45:52to provide 10 25 and there is nothing we
  988. 45:55need to do uh right here so that's
  989. 45:59already done SMTP host and
  990. 46:03Port now let's try to create new account
  991. 46:07let's close this tab this tab as well we
  992. 46:10can leave the permissions we can leave
  993. 46:11the iner as well so now let's try to
  994. 46:14register using Zur zoraa example.com
  995. 46:17let's provide some secure password
  996. 46:22Here we hit the enter and we save this
  997. 46:26and and look at this so now we are not
  998. 46:28verified and it tells us that we need to
  999. 46:30check the email so here is the mail ped
  1000. 46:32we see one here so we received new email
  1001. 46:35just click on this and this displays our
  1002. 46:38email nicely in the browser we click on
  1003. 46:40this verify email address and here it
  1004. 46:44goes now we are verified and we see the
  1005. 46:46dashboard we can reload this page as
  1006. 46:48well and we are going to see dashboard
  1007. 46:50right here as well so let's close this
  1008. 46:52we have this mail pit local client which
  1009. 46:54is awesome for local testing of s emails
  1010. 46:57and also make sure you don't kill that
  1011. 47:00mail pit command that should be running
  1012. 47:03in the background so that whenever we
  1013. 47:05are testing we need to have this comment
  1014. 47:06running otherwise simply we won't
  1015. 47:09receive any emails right here now let's
  1016. 47:12open PHP
  1017. 47:15stor first let me actually comment the
  1018. 47:17changes I made so I just implemented
  1019. 47:21this must verify email so add email send
  1020. 47:27in on
  1021. 47:29registration so let's comment
  1022. 47:31this awesome so now let's open handle
  1023. 47:36inera JS request by the way the comment
  1024. 47:38I made right now was only for the file
  1025. 47:41user PHP but previously I made some
  1026. 47:43changes when I edit rols and permissions
  1027. 47:46in the database Seer I actually already
  1028. 47:48made the comment for this and we can see
  1029. 47:50this in the G comment history so the
  1030. 47:51initial comment to find roles and
  1031. 47:53permissions and then I added the
  1032. 47:55following comment add send sending email
  1033. 47:57sending on
  1034. 47:59registration okay cool now I want to
  1035. 48:02open this handle inera JS request and
  1036. 48:05from here we have these shared props for
  1037. 48:10the um react component so we have out
  1038. 48:13user which is the request user which I
  1039. 48:16want to change so I want to Define two
  1040. 48:18resources for
  1041. 48:20users I'm going to double click on
  1042. 48:22control on the keyboard PHP artisan make
  1043. 48:28resource first I'm going to Define out
  1044. 48:30user resource which is going to be the
  1045. 48:34resource for the authenticated user hit
  1046. 48:36the enter
  1047. 48:38next I'm going to Define just user
  1048. 48:42resource hit the enter okay now I have
  1049. 48:45two resources first let's open user
  1050. 48:48resource which is going to be simpler
  1051. 48:50and from here I want to return the
  1052. 48:53properties for the other users like if
  1053. 48:56one user is just viewing the um page the
  1054. 49:00application and if other users left some
  1055. 49:03comment or create to the Future the
  1056. 49:06other users information will uh
  1057. 49:09basically run inside this
  1058. 49:12resource so we just need
  1059. 49:15ID this ID duplicate this two times we
  1060. 49:21need
  1061. 49:23name and we need email so this is this
  1062. 49:26is for user resource now let's open out
  1063. 49:30user
  1064. 49:31resource and here we need few more
  1065. 49:34things than just ID name and email so
  1066. 49:38obviously we need those fields as well
  1067. 49:42this ID duplicate this few more times we
  1068. 49:46need
  1069. 49:47name we need email but we need a couple
  1070. 49:51of other things like we can also add
  1071. 49:54email verified ad
  1072. 49:59uh but we also want to return roles and
  1073. 50:02permissions so what roles and
  1074. 50:04permissions the current user has so
  1075. 50:06let's define permissions first here and
  1076. 50:09this is going to be this which is user
  1077. 50:12in this case this get all permissions so
  1078. 50:17this basically this get all permissions
  1079. 50:20is coming from this has rules trait
  1080. 50:25because we added it into this user now
  1081. 50:27user has this get all permissions and we
  1082. 50:31this is going to return actually
  1083. 50:32instances of the eloquent models of the
  1084. 50:34permission so we are going to uh run
  1085. 50:37this inside the map
  1086. 50:40function uh let's move this map actually
  1087. 50:44down and then from here we are going to
  1088. 50:46Simply return the permission name so we
  1089. 50:48only want permission names not the
  1090. 50:50entire objects on uh front end in react
  1091. 50:54so next we need r roles and there is uh
  1092. 50:59this is actually simpler so we have this
  1093. 51:03get roll names get R names method
  1094. 51:08available inside um this H roles trait
  1095. 51:13so in just like this we are returning
  1096. 51:14permissions and rules for the user and
  1097. 51:17actually we can check that so if we open
  1098. 51:20dashboard
  1099. 51:22TSX scroll up uh and open this authentic
  1100. 51:26ated layout here we are accessing this
  1101. 51:29user which is coming from this page
  1102. 51:32props out user that out user is exactly
  1103. 51:35what we are returning from here but
  1104. 51:37first we need to change this into
  1105. 51:40resource so we have this request user
  1106. 51:42which I'm going to extract into a
  1107. 51:44variable called user then I'm going to
  1108. 51:46check if the user exists then I'm going
  1109. 51:49to run this in Inside Out user resource
  1110. 51:53actually we need to use new out user
  1111. 51:55resource Prov providing that user
  1112. 51:57otherwise we're going to return
  1113. 52:00null now right here that user basically
  1114. 52:03will be a result of out user resource if
  1115. 52:06the user exists otherwise it's going to
  1116. 52:07be null so what we can do is just print
  1117. 52:11the user and because we changed the
  1118. 52:13indentation into two spaces by default
  1119. 52:16that was set to four now uh the default
  1120. 52:20um now when I generated this console log
  1121. 52:23basically it was set like this with two
  1122. 52:26spaces actually we have to Simply
  1123. 52:28reformat the file contrl alt and L on
  1124. 52:32the keyboard so that reformatted the
  1125. 52:34file let's just print the user save that
  1126. 52:38and let's open developer tools go into
  1127. 52:40console here we see the object this is
  1128. 52:42the user object and let's reload the
  1129. 52:46page and have a look so we have the data
  1130. 52:50actually I don't want the data so let's
  1131. 52:53open Al user resource and we are going
  1132. 52:56to said R equals
  1133. 52:59false that WP basically creates that
  1134. 53:02additional data which we don't want so
  1135. 53:05we set the W equals false and we
  1136. 53:08probably need to do the same thing in
  1137. 53:10the user
  1138. 53:13resource R equals
  1139. 53:17false awesome now we reload the
  1140. 53:21page and now we see here user and that
  1141. 53:24user has permissions and r as well and
  1142. 53:28actually both of them are null because
  1143. 53:31right now I'm authenticated as user zura
  1144. 53:33Zur is just created user and that user
  1145. 53:35doesn't have any roles and permissions
  1146. 53:38but if we log out and if we try to log
  1147. 53:40in with admin n example.com
  1148. 53:44hit the
  1149. 53:46[Music]
  1150. 53:47enter okay let's open the developer
  1151. 53:49tools reload the
  1152. 53:51page and here we see the uh user admin
  1153. 53:55and we see that that user has four
  1154. 53:58permissions and one role admin role okay
  1155. 54:02that's awesome and just like this we
  1156. 54:04have the the necessary uh resources for
  1157. 54:08the authenticated user as well as for
  1158. 54:10the general user which we are going to
  1159. 54:11use in the future now let's define
  1160. 54:14migrations models uh and controller in
  1161. 54:19case if we need that for our project
  1162. 54:22basically so we're going to work on the
  1163. 54:23database schema first let's come into
  1164. 54:26again everything would we change so far
  1165. 54:29uh create new user
  1166. 54:36resources awesome our files were
  1167. 54:38committed now let's close
  1168. 54:42everything and let's double click on
  1169. 54:44control and we execute PHP artisan make
  1170. 54:48model first we're going to create
  1171. 54:51feature model and I'm going to generate
  1172. 54:53this with migration file as well
  1173. 54:57we need to generate controller as well
  1174. 54:59and that controller should be resource
  1175. 55:02controller okay so we hit the
  1176. 55:05enter these files were generated so we
  1177. 55:09see model we see migration and we see
  1178. 55:12controller okay next is to create the
  1179. 55:16upfold model so PHP artisan make model
  1180. 55:23upvote model and we need to generate
  1181. 55:25only migration for
  1182. 55:28that we hit the enter and the next one
  1183. 55:31is
  1184. 55:32to actually
  1185. 55:34create comment model so we hit the enter
  1186. 55:38the comment model and the migration was
  1187. 55:40created now let's open create features
  1188. 55:45table and right here we need to define a
  1189. 55:48couple of columns like we need table
  1190. 55:50string name that's correct we need
  1191. 55:54table uh long text description and we're
  1192. 55:58going to make this nullable and on table
  1193. 56:02we also want to Define um foring ID for
  1194. 56:08user
  1195. 56:11model awesome now let's open second
  1196. 56:14migration file create up folds table and
  1197. 56:19here we need to Define foring
  1198. 56:24ID ping ID um feature
  1199. 56:29ID this is
  1200. 56:32constrained by
  1201. 56:35features and we can move this down and
  1202. 56:39we need Cascade on delete as well so if
  1203. 56:43the feature is deleted its uploads are
  1204. 56:45deleted as well and in the same way we
  1205. 56:48need foring ID on user the column name
  1206. 56:52is the user ID it it is constrained by
  1207. 56:55users
  1208. 56:56and Cascade on delete as well and I
  1209. 56:59think we don't need time stamps so we
  1210. 57:01can remove that we can simplify things a
  1211. 57:04little bit and then we need Boolean
  1212. 57:07upvote so that table basically
  1213. 57:10defines if that specific user has
  1214. 57:13upvoted that feature or downvoted that
  1215. 57:16feature so inside up vote we have one
  1216. 57:18and zero one means that the user upvoted
  1217. 57:21that feature zero means that user
  1218. 57:24downvoted that feature that's all now
  1219. 57:27let's open third migration file
  1220. 57:31create uh comments table and here we
  1221. 57:35need to
  1222. 57:37Define um
  1223. 57:40string comment which can be a little bit
  1224. 57:43larger text like 2,000 but it should be
  1225. 57:47required then we need a foring ID that
  1226. 57:51should be feature ID constrainted on
  1227. 57:56features and we can provide Cascade on
  1228. 57:58delete as well let's move this down and
  1229. 58:03we need also user so that's going to be
  1230. 58:06user ID constraint on users and Cascade
  1231. 58:11on delete and we can have also time
  1232. 58:13stamp on the comments because sometimes
  1233. 58:15we need to display at what time the
  1234. 58:17comment was
  1235. 58:18made okay this is good now let's open
  1236. 58:22feature PHP model and we def find
  1237. 58:26relations here we are going to use has
  1238. 58:29many keyword which comes with I think
  1239. 58:31with a lot um blade sorry with Lal ID
  1240. 58:36plugin so then we need up votes here and
  1241. 58:40we need to use up vote
  1242. 58:44class we have another has many or
  1243. 58:49comments here we need comment class and
  1244. 58:53we have belongs to
  1245. 58:56uh user and here we need user
  1246. 59:04class okay so we need to open comment
  1247. 59:07model as well and we need to Define
  1248. 59:10belongs to user so comment belongs to a
  1249. 59:15user let's use user
  1250. 59:18here and comment also belongs to
  1251. 59:24feature so here here we need feature and
  1252. 59:28we have to open user as well and user
  1253. 59:33has
  1254. 59:34many uh
  1255. 59:38features and user also has many comments
  1256. 59:42but I think we don't need that actually
  1257. 59:44so we can Define this but we are not
  1258. 59:46going to use this because we are
  1259. 59:48interested comments for the specific
  1260. 59:50feature not General all the available
  1261. 59:53comments of the user so we don't need
  1262. 59:54that uh again again let's go back into
  1263. 59:58feature and we need to open this up v as
  1264. 1:00:01well and we can also Define this uh
  1265. 1:00:04belongs to belongs to feature maybe we
  1266. 1:00:08are not even going to use all the
  1267. 1:00:10relations what we defined right here um
  1268. 1:00:13but I'm just defining I think that's all
  1269. 1:00:16so we we created the migrations we
  1270. 1:00:19created the models uh we Define the
  1271. 1:00:22relations and let's just open feature
  1272. 1:00:24controller and I think now we're going
  1273. 1:00:26to focus on the feature controller which
  1274. 1:00:28is actually a resource controller right
  1275. 1:00:30now for feature model now let's comment
  1276. 1:00:34all the changes what we made so far
  1277. 1:00:36Define models in migrations is going to
  1278. 1:00:38be the comment message click on
  1279. 1:00:40comment and that was done now let's
  1280. 1:00:43close
  1281. 1:00:44everything and we are going to uh focus
  1282. 1:00:47on the next step and this is going to be
  1283. 1:00:49to render features but to render
  1284. 1:00:53features first we we have to create some
  1285. 1:00:56seed data so for this I want to actually
  1286. 1:00:59create a factory class for the features
  1287. 1:01:03PHP artisan
  1288. 1:01:05make Factory and let's call this feature
  1289. 1:01:11Factory we hit the enter feature Factory
  1290. 1:01:13was created now let's open feature
  1291. 1:01:17Factory and we have to return a couple
  1292. 1:01:20of things so we have the name instead of
  1293. 1:01:23this Faker I'm going to use actually
  1294. 1:01:25fake function
  1295. 1:01:26we need fake um name okay I don't want
  1296. 1:01:30name I just want fake text okay because
  1297. 1:01:33feature name is not going to be a name
  1298. 1:01:35it's going to be some
  1299. 1:01:37text okay so we have name to be feature
  1300. 1:01:40text we have the description which going
  1301. 1:01:42to be again text but we have to provide
  1302. 1:01:44uh larger number of characters and we
  1303. 1:01:48have to provide the user ID as well so
  1304. 1:01:51for user ID I'm going to assign every
  1305. 1:01:54feature to the admin user because admin
  1306. 1:01:56user is going to be only user who is
  1307. 1:01:59able to create new features so let's use
  1308. 1:02:02user we so right now because we are
  1309. 1:02:05actually faking the data now we have one
  1310. 1:02:08admin user which has email admin at
  1311. 1:02:11example.com so I'm going to just select
  1312. 1:02:13the user which has email admin
  1313. 1:02:16example.com and first and we are going
  1314. 1:02:20to Simply get its ID of that user ID and
  1315. 1:02:24just like this we have that field
  1316. 1:02:26defined now let's open database Cedar
  1317. 1:02:29scroll down below and right here I'm
  1318. 1:02:31going to call uh feature
  1319. 1:02:35Factory we have to provide 100 here I'm
  1320. 1:02:38going to create 100 features and then
  1321. 1:02:40let's call
  1322. 1:02:42create now let's save everything uh we
  1323. 1:02:45can open Terminal or we can hit double
  1324. 1:02:49um on control and execute PHP Artisan
  1325. 1:02:53migrate actually we have to to execute
  1326. 1:02:56migrate fresh with Dash Das seed as well
  1327. 1:02:59because we want that seed data to be
  1328. 1:03:02rerun we hit the
  1329. 1:03:04enter we have an error interesting uh
  1330. 1:03:08okay feature Factory okay that's that's
  1331. 1:03:11uh good so the error actually is not
  1332. 1:03:13good but um we can easily fix
  1333. 1:03:16that let's open feature. PHP model and
  1334. 1:03:21we are going to H use trade has
  1335. 1:03:24Factory now let's re-execute that hit
  1336. 1:03:27the
  1337. 1:03:30enter okay so that was finished now
  1338. 1:03:32let's open the
  1339. 1:03:34database
  1340. 1:03:37open features and we see 100 features
  1341. 1:03:40inside the database we see user ID
  1342. 1:03:43created it updated it and everything is
  1343. 1:03:46there okay that's cool now I think we
  1344. 1:03:48can focus on rendering those features um
  1345. 1:03:52on the front end side first let's open
  1346. 1:03:57uh feature
  1347. 1:04:00controller I'm going to drink
  1348. 1:04:07water return and we have to actually
  1349. 1:04:11select these features and return
  1350. 1:04:15them however we're going to use also
  1351. 1:04:17resource to return the data so I'm going
  1352. 1:04:20to create now feature resource uh PHP
  1353. 1:04:24artisan make
  1354. 1:04:26resource feature resource it is always
  1355. 1:04:30good practice to create resources and
  1356. 1:04:33Define what data you want to be returned
  1357. 1:04:37on the front end which is in our case
  1358. 1:04:39react application because if you return
  1359. 1:04:42everything without resource you might
  1360. 1:04:44expose some uh confidential data which
  1361. 1:04:47we don't
  1362. 1:04:49want okay we created feature
  1363. 1:04:54resource let's let's first open feature
  1364. 1:04:57resource we will come back to the
  1365. 1:04:59controller and we're going to return a
  1366. 1:05:00few things from here so we need ID
  1367. 1:05:04obviously this ID let's duplicate this
  1368. 1:05:07few times uh we need
  1369. 1:05:12name we need a description to return we
  1370. 1:05:17also want to return the user information
  1371. 1:05:20okay so user and here I can directly
  1372. 1:05:24return this user but again this user is
  1373. 1:05:27going to be an instance of the eloquent
  1374. 1:05:28model and I want to put that into
  1375. 1:05:30resource and for exactly this purpose we
  1376. 1:05:33created user resource which we haven't
  1377. 1:05:37used so far okay and we also need to
  1378. 1:05:40return created
  1379. 1:05:44at this created it and we can uh call
  1380. 1:05:48format here with the following format
  1381. 1:05:51year month day h i and S okay now we
  1382. 1:05:56have this feature resource let's go into
  1383. 1:05:58controller and from here I'm going to
  1384. 1:06:01call inertia render and I'm going to
  1385. 1:06:04provide the following component which I
  1386. 1:06:06want to create so that doesn't exist yet
  1387. 1:06:08we're going to create that so and inside
  1388. 1:06:11the feature index we are going to pass
  1389. 1:06:14features which is going to be uh feature
  1390. 1:06:19resource collection okay we have to
  1391. 1:06:22provide the collection here and we have
  1392. 1:06:25to select
  1393. 1:06:28feature
  1394. 1:06:30latest actually let's take this
  1395. 1:06:32out and let's call this
  1396. 1:06:36paginated feature
  1397. 1:06:38latest uh and pinate we have to call
  1398. 1:06:42paginate let's provide the um no
  1399. 1:06:45argument here and by default it's going
  1400. 1:06:47to take the 15 features as I remember so
  1401. 1:06:50we need to take this paginated and
  1402. 1:06:52provide this into collection right here
  1403. 1:06:54now we have to Define this feature index
  1404. 1:06:57so let's go into resources
  1405. 1:07:00JS pages and we have dashboard right
  1406. 1:07:03here now I'm going to create new folder
  1407. 1:07:06this is going to be feature we hit the
  1408. 1:07:09enter now let's copy the dashboard TS6
  1409. 1:07:12and put this inside
  1410. 1:07:14feature and we have to call this index
  1411. 1:07:18TS6 okay so now feature index view file
  1412. 1:07:22actually exists let's open this index
  1413. 1:07:25IND TSX and we have to change this
  1414. 1:07:27dashboard into index and we have to
  1415. 1:07:30accept right here props and we are
  1416. 1:07:33passing actually features from here so
  1417. 1:07:36we have to
  1418. 1:07:38accept
  1419. 1:07:40features now this is actually
  1420. 1:07:42interesting part so we are accepting
  1421. 1:07:44features right here but because we are
  1422. 1:07:47using typescript we have to actually
  1423. 1:07:50Define what type of instance these
  1424. 1:07:53features is
  1425. 1:07:56if we don't Define these types so it is
  1426. 1:07:58going to actually work while we're
  1427. 1:08:00developing this and let's try to now
  1428. 1:08:03authenticate with admin
  1429. 1:08:05user actually we don't uh use that view
  1430. 1:08:10at the moment so let me do the following
  1431. 1:08:12so let's change this dashboard into
  1432. 1:08:15features and here we have the dashboard
  1433. 1:08:18and let's just print inside preag using
  1434. 1:08:22Json stringify
  1435. 1:08:25provide
  1436. 1:08:26features
  1437. 1:08:28undefined
  1438. 1:08:30to okay awesome now let's open web. PP
  1439. 1:08:34and we want to Define this um
  1440. 1:08:38root so first we don't need this welcome
  1441. 1:08:41page anymore so I'm going to remove
  1442. 1:08:45this uh we are going to let me think so
  1443. 1:08:50let's actually do redirect so from slash
  1444. 1:08:52we are going to do redirect into
  1445. 1:08:54dashboard
  1446. 1:08:56Okay cool so now inside the dashboard we
  1447. 1:08:58render this dashboard blade um not plate
  1448. 1:09:02but the react file and this is something
  1449. 1:09:04I want to
  1450. 1:09:05change uh here we have this middleware
  1451. 1:09:08for out and we have this profile
  1452. 1:09:11management and this is what I'm going to
  1453. 1:09:12do inside out I'm going to Define
  1454. 1:09:16another middle wear and this is going to
  1455. 1:09:18be verified middle wear so middle
  1456. 1:09:21wear verified which means that the user
  1457. 1:09:24needs to be authenticated and verified
  1458. 1:09:27to be able to access dashboard this is
  1459. 1:09:29exactly what is written here so let's
  1460. 1:09:33copy this part and we can delete this
  1461. 1:09:35middle
  1462. 1:09:38gear okay user needs to be authenticated
  1463. 1:09:42and verified to be able to access
  1464. 1:09:44dashboard in the same way user needs to
  1465. 1:09:47be authenticated and verified to be able
  1466. 1:09:49to access Feature Feature page and in
  1467. 1:09:52this case we need to provide here
  1468. 1:09:56feature controller index and we have to
  1469. 1:09:59provide the name as well feature index
  1470. 1:10:02and just like this we Define the root
  1471. 1:10:04for feature now let's go into index TSX
  1472. 1:10:10let's open this authenticated layout
  1473. 1:10:12let's find dashboard here this is the
  1474. 1:10:16navigation item dashboard and I'm going
  1475. 1:10:18to copy and paste this and change that
  1476. 1:10:22so we need features index the wrote name
  1477. 1:10:26here we also need features index and the
  1478. 1:10:29menu item to be features and we have
  1479. 1:10:31dashboard also in the second place for
  1480. 1:10:34the responsive nav link and we have to
  1481. 1:10:36copy
  1482. 1:10:38this and adjust this as well so we need
  1483. 1:10:41feature
  1484. 1:10:42index Fe feature index here and features
  1485. 1:10:49here as well now if we save this and
  1486. 1:10:52reload the
  1487. 1:10:53page we
  1488. 1:10:55have couple of
  1489. 1:10:57Errors okay let's see what errors do we
  1490. 1:11:05have dashboard is not in the rot list
  1491. 1:11:08okay makes sense so if you open web PHP
  1492. 1:11:11we we simply remove the name for the
  1493. 1:11:14dashboard Ru so we have to
  1494. 1:11:16provide name to be dashboard save that
  1495. 1:11:20reload that
  1496. 1:11:25and here we go now let's click on
  1497. 1:11:28features and here we have these features
  1498. 1:11:31and here we have the entire data so even
  1499. 1:11:34though at the moment we don't have types
  1500. 1:11:37Associated to these features this is
  1501. 1:11:39going to actually work and we see the
  1502. 1:11:42features object which has data if you
  1503. 1:11:44scroll down below there are 15 features
  1504. 1:11:47I guess by default inside this paginated
  1505. 1:11:48data then we have links and meta and
  1506. 1:11:52that's it basically and we can expand um
  1507. 1:11:55that features I think we don't print
  1508. 1:11:56that features right here but we can
  1509. 1:11:58actually print features here as
  1510. 1:12:02well here it is Data links and meta okay
  1511. 1:12:06so what we need to do is to Define now
  1512. 1:12:10type and again to come back to this so
  1513. 1:12:12even though this works right now it is
  1514. 1:12:14not going to work when we try to build
  1515. 1:12:16the project for production so here we
  1516. 1:12:18have this V server if I close this and
  1517. 1:12:21execute mpm run run build now it is not
  1518. 1:12:27going to work
  1519. 1:12:31anymore so as you see the error is
  1520. 1:12:34coming from here implicitly has any type
  1521. 1:12:37so we can obviously provide that these
  1522. 1:12:39features has any type but this is not
  1523. 1:12:41what we want we want to Define proper
  1524. 1:12:44types because we are using
  1525. 1:12:46typescript so for this I'm going to open
  1526. 1:12:48index. d. TS which has some predefine
  1527. 1:12:52types let's format this into two space
  1528. 1:12:56and we have a couple of interfaces and
  1529. 1:12:58types like for the user interface and we
  1530. 1:13:00have some page props as well and a few
  1531. 1:13:03other
  1532. 1:13:04things first because for the
  1533. 1:13:06authenticated user we addit permissions
  1534. 1:13:09and draws so if we check out user
  1535. 1:13:13resource um right here we have this
  1536. 1:13:16permissions and trols this is something
  1537. 1:13:18we need to also add right here in this
  1538. 1:13:20user because that user is used inside
  1539. 1:13:24the page props
  1540. 1:13:26okay inside out user and if we check the
  1541. 1:13:28usage of page props we're going to see
  1542. 1:13:30this into a couple of places we see this
  1543. 1:13:32in the welcome page and we see in the
  1544. 1:13:34profile page as well uh and if we open
  1545. 1:13:37this for
  1546. 1:13:38example we only use must verified email
  1547. 1:13:41and status in this case if we check
  1548. 1:13:44another example on the welcome page we
  1549. 1:13:48use out LEL and PHP
  1550. 1:13:51version actually I think we don't even
  1551. 1:13:54use user when we use page props but my
  1552. 1:13:57point is that if we
  1553. 1:14:00use let's open this example so right
  1554. 1:14:03here if we decide to use Al and we know
  1555. 1:14:06that that Al actually has user so right
  1556. 1:14:10here we could access al. user and this
  1557. 1:14:14is autoc completed and this is coming
  1558. 1:14:16from these types okay but that user has
  1559. 1:14:21name email verify dat email and ID but
  1560. 1:14:24that user does not have uh permissions
  1561. 1:14:27or roles even though it actually has
  1562. 1:14:31okay because we return that from this
  1563. 1:14:33out user resource the permissions and
  1564. 1:14:36roles that's why we need to Define this
  1565. 1:14:39properly so right here let me Define
  1566. 1:14:42permissions which is actually an array
  1567. 1:14:45of
  1568. 1:14:46strings and roles again array of strings
  1569. 1:14:51now if we go in edit TSX control and
  1570. 1:14:54space is now it has permissions array of
  1571. 1:14:57strings and roles as well okay I'm going
  1572. 1:14:59to undo these changes right here because
  1573. 1:15:01I am not actually making some changes in
  1574. 1:15:03this edit TSX file at the moment so we
  1575. 1:15:05can close this welcome as well now let's
  1576. 1:15:09focus on this um types index DTS file
  1577. 1:15:13okay so we added these roles and
  1578. 1:15:15permissions here now let's define new
  1579. 1:15:17type export type I'm going to call this
  1580. 1:15:22paginated data and that actually
  1581. 1:15:26equals into the following object so we
  1582. 1:15:29have
  1583. 1:15:30data and this is also kind of something
  1584. 1:15:33interesting so we can make this data to
  1585. 1:15:36be something okay the data is actually
  1586. 1:15:40an array of feature
  1587. 1:15:43objects so we have to actually Define
  1588. 1:15:47the feature object as well and make that
  1589. 1:15:51paginated data to know that it is
  1590. 1:15:54actually actually it contains data to be
  1591. 1:15:57an um array of feature objects it sounds
  1592. 1:16:00complicated but let me just make this
  1593. 1:16:02simple okay so inside this pated data we
  1594. 1:16:06going to accept t as a type which can be
  1595. 1:16:09anything okay then the data is going to
  1596. 1:16:12be type of T an array basically of
  1597. 1:16:18T and inside links we're going to have a
  1598. 1:16:23record of
  1599. 1:16:25string and string so it's going to have
  1600. 1:16:27some key value Pi there okay so it's
  1601. 1:16:30going to be record of string and string
  1602. 1:16:33let's just have a look at the data and
  1603. 1:16:34we're going to understand this better
  1604. 1:16:36now we can use this paginated data
  1605. 1:16:39inside right
  1606. 1:16:41here so features actually is a type
  1607. 1:16:46where
  1608. 1:16:47features is pated data and we can
  1609. 1:16:51actually provide type right here what
  1610. 1:16:54type of features what type of data is
  1611. 1:16:57inside features this so far is already
  1612. 1:16:59good and we don't see any errors but for
  1613. 1:17:02additional autoc completion so now we
  1614. 1:17:04see that the features is an paginated
  1615. 1:17:07data but when we try to iterate features
  1616. 1:17:10over data which we're going to do right
  1617. 1:17:12here like features dot let's use
  1618. 1:17:16features. data and when we start
  1619. 1:17:20iterating over that we accept feature
  1620. 1:17:23right here as an example and then we try
  1621. 1:17:27to print feature. name but now um
  1622. 1:17:32typescript doesn't know what is this
  1623. 1:17:34feature okay it doesn't have any idea
  1624. 1:17:36about this that's why we have to define
  1625. 1:17:39feature as well export type
  1626. 1:17:45feature and we need uh basically let me
  1627. 1:17:48just quickly copy and paste this
  1628. 1:17:51part so we need ID name description the
  1629. 1:17:54user user object itself and created that
  1630. 1:17:57this is what we defined in the where is
  1631. 1:18:00that in the feature resource here here
  1632. 1:18:06okay so now if you open
  1633. 1:18:09index. TSX file right here we need to
  1634. 1:18:12provide inside this less than and
  1635. 1:18:15greater than symbol the type feature
  1636. 1:18:18type now typescript knows that right
  1637. 1:18:21here this feature actually has a type of
  1638. 1:18:24feature
  1639. 1:18:25so that's why uh if we save
  1640. 1:18:31that let's actually change this into
  1641. 1:18:34something
  1642. 1:18:36like this the error is actually gone
  1643. 1:18:40okay but without that feature definition
  1644. 1:18:44the
  1645. 1:18:47error yeah implicitly implicitly it has
  1646. 1:18:50type of any so this technically doesn't
  1647. 1:18:53give us an error uh but if we try to
  1648. 1:18:56build that might give us an error let's
  1649. 1:18:58execute mpm run build or it might not
  1650. 1:19:01give us an error but it also doesn't
  1651. 1:19:03autocomplete it so it doesn't give us an
  1652. 1:19:07error but if we try to access some
  1653. 1:19:10fields of the feature it doesn't have
  1654. 1:19:12any idea what fields that feature has
  1655. 1:19:15but as soon as we provide here
  1656. 1:19:20feature scroll down below then it knows
  1657. 1:19:24it has user user name ID description and
  1658. 1:19:27so on couple of other things okay so
  1659. 1:19:29we're going to come back to this now and
  1660. 1:19:31render features okay so for each feature
  1661. 1:19:34I want to create separate component to
  1662. 1:19:36render that feature item so inside
  1663. 1:19:39resources JS components I'm going to
  1664. 1:19:41create
  1665. 1:19:42new feature item um typescript jsx file
  1666. 1:19:48okay let's hit the enter click add now
  1667. 1:19:52export default
  1668. 1:19:55um
  1669. 1:19:56function feature
  1670. 1:20:00item okay we are going to
  1671. 1:20:03return some template from
  1672. 1:20:07here function feature okay we can remove
  1673. 1:20:10these props and actually we're going to
  1674. 1:20:11accept right here feature then we Define
  1675. 1:20:14the type feature as a type of feature
  1676. 1:20:19and we have to import that from types
  1677. 1:20:22cool and if we go into T6 so this is
  1678. 1:20:25actually a card so let me think I think
  1679. 1:20:31we can just take this
  1680. 1:20:34out or I think we should take this part
  1681. 1:20:37out this is card go in the feature item
  1682. 1:20:41put this
  1683. 1:20:43here uh and we are going to render the
  1684. 1:20:46feature item itself so here we need the
  1685. 1:20:49feature item let's use pre-ex and just
  1686. 1:20:52use
  1687. 1:20:53json.
  1688. 1:20:56stringify uh
  1689. 1:20:58provide actually it should be uppercase
  1690. 1:21:00all uppercase Json stringify feature
  1691. 1:21:04undefined
  1692. 1:21:06to cool and right here we need that
  1693. 1:21:12iteration of features
  1694. 1:21:13data and we're going to use feature item
  1695. 1:21:18providing that
  1696. 1:21:20feature okay cool now we save that and
  1697. 1:21:24let's check in the
  1698. 1:21:25browser uh we don't have V server up and
  1699. 1:21:28running mpm run Dev we have to execute
  1700. 1:21:32this okay that's good let me drink a
  1701. 1:21:36little bit of
  1702. 1:21:39water okay it is going to
  1703. 1:21:45reload and here we
  1704. 1:21:47have data for each feature okay we have
  1705. 1:21:51different cards let's actually open this
  1706. 1:21:53feature item and give it also some class
  1707. 1:21:56like margin bottom four maybe something
  1708. 1:21:59like this and we have these cards for
  1709. 1:22:01each feature which is pretty cool um
  1710. 1:22:06okay so we have some width and height
  1711. 1:22:09definition on the dashboard as well as
  1712. 1:22:11on the features which I'm going to move
  1713. 1:22:13in the layout like inside index we have
  1714. 1:22:16this pading y12 MX and so on which you
  1715. 1:22:19have on the dashboard page as well so
  1716. 1:22:22let me cut this delete the closing text
  1717. 1:22:24as
  1718. 1:22:26well and let's open dashboard as well
  1719. 1:22:31and cut this delete this closing D tags
  1720. 1:22:35as well we can leave this here and let's
  1721. 1:22:38open this authenticated layout and if we
  1722. 1:22:41scroll down
  1723. 1:22:42below here we have this main tag and
  1724. 1:22:45we're going to wrap this
  1725. 1:22:48St around this main tag these two divs
  1726. 1:22:51so if I save this reload the page the
  1727. 1:22:54result is not going to change so on
  1728. 1:22:55features we see the same result and on
  1729. 1:22:57dashboard we see the same result let's
  1730. 1:22:59zoom in into 100 and now let's focus on
  1731. 1:23:04rendering um each individual feature
  1732. 1:23:08item okay let's open feature item let's
  1733. 1:23:14delete this
  1734. 1:23:16and actually I'm going to do the
  1735. 1:23:18following so first I'm going to Define
  1736. 1:23:20one div with uh with flex
  1737. 1:23:26okay actually I think we need to give
  1738. 1:23:29Flex to this so let's give it flex and
  1739. 1:23:32let's give it gap of
  1740. 1:23:39eight so then I need two divs one is
  1741. 1:23:43going to be for the title for the name
  1742. 1:23:46of the feature and description of the
  1743. 1:23:47feature and second is going to be for
  1744. 1:23:51the up vote and down vote but
  1745. 1:23:55for that specific feature okay so we
  1746. 1:23:57need two
  1747. 1:23:58divs so I'm going to now use hero
  1748. 1:24:02icons hero econs and we can search for
  1749. 1:24:06Chevon uh I want this icon Chevron up
  1750. 1:24:11this
  1751. 1:24:12one why I can copy this
  1752. 1:24:15okay um this is Chevon up and then I
  1753. 1:24:20need Chevon down as well so I need these
  1754. 1:24:23two SVG icons and I'm going to also put
  1755. 1:24:27them inside span
  1756. 1:24:31Texs okay let's put this inside span as
  1757. 1:24:35well or maybe we should even change this
  1758. 1:24:37into buttons let's make this
  1759. 1:24:40button and button and I'm going to put
  1760. 1:24:45span here which is going to be number of
  1761. 1:24:48um app FS let's put 12 here okay so but
  1762. 1:24:52because we are using react we need we we
  1763. 1:24:54should not use this dashed approach we
  1764. 1:24:57should change this into camel case
  1765. 1:24:59approach um field rule clip
  1766. 1:25:02[Music]
  1767. 1:25:05rule what else do we
  1768. 1:25:12have
  1769. 1:25:14Okay
  1770. 1:25:16cool so I want to put that div in front
  1771. 1:25:20of the name and the description so this
  1772. 1:25:24is going to be so this one has display
  1773. 1:25:26Flex this is going to be in front of it
  1774. 1:25:28and now this one should have Flex of one
  1775. 1:25:31and inside here we need H2 let's give it
  1776. 1:25:36class name of text um two Excel let's
  1777. 1:25:42give it also margin button two and I
  1778. 1:25:44want to Output feature. name the auto
  1779. 1:25:47completion works perfectly okay then I
  1780. 1:25:51want to display the feature description
  1781. 1:25:53so inside paragraph let's output
  1782. 1:25:56feature. description let's save this and
  1783. 1:26:00have a look in the
  1784. 1:26:01browser
  1785. 1:26:03okay what is
  1786. 1:26:05this I probably copied incorrect one so
  1787. 1:26:10that is Chon
  1788. 1:26:12up this is Chon
  1789. 1:26:16up F
  1790. 1:26:19rule rule
  1791. 1:26:21here oops save that
  1792. 1:26:25okay cool uh we just need to give this
  1793. 1:26:29one uh
  1794. 1:26:32FX and flex column and we probably need
  1795. 1:26:37items Center as
  1796. 1:26:41well okay that's nice however we have to
  1797. 1:26:44increase the size a little bit so on
  1798. 1:26:47that SVG let's provide text uh to Excel
  1799. 1:26:52and let's give it font semi Bol as well
  1800. 1:26:56and on that
  1801. 1:26:58SVG we have to adjust the class name
  1802. 1:27:01let's change this into
  1803. 1:27:0312 and here as well we have to change
  1804. 1:27:08this into 12 to increase the size a
  1805. 1:27:11little bit okay that's much better we
  1806. 1:27:13have the title we have the description
  1807. 1:27:16however I want to make that description
  1808. 1:27:18uh kind of um show more show less
  1809. 1:27:22toggling uh type of description so
  1810. 1:27:24here's what I'm going to do so I'm going
  1811. 1:27:26to
  1812. 1:27:28Define State
  1813. 1:27:31const uh we need is
  1814. 1:27:34expanded expanded and
  1815. 1:27:38Set uh set is
  1816. 1:27:42expanded okay we are going to use state
  1817. 1:27:47for this and the default one should be
  1818. 1:27:49false so the by default it is not
  1819. 1:27:52expanded okay and and I'm going to
  1820. 1:27:54Define also toggle read more which is
  1821. 1:27:59going to be
  1822. 1:28:02function and we're going to call set is
  1823. 1:28:05expanded to equal
  1824. 1:28:07not uh
  1825. 1:28:09read more not is
  1826. 1:28:13expanded now we have this let's collapse
  1827. 1:28:17this T which is for these arrows and
  1828. 1:28:21here we have this paragraph and we want
  1829. 1:28:23to check
  1830. 1:28:24so if is expanded if this is expanded
  1831. 1:28:30then we're going to display this feature
  1832. 1:28:32description entire description otherwise
  1833. 1:28:36we are going to do the following
  1834. 1:28:38so I want to take feature
  1835. 1:28:43description slice I want to take first
  1836. 1:28:47200 characters so from 0 to 200 and then
  1837. 1:28:51I want to display three dots okay okay
  1838. 1:28:54and after this paragraph I want to have
  1839. 1:28:57a button which will have a text read
  1840. 1:29:01more or read less depending on if it is
  1841. 1:29:03expanded or not so is
  1842. 1:29:07expanded if it's expanded we're going to
  1843. 1:29:09have read uh less otherwise we're going
  1844. 1:29:13to have read more and let's give some
  1845. 1:29:17styles to this button as well so let's
  1846. 1:29:19give it uh text am 500
  1847. 1:29:25and on Hover let's give it
  1848. 1:29:28underline and we need to listen on click
  1849. 1:29:30to that button and we're going to call
  1850. 1:29:32toggle read
  1851. 1:29:34more okay so we save this and have a
  1852. 1:29:38look so let's click on read more read
  1853. 1:29:42less this is awesome this is exactly um
  1854. 1:29:46how I wanted this all right now we can
  1855. 1:29:49move on and start working on creating
  1856. 1:29:51new features or updating features but
  1857. 1:29:53first let's comment everything what we
  1858. 1:29:55changed so far I'm going to group
  1859. 1:29:58everything and this is basically all
  1860. 1:30:00related into displaying
  1861. 1:30:04features create features page and
  1862. 1:30:12display okay
  1863. 1:30:14cool I guess that should be included as
  1864. 1:30:16well isn't it let's amend the comment
  1865. 1:30:20include this two files as well okay Co
  1866. 1:30:24cool so everything is now included
  1867. 1:30:26inside the comment message all right so
  1868. 1:30:28we're going to open now feature
  1869. 1:30:31controller and we have Index right here
  1870. 1:30:33but we're going to actually start
  1871. 1:30:34working on creating new features as well
  1872. 1:30:36as updating features and so on and we
  1873. 1:30:39are going to create new Implement
  1874. 1:30:41actually these new methods for the
  1875. 1:30:44resource crowd operations okay so let's
  1876. 1:30:47start with create let me first focus on
  1877. 1:30:49the server side inesha render feature
  1878. 1:30:52create okay I think this is exactly what
  1879. 1:30:55we want for store we're going to come
  1880. 1:30:57back to this and implement or maybe we
  1881. 1:31:00can try to implement this right now
  1882. 1:31:02request validate we're going to expect
  1883. 1:31:06uh two things here we're going to expect
  1884. 1:31:08name and this name needs to be required
  1885. 1:31:11and it must be string and we accept
  1886. 1:31:13expect a description which is required
  1887. 1:31:17or it's optional let me double check I
  1888. 1:31:20think it's optional because it doesn't
  1889. 1:31:21have this dot right here it is not
  1890. 1:31:23require Reed it is optional so we're
  1891. 1:31:25going to make it nullable and then
  1892. 1:31:28string so finally we have the
  1893. 1:31:31data inside the data we're going to push
  1894. 1:31:34the currently authenticated user
  1895. 1:31:36information like user ID is out ID and
  1896. 1:31:39then on the feature we're going to call
  1897. 1:31:42create we're going to pass the data this
  1898. 1:31:44is going to return just created the
  1899. 1:31:46feature which we actually don't need but
  1900. 1:31:49we need to go back so we need to
  1901. 1:31:52redirect into feature in index with a
  1902. 1:31:55success message feature created
  1903. 1:31:57successfully okay good now let's open
  1904. 1:31:59feature model and we need to Define
  1905. 1:32:01feable here inside the fieldable we need
  1906. 1:32:05name we need description and we need
  1907. 1:32:09user
  1908. 1:32:11ID cool I think we have implemented
  1909. 1:32:13store we will come back and test this
  1910. 1:32:15when we have the front end side ready
  1911. 1:32:17inside show we're going to just return
  1912. 1:32:20intia render feature show and we're
  1913. 1:32:22going to provide feature to be new
  1914. 1:32:24feature resource passing this feature
  1915. 1:32:27model awesome next we have to implement
  1916. 1:32:30edit so in this case we just need to
  1917. 1:32:32return inera render feature edit and we
  1918. 1:32:36have to provide this feature resource
  1919. 1:32:38okay so we are basically doing something
  1920. 1:32:42very identical to
  1921. 1:32:43show but in case of edit the view is
  1922. 1:32:46going to be different we're going to
  1923. 1:32:47display that information inside the form
  1924. 1:32:50so for update we're going to uh call
  1925. 1:32:53request
  1926. 1:32:54again validate we have name required
  1927. 1:32:58string we have description nullable and
  1928. 1:33:00string uh we take that
  1929. 1:33:03data and then on that feature we're
  1930. 1:33:06going to call update passing the data
  1931. 1:33:09and once this is completed we're going
  1932. 1:33:11to return into root a feature index with
  1933. 1:33:14a message feature updated successfully
  1934. 1:33:17and in Destroy we just take that feature
  1935. 1:33:19call delete and then we redirect user
  1936. 1:33:23into feature index with a message
  1937. 1:33:25feature deleted successfully so the back
  1938. 1:33:27end is kind of ready let's open web
  1939. 1:33:31PHP and right here we have only feature
  1940. 1:33:35um list uh rout defined we're going to
  1941. 1:33:39change this
  1942. 1:33:40into excuse me we're going to change
  1943. 1:33:42this into resource okay so we're going
  1944. 1:33:45to have the resource um the root name
  1945. 1:33:48here and the controller
  1946. 1:33:56and I
  1947. 1:33:58think we can remove the name okay now we
  1948. 1:34:00defined the feature resource and we have
  1949. 1:34:03all seven Roots defined and in fact if
  1950. 1:34:06we execute PHP Artisan root column list
  1951. 1:34:10it's going to give us the following
  1952. 1:34:12output these are all the roots defined
  1953. 1:34:14and if we have a look at the feature we
  1954. 1:34:17see all seven crud uh resource rules
  1955. 1:34:20defined here okay awesome
  1956. 1:34:24now we need to create the react Pages
  1957. 1:34:27under Pages feature we have index and we
  1958. 1:34:30have to duplicate this few times first
  1959. 1:34:34let's create show to just view a single
  1960. 1:34:39feature um let's give it title feature
  1961. 1:34:43and then inside BX I want to Output
  1962. 1:34:47feature. name here instead of accepting
  1963. 1:34:50features we're going to Simply accept
  1964. 1:34:52one feature
  1965. 1:34:55this is going to be just
  1966. 1:34:58feature okay we don't need to iterate
  1967. 1:35:01however we want to display the feature
  1968. 1:35:03and the skeleton template of the feature
  1969. 1:35:06should be very similar to this so I'm
  1970. 1:35:08going to actually copy this part put
  1971. 1:35:12that right here but I'm going to change
  1972. 1:35:15this title from dashboard
  1973. 1:35:18into uh feature actually let's change
  1974. 1:35:21this into binding so
  1975. 1:35:25feature uh plus feature. name and
  1976. 1:35:29because we copied this from index I
  1977. 1:35:32noticed that inside index we also have
  1978. 1:35:34dashboard right here which should be
  1979. 1:35:36features okay
  1980. 1:35:39cool next we don't need this is expanded
  1981. 1:35:42we're going to display the entire
  1982. 1:35:43description so we can remove this part
  1983. 1:35:46we don't need this read more read L and
  1984. 1:35:49we have the feature that's give it name
  1985. 1:35:52show save that now let's open feature
  1986. 1:35:57item find this
  1987. 1:35:59H2 and I'm going to put a link right
  1988. 1:36:04here that should be
  1989. 1:36:07link now that should be inertia link
  1990. 1:36:10we're going to put the feature name and
  1991. 1:36:12we have to provide hre uh with the root
  1992. 1:36:15to be oops feature. show and we have to
  1993. 1:36:20provide the
  1994. 1:36:21feature okay awesome
  1995. 1:36:24now if we just open this in the
  1996. 1:36:32browser I just click on this this is
  1997. 1:36:34going to open the feature view page and
  1998. 1:36:37why don't we see the entire information
  1999. 1:36:40let's open developer tools we probably
  2000. 1:36:41have some error let's reload the
  2001. 1:36:45page no we don't see any
  2002. 1:36:49errors then what's the
  2003. 1:36:52issue we have
  2004. 1:36:54feature we display the feature
  2005. 1:36:58description we display the
  2006. 1:37:00feature
  2007. 1:37:02name H2 and paragraph both are actually
  2008. 1:37:07empty
  2009. 1:37:10okay let's see
  2010. 1:37:13feature show we accept the
  2011. 1:37:16feature we return that feature inside
  2012. 1:37:18feature
  2013. 1:37:19show it should be good
  2014. 1:37:24okay let's print what what is the
  2015. 1:37:27feature we'll receive
  2016. 1:37:34here okay yeah I see the reason so the
  2017. 1:37:37feature resource right here has this
  2018. 1:37:40wrap which needs to be disabled so I'm
  2019. 1:37:42going to set this public static wrap
  2020. 1:37:45equals
  2021. 1:37:47false and
  2022. 1:37:49now we are going to see the data
  2023. 1:37:52displayed correctly okay so feature and
  2024. 1:37:55this is the feature name okay awesome so
  2025. 1:37:57this is the view uh page of the feature
  2026. 1:38:00now let's add a button right here and
  2027. 1:38:02Implement creating new feature for this
  2028. 1:38:06let's open index
  2029. 1:38:08TSX and right here we have this feature
  2030. 1:38:11listing and I'm going to create another
  2031. 1:38:14link here and this is going to have root
  2032. 1:38:19actually it should have H ref and then
  2033. 1:38:22it should have root into feature. create
  2034. 1:38:27okay and let's give it also the same
  2035. 1:38:29class names uh what we have for the
  2036. 1:38:33primary button so we can open oops we
  2037. 1:38:37can open primary button and I'm going to
  2038. 1:38:40just copy these classes
  2039. 1:38:43here and put them on that link and let's
  2040. 1:38:47give it text create new feature this
  2041. 1:38:51going to open feature create page let's
  2042. 1:38:54see if the button is there okay the
  2043. 1:38:55button is there let's give it let's put
  2044. 1:38:58this probably in a div to make it kind
  2045. 1:39:00of a on full width and then give it
  2046. 1:39:04margin bottom
  2047. 1:39:07eight okay awesome now when I click this
  2048. 1:39:09it's not going to do anything because we
  2049. 1:39:11don't have that feature create TSX file
  2050. 1:39:15so let me copy show and call this
  2051. 1:39:20create okay we need form let's open
  2052. 1:39:24index and we have the form uh no we we
  2053. 1:39:27don't have form defined uh
  2054. 1:39:30anywhere actually so let's give it
  2055. 1:39:34create new feature the same text right
  2056. 1:39:40here on this head
  2057. 1:39:42title cool um and we are going
  2058. 1:39:47to
  2059. 1:39:48delete this
  2060. 1:39:52part okay and we have to create the form
  2061. 1:39:55for this I'm going to open edit. tsix
  2062. 1:39:58which is coming from this Pages profile
  2063. 1:40:01and this is an example of the input
  2064. 1:40:03Fields um inside the Lal Breeze default
  2065. 1:40:06template so if we click on profile we
  2066. 1:40:08see the input Fields so we're going to
  2067. 1:40:10just copy a couple of input Fields like
  2068. 1:40:12let's open this update profile
  2069. 1:40:14information and scroll down below and we
  2070. 1:40:17are going to see the following form and
  2071. 1:40:19the following elements so what I want is
  2072. 1:40:21just copy this div okay and open create
  2073. 1:40:26let's create our
  2074. 1:40:28form uh we don't need action we need on
  2075. 1:40:32submit uh let's call this create feature
  2076. 1:40:37we're going to create that um function
  2077. 1:40:39create feature function let's paste it
  2078. 1:40:43and now let's focus on the JavaScript
  2079. 1:40:45side okay so we need to uh create the
  2080. 1:40:49form I'm going to use in user form
  2081. 1:40:54and we have to provide idid of the
  2082. 1:40:56feature well when we create new feature
  2083. 1:40:59we don't need to to have ID we can
  2084. 1:41:02provide ID equals null or we can
  2085. 1:41:04completely skip that so name is actually
  2086. 1:41:07empty string and description is also
  2087. 1:41:11empty string now here we accept data we
  2088. 1:41:15destructure that form and take out the
  2089. 1:41:17data we take out set data we take out
  2090. 1:41:20processing flag um let's move this down
  2091. 1:41:25like
  2092. 1:41:26this okay we take out errors as well and
  2093. 1:41:31we need
  2094. 1:41:33post okay now let's Define con create
  2095. 1:41:38feature
  2096. 1:41:42function
  2097. 1:41:43okay uh and we accept an event
  2098. 1:41:47here okay so now this is uh something
  2099. 1:41:50we're going to handle so this EF we're
  2100. 1:41:53going to going to change basically this
  2101. 1:41:54form into um form Handler or something
  2102. 1:41:59like this similar to what we have in
  2103. 1:42:01this update profile information let's
  2104. 1:42:02scroll down below uh form even Handler
  2105. 1:42:05that's correct so we're going to tell
  2106. 1:42:08typescript that hey this Handler the
  2107. 1:42:12create feature is actually an instance
  2108. 1:42:14of for Ev Handler and then typescript
  2109. 1:42:18knows that this EF is actually react
  2110. 1:42:20form event for element
  2111. 1:42:24on that e we're going to call prevent
  2112. 1:42:27default and then we're going to submit
  2113. 1:42:29the data through post uh the post what
  2114. 1:42:32we take out from this form post we're
  2115. 1:42:36going to
  2116. 1:42:37use
  2117. 1:42:39root um
  2118. 1:42:42feature feature. store and we have to
  2119. 1:42:46provide uh a preserve scroll to be
  2120. 1:42:51true okay that's cool uh we can take
  2121. 1:42:54this processing and we can give it to a
  2122. 1:42:58submit button uh when we create the
  2123. 1:43:01submit button somewhere right here okay
  2124. 1:43:03uh but first let's adjust this so input
  2125. 1:43:06label for name okay that's good it is
  2126. 1:43:08for name um set data name okay so this
  2127. 1:43:12is actually exactly how I want now I can
  2128. 1:43:15duplicate this second time but in this
  2129. 1:43:19case we need text area and if you open
  2130. 1:43:21this text input this is coming coming
  2131. 1:43:23from components folder and there's no
  2132. 1:43:25text area okay so I'm going to duplicate
  2133. 1:43:28this text input and let let's call this
  2134. 1:43:31text area input I cannot call this text
  2135. 1:43:35area because text area is actually the
  2136. 1:43:38native HTML element now let's open this
  2137. 1:43:41text area input and we're going to
  2138. 1:43:42change a few things first scroll down
  2139. 1:43:46below and instead of input we need text
  2140. 1:43:49area we don't need type at all uh text
  2141. 1:43:52area is not self closing so we need
  2142. 1:43:55closing tag as well I think we don't
  2143. 1:43:58need this local ref because this is only
  2144. 1:44:00for fuckus sing if we have um ease
  2145. 1:44:03focused then we're going to autofocus on
  2146. 1:44:05the text area which is something we
  2147. 1:44:06don't need so I'm going to remove this
  2148. 1:44:08ease focused remove this remove this ref
  2149. 1:44:13as
  2150. 1:44:14well uh what else
  2151. 1:44:23uh we can remove this uh oh I think we
  2152. 1:44:26need this local ref but instead of HTML
  2153. 1:44:30input element I guess that should be
  2154. 1:44:32html text area
  2155. 1:44:35element and right here as well so now we
  2156. 1:44:39can have this local ref if we need that
  2157. 1:44:44and what else so we don't need type we
  2158. 1:44:46can remove that we have the class name
  2159. 1:44:48props uh and
  2160. 1:44:55I think we don't need this as
  2161. 1:44:58well let's remove extra Imports use
  2162. 1:45:01effect something we don't need okay
  2163. 1:45:02anyway I think that's enough let's open
  2164. 1:45:05this
  2165. 1:45:06create um
  2166. 1:45:10TSX text area
  2167. 1:45:12input uh and we have to provide the
  2168. 1:45:15value which is going to be
  2169. 1:45:18data description and we use description
  2170. 1:45:21um inside on change
  2171. 1:45:23and inside this errors as well we don't
  2172. 1:45:25need this is focused we don't need
  2173. 1:45:27autocomplete however it should be
  2174. 1:45:29required and the ID should be
  2175. 1:45:32description and we're going to change
  2176. 1:45:34this HTML 4 into description as well and
  2177. 1:45:38the value for label is going to be
  2178. 1:45:43description okay so this is the create
  2179. 1:45:45page now let's open uh features page and
  2180. 1:45:48we're going to click on this create new
  2181. 1:45:50feature and it opens that page now now
  2182. 1:45:54on that form let's give it w full to
  2183. 1:45:58stretch it on full width okay so on this
  2184. 1:46:01div we're going to add margin bottom uh
  2185. 1:46:06eight this is the first div we have in
  2186. 1:46:09distance on the second D again margin
  2187. 1:46:14bottom eight
  2188. 1:46:18oops and finally we need the button uh
  2189. 1:46:21let me grab that button from the profile
  2190. 1:46:23file page
  2191. 1:46:24again scroll down below we have this div
  2192. 1:46:27another
  2193. 1:46:29div something else and finally we have
  2194. 1:46:32this primary button I'm going to get
  2195. 1:46:36this on the create page
  2196. 1:46:39oops right here we need this primary
  2197. 1:46:43button okay it has disabled when
  2198. 1:46:47processing cool now let's have a look
  2199. 1:46:50okay this is awesome so now when we
  2200. 1:46:52click on save it should make the request
  2201. 1:46:54and create new feature let's try this
  2202. 1:46:57new feature one click on save this
  2203. 1:47:01actually required however we have it
  2204. 1:47:04optional so let's just remove this
  2205. 1:47:07required on the text area input click on
  2206. 1:47:10Save okay something happened it was
  2207. 1:47:13failed now we need to understand why it
  2208. 1:47:15was
  2209. 1:47:17failed okay where is that coming from
  2210. 1:47:25can't read properties of null reading
  2211. 1:47:27slice okay something was going to wrong
  2212. 1:47:29let's open features and now we have 101
  2213. 1:47:33features and let's check the latest one
  2214. 1:47:35which we just
  2215. 1:47:40created it has description to be
  2216. 1:47:44null okay so
  2217. 1:47:48what if the description is null okay
  2218. 1:47:50that's causing the problem let's open
  2219. 1:47:54Feature Feature
  2220. 1:47:57item and here we check if is expanded
  2221. 1:48:01okay we by default we take this slice
  2222. 1:48:04instead of that uh accessing this
  2223. 1:48:07feature description immediately when it
  2224. 1:48:10is n this is causing problems we can use
  2225. 1:48:13the following if the feature description
  2226. 1:48:14exists if not let's take empty string
  2227. 1:48:17and then Slice on the empty string will
  2228. 1:48:20work okay now we don't have any
  2229. 1:48:24we don't have any errors except that key
  2230. 1:48:27which we should probably add when
  2231. 1:48:30iterating over feature items so for this
  2232. 1:48:33we need to
  2233. 1:48:34open index and right here we're going to
  2234. 1:48:38add
  2235. 1:48:38key uh feature.
  2236. 1:48:42ID awesome uh however we don't need this
  2237. 1:48:45read more read less because yeah the
  2238. 1:48:47description is actually um very small
  2239. 1:48:51okay what we can do is the following so
  2240. 1:48:54we can take the feature description and
  2241. 1:48:56write the following if statement so if
  2242. 1:48:58the feature description or we can also
  2243. 1:49:01do the following if the feature
  2244. 1:49:02description
  2245. 1:49:04or empty
  2246. 1:49:06string if the length of that is more
  2247. 1:49:11than 200 okay then we do the
  2248. 1:49:17following so we display the following p
  2249. 1:49:23otherwise we don't do
  2250. 1:49:25anything uh and we also display this
  2251. 1:49:27pattern in that case so in this case we
  2252. 1:49:30need to use
  2253. 1:49:32fragment just like
  2254. 1:49:35this awesome now we don't display
  2255. 1:49:38anything we just have the title of the
  2256. 1:49:40feature nothing else but this one has
  2257. 1:49:41read more and read less and just like
  2258. 1:49:44this we are able to implement creating
  2259. 1:49:47new features let's create another one
  2260. 1:49:50another cool feature
  2261. 1:49:54uh with some test description anyway so
  2262. 1:49:59let's just click on Save uh another cool
  2263. 1:50:02okay what's
  2264. 1:50:07that okay yeah that makes sense so the
  2265. 1:50:11length is
  2266. 1:50:13actually
  2267. 1:50:15not more than 200 that's why we don't
  2268. 1:50:18see
  2269. 1:50:20this uh and we can write another
  2270. 1:50:24if
  2271. 1:50:27here so if the description is less than
  2272. 1:50:31or equal to 100 then we simply
  2273. 1:50:35display um inside
  2274. 1:50:37paragraph We display feature.
  2275. 1:50:40description directly without anything
  2276. 1:50:43else so in this case we don't have read
  2277. 1:50:44more read less but we have the entire
  2278. 1:50:47feature and again if we create new one
  2279. 1:50:49with some um lurm ipsum
  2280. 1:50:58text test
  2281. 1:51:00feature click on Save now we see this
  2282. 1:51:03one and it has this read more read less
  2283. 1:51:05which I
  2284. 1:51:06want uh this we can remove okay this is
  2285. 1:51:11cool awesome so now we have this um
  2286. 1:51:15creating of new features
  2287. 1:51:17implemented uh and we have the feature
  2288. 1:51:20Details page
  2289. 1:51:23okay let me clean up the console logs
  2290. 1:51:25what we see right here which is coming
  2291. 1:51:26from the authenticated
  2292. 1:51:30layout authenticated layout we have this
  2293. 1:51:34conso log user we need to remove this
  2294. 1:51:37and what else do we have from show T6 we
  2295. 1:51:41have this feature as well which I am
  2296. 1:51:43going to
  2297. 1:51:45remove cool now we need to comment
  2298. 1:51:48everything what we implemented so far
  2299. 1:51:50this is related to
  2300. 1:51:54Implement creating new feature and
  2301. 1:51:58feature show
  2302. 1:52:02page cool we can push
  2303. 1:52:06everything I think I don't have the
  2304. 1:52:08remote repository defined yet I'm going
  2305. 1:52:10to push it later
  2306. 1:52:12everything and the next is to implement
  2307. 1:52:15feature edit and delete let me close
  2308. 1:52:18everything and I'm going to put a drop-
  2309. 1:52:21down right here in the probably in the
  2310. 1:52:24feature listing as well and I'm going to
  2311. 1:52:27use uh similar drop down like we have in
  2312. 1:52:29this authenticated layout so let's
  2313. 1:52:33open authenticated layout and we're
  2314. 1:52:36going to search for the dropdown here it
  2315. 1:52:39is let me copy the dropdown and next
  2316. 1:52:43let's open feature
  2317. 1:52:47item okay so this is up vote down vote
  2318. 1:52:52this is the content and I'm going to
  2319. 1:52:54create another div right here and I am
  2320. 1:52:57going to paste the drop down but
  2321. 1:52:59actually I'm going to use the same
  2322. 1:53:00dropdown on the feature Details page so
  2323. 1:53:04better to create new component for that
  2324. 1:53:08dropdown so let's call
  2325. 1:53:10this let's call this um feature actions
  2326. 1:53:16dropdown let's hit the
  2327. 1:53:18enter export default function
  2328. 1:53:23feature actions
  2329. 1:53:25dropdown okay we are going to return the
  2330. 1:53:28following HTML or
  2331. 1:53:32j6 uh
  2332. 1:53:34let's fix the
  2333. 1:53:36indentation and instead of username I'm
  2334. 1:53:39going to use the H so-called Ellipsis
  2335. 1:53:44icon so let's search for Ellipsis
  2336. 1:53:47vertical icon this is what I'm going to
  2337. 1:53:49use instead of this SVG
  2338. 1:53:54let me paste this and we're going to
  2339. 1:53:56change this into camel case
  2340. 1:54:01version cool
  2341. 1:54:04and then scroll down below instead of
  2342. 1:54:08profile edit we need uh Feature Feature
  2343. 1:54:12edit but we have to provide the feature
  2344. 1:54:14as well so we have to accept feature
  2345. 1:54:17right here feature and then the def
  2346. 1:54:21let's define the prop a feature is an
  2347. 1:54:23instance of feature so inside edit we're
  2348. 1:54:26going to provide feature. ID and this is
  2349. 1:54:29going to be to delete the feature let's
  2350. 1:54:31change the text edit
  2351. 1:54:34feature and this is going to be
  2352. 1:54:37delete
  2353. 1:54:39feature okay feature. destroy and we
  2354. 1:54:44have to provide feature. ID again now
  2355. 1:54:48let's open feature item and let's use
  2356. 1:54:51feature actions drop down providing the
  2357. 1:54:55feature that's cool now let's have a
  2358. 1:54:58look in the feature listing here we see
  2359. 1:55:01this three dot click on this this going
  2360. 1:55:02to open the drop down edit feature and
  2361. 1:55:05delete feature if we click on this edit
  2362. 1:55:08feature it doesn't do anything because
  2363. 1:55:10we don't have the corresponding um blade
  2364. 1:55:13file if we click on this delete feature
  2365. 1:55:16which by the
  2366. 1:55:17way should make the request with method
  2367. 1:55:21delete
  2368. 1:55:23Okay then if I click on this delete
  2369. 1:55:26feature
  2370. 1:55:28it well what it did it
  2371. 1:55:31do it should have deleted it actually
  2372. 1:55:34deleted that feature so click on delete
  2373. 1:55:37again yeah now this is gone look at this
  2374. 1:55:40so the delete actually works and the
  2375. 1:55:41features are successfully deleted why do
  2376. 1:55:44we have this this is coming from index
  2377. 1:55:48okay let's open index as well and remove
  2378. 1:55:52these
  2379. 1:55:54features now we need to
  2380. 1:55:57create another page under JS Pages
  2381. 1:56:02feature similar to create but this is
  2382. 1:56:04going to be
  2383. 1:56:06edit okay so here inside the
  2384. 1:56:10edit hold on let's open create I noticed
  2385. 1:56:13something so inside create we accept
  2386. 1:56:16this feature probably because we copied
  2387. 1:56:18that create from show which we don't
  2388. 1:56:20need so I'm going to remove
  2389. 1:56:23this cool now let's open edit inside
  2390. 1:56:26edit we definitely need this feature and
  2391. 1:56:28we're going to take and provide um I
  2392. 1:56:32think we don't need ID we don't need ID
  2393. 1:56:35here we just need
  2394. 1:56:36name feature. name and feature dot
  2395. 1:56:44feature.
  2396. 1:56:46description however instead of create
  2397. 1:56:48feature we can rename this and call
  2398. 1:56:51update feature we have to rename it here
  2399. 1:56:55as well but when we make the update
  2400. 1:56:58first from this form we should take put
  2401. 1:57:01not post so here we're going to use put
  2402. 1:57:04and then we should change the root from
  2403. 1:57:06featur tour into feature update and this
  2404. 1:57:09is the place where we provide feature ID
  2405. 1:57:12this is the way how we tell L which
  2406. 1:57:14feature we want to update not putting
  2407. 1:57:16the ID right here so in the following
  2408. 1:57:19way we perform the update uh let's just
  2409. 1:57:22change
  2410. 1:57:23this uh edit feature and let's use
  2411. 1:57:28inside bags feature.
  2412. 1:57:31name okay cool and inside the title we
  2413. 1:57:35need edit let's change this into binding
  2414. 1:57:39edit
  2415. 1:57:41feature plus
  2416. 1:57:43feature.
  2417. 1:57:46name okay now let's have a look so click
  2418. 1:57:51on edit feature it is going to open the
  2419. 1:57:53edit feature page edit feature and this
  2420. 1:57:56is going to be it however I think um
  2421. 1:57:59this B tag doesn't work because I think
  2422. 1:58:02everything is in bold to be
  2423. 1:58:05honest edit
  2424. 1:58:07feature and this is the
  2425. 1:58:10btag yeah everything is actually inside
  2426. 1:58:12the Bold B is the boulder however that
  2427. 1:58:17H2 also
  2428. 1:58:19has font weight 600
  2429. 1:58:24yeah okay anyway it's not big deal I
  2430. 1:58:26just uh I'm used to putting the actual
  2431. 1:58:29name inside um something to easily
  2432. 1:58:32identify that we can also use double
  2433. 1:58:35quotes we know what is the actual
  2434. 1:58:37feature name in this case uh and this is
  2435. 1:58:40the actual feature description by the
  2436. 1:58:42way we can change the number of rules in
  2437. 1:58:45the text area during the edit so we can
  2438. 1:58:48provide um rules we don't have that by
  2439. 1:58:52the way so inside this text area we can
  2440. 1:58:55add
  2441. 1:58:56rules um
  2442. 1:58:59equals by default let's give it two
  2443. 1:59:02rowes but we can overwrite this so let's
  2444. 1:59:05format this by the way because by
  2445. 1:59:07default that was on four spaces but we
  2446. 1:59:09have two spaces configured in the editor
  2447. 1:59:11config so that's good uh however that
  2448. 1:59:15row needs to be
  2449. 1:59:18defined also in the props
  2450. 1:59:23so input HTML
  2451. 1:59:25attributes for the text area element we
  2452. 1:59:29have this is focus which we don't need
  2453. 1:59:31but we need
  2454. 1:59:33rules so rules is
  2455. 1:59:37number basically this defines the type
  2456. 1:59:41inside the typ script so this defines
  2457. 1:59:42the type uh we're going to change this
  2458. 1:59:44into text area input so this defines the
  2459. 1:59:49type what type of props
  2460. 1:59:52uh that component expects and using the
  2461. 1:59:55end symbol we are going to merge two
  2462. 1:59:58types into um single type so now
  2463. 2:00:03whatever is available whatever is
  2464. 2:00:05defined in the following type plus rows
  2465. 2:00:09which should be numbered and that's and
  2466. 2:00:11that's that's the way how we uh Define
  2467. 2:00:14the rows probe here and we can provide
  2468. 2:00:17rowes equals rows and if we go into edit
  2469. 2:00:22now we can provide rows equals six for
  2470. 2:00:25example so if we refresh the page we're
  2471. 2:00:28going to
  2472. 2:00:29see six rows by default and we probably
  2473. 2:00:32need uh something in the description as
  2474. 2:00:35well we have only one and we should
  2475. 2:00:37probably change this default one into
  2476. 2:00:40something like six because we use that
  2477. 2:00:42text area only when creating new feature
  2478. 2:00:45or editing the feature okay now let's
  2479. 2:00:48click on this edit feature and let's put
  2480. 2:00:50some text like updated and let's click
  2481. 2:00:54on
  2482. 2:00:54save it looks like that was updated and
  2483. 2:00:57we will redirect it back however I think
  2484. 2:01:00we don't display the message so if we
  2485. 2:01:03try to create new feature I want the
  2486. 2:01:05message to be displayed as
  2487. 2:01:09well test
  2488. 2:01:11feature some description save yeah the
  2489. 2:01:15message is not displayed however in the
  2490. 2:01:18feature controller when we create those
  2491. 2:01:21features like inside the store we
  2492. 2:01:24redirect user back with the session um
  2493. 2:01:27variable so what we need to do is open
  2494. 2:01:30handle inera request and right here we
  2495. 2:01:34are going to take success message from
  2496. 2:01:39session and we're going to provide to
  2497. 2:01:41every page okay then we are going to
  2498. 2:01:46open authenticated
  2499. 2:01:49layout and let's take that just like we
  2500. 2:01:52are taking the user we are going to take
  2501. 2:01:55message or let's call this success which
  2502. 2:01:59is going to be string and we're going to
  2503. 2:02:02take this through use use page. props do
  2504. 2:02:08success this is the way how we provided
  2505. 2:02:10that success message okay so uh what's
  2506. 2:02:14the
  2507. 2:02:19issue okay unknown is not assignable uh
  2508. 2:02:23to type string so this success is
  2509. 2:02:26actually
  2510. 2:02:28unknown okay what is this props this is
  2511. 2:02:31Page
  2512. 2:02:35props well in this specific case for
  2513. 2:02:39Simplicity I'm going to change this
  2514. 2:02:40success into any okay then we take this
  2515. 2:02:45success and we need to
  2516. 2:02:48display um message somewhere and let me
  2517. 2:02:52put this right here actually I'm going
  2518. 2:02:55to use
  2519. 2:02:56alert template or we can create
  2520. 2:02:59something custom like uh BG
  2521. 2:03:05Emerald Emerald um like
  2522. 2:03:09400 uh we give it pading of uh six let's
  2523. 2:03:15give it
  2524. 2:03:16rounded and then output success message
  2525. 2:03:20here and if success exists then we
  2526. 2:03:24output the entire
  2527. 2:03:26message okay now let's create
  2528. 2:03:31new test okay feature created
  2529. 2:03:34successfully let's change some pings
  2530. 2:03:37instead
  2531. 2:03:39of uh let's give it pting X6 but pting
  2532. 2:03:46y4 that's I think better and let's give
  2533. 2:03:48it also margin bottom of eight
  2534. 2:03:56yeah I think we can change this
  2535. 2:03:59into
  2536. 2:04:01300 and we give it text
  2537. 2:04:06Emerald 700 something like this or even
  2538. 2:04:10800 anyway so this is something uh I
  2539. 2:04:12don't want to spend some time on this
  2540. 2:04:14feature created successfully okay maybe
  2541. 2:04:16we should completely remove that text
  2542. 2:04:18color and we just return this into like
  2543. 2:04:21five
  2544. 2:04:22500 okay that's not bad now if we try to
  2545. 2:04:26edit new feature click on update or say
  2546. 2:04:29or update the feature updated
  2547. 2:04:30successfully we see the following
  2548. 2:04:33message and just like this we have
  2549. 2:04:35implemented creating new features
  2550. 2:04:38updating features as well as deleting
  2551. 2:04:41the features you can go ahead and uh
  2552. 2:04:44like take the challenge and try to add
  2553. 2:04:46the confirmation message into the delete
  2554. 2:04:48feature which I'm not going to do but I
  2555. 2:04:51think it's going to be good challenge
  2556. 2:04:52for you now let's comment the changes
  2557. 2:04:54what we made so far update Implement
  2558. 2:04:56updating and deleting features click on
  2559. 2:04:59comment and now I'm going to focus on up
  2560. 2:05:03vote and down vote functionality so
  2561. 2:05:06first I want to generate new
  2562. 2:05:09controller PHP artisan make controller
  2563. 2:05:14and let's call this up vote
  2564. 2:05:19controller okay the controller was
  2565. 2:05:21created
  2566. 2:05:22let's open up vote controller here it
  2567. 2:05:25goes okay so before I start implementing
  2568. 2:05:29this controller let's talk a little bit
  2569. 2:05:31how we're going to do or what we are
  2570. 2:05:33going to do so the state right here
  2571. 2:05:37basically when everything is white means
  2572. 2:05:39that the current user me I have not
  2573. 2:05:42added my up Vote or down vote to the
  2574. 2:05:45following feature as soon as I add my up
  2575. 2:05:49Vote or down vote then the arrow the
  2576. 2:05:52corresponding Arrow should turn into a
  2577. 2:05:55different color like the following color
  2578. 2:05:58uh I think it's called Amber okay so
  2579. 2:06:01that will indicate that I have
  2580. 2:06:03personally up voted that specific
  2581. 2:06:07feature okay and whenever I also refresh
  2582. 2:06:09the page I want to display uh the
  2583. 2:06:13corresponding color on the Up vot Down
  2584. 2:06:16vs okay so this is something we are
  2585. 2:06:19going to do okay let's focus on uh
  2586. 2:06:22actually displaying that information
  2587. 2:06:24first and then we're going to
  2588. 2:06:26implement um actually up voting and down
  2589. 2:06:29voting so for this let's open up votes
  2590. 2:06:33table and we're going to add a couple of
  2591. 2:06:36Records right
  2592. 2:06:38here let's add three records so feature
  2593. 2:06:42uh the latest feature which
  2594. 2:06:44is whatever which has ID one actually I
  2595. 2:06:48think the latest features or which
  2596. 2:06:51features should be at the top that's a
  2597. 2:06:52good question uh okay let's leave it
  2598. 2:06:54everything as it is right now we can
  2599. 2:06:55come back to this so feature
  2600. 2:06:58one uh user one user two user three one
  2601. 2:07:01user can have only one up Vote or down
  2602. 2:07:04vote and now let's add all ones so all
  2603. 2:07:07users gave uh up folds to the specific
  2604. 2:07:11feature now if I save this everything we
  2605. 2:07:13need to display this information right
  2606. 2:07:15here the count should be three instead
  2607. 2:07:18of 12 here let's start with this feature
  2608. 2:07:23controller scroll up find this index and
  2609. 2:07:27we are going to do a few things so we
  2610. 2:07:32want we want to um take the count which
  2611. 2:07:36going to be UPF count so for this I'm
  2612. 2:07:39going to use with count and we have to
  2613. 2:07:43provide the relations so the relation in
  2614. 2:07:47this case is going to be up folds
  2615. 2:07:49relation up Folds and we're going to
  2616. 2:07:52select this as upvote count then we
  2617. 2:07:56provide the function here we accept that
  2618. 2:07:58quy uh and on that quy we are going to
  2619. 2:08:02execute select we just want to select
  2620. 2:08:05one information and in this case let me
  2621. 2:08:07use just TB rule uh I'm using eliminate
  2622. 2:08:11support facets TB rule select and we are
  2623. 2:08:14going to execute sum so I want to take
  2624. 2:08:19the sum of the upvs if the UPF is one or
  2625. 2:08:26um let me just write this I think it's
  2626. 2:08:29going to be better to just write this
  2627. 2:08:31and then explain okay so case I'm going
  2628. 2:08:34to use case
  2629. 2:08:37when um
  2630. 2:08:40upb actually I think it was uh
  2631. 2:08:42completing something actually nice okay
  2632. 2:08:46anyway um up vote equals 1 then one else
  2633. 2:08:53we're going to take minus one so I'm
  2634. 2:08:57basically creating a semicolon T I'm
  2635. 2:09:00creating a sum of ones and minus ones so
  2636. 2:09:05if the up is one then I simply take it
  2637. 2:09:08as one otherwise if the UPF is not one
  2638. 2:09:11which means it's zero I'm taking minus
  2639. 2:09:14one and I'm creating this sum and I'm
  2640. 2:09:17taking this sum and selecting this
  2641. 2:09:20inside the up folds relation and just
  2642. 2:09:22give it an alas upfold count now if we
  2643. 2:09:25open this feature resource and we can
  2644. 2:09:28dump uh the object here this object and
  2645. 2:09:32when we just refresh the page we're
  2646. 2:09:34going to see a single
  2647. 2:09:36resource uh single model which has
  2648. 2:09:39upvote count three this is exactly what
  2649. 2:09:42I want from here we can return upvote
  2650. 2:09:46count equals this up vote
  2651. 2:09:53account save that refresh the page
  2652. 2:09:56nothing will happen probably because we
  2653. 2:09:58have to open feature item
  2654. 2:10:01and right here instead of 12 we are
  2655. 2:10:05going to Output feature. dot uh upfold
  2656. 2:10:09count but we will have typescript error
  2657. 2:10:12because the feature model this model
  2658. 2:10:15does not have upfold count so we add
  2659. 2:10:18upfold count to be number
  2660. 2:10:21now we save that and look at this uh
  2661. 2:10:25actually we should take also zero if it
  2662. 2:10:28is uh null because we don't want uh
  2663. 2:10:31empty strings right here so we can do
  2664. 2:10:33this in two ways first we can do this
  2665. 2:10:36right here if that doesn't exist we can
  2666. 2:10:38take just zero or we can also return
  2667. 2:10:41zero from
  2668. 2:10:44here I think it's going to be better to
  2669. 2:10:46return this from the back end so we can
  2670. 2:10:49just take this out reload the page and
  2671. 2:10:53we see three Z zero and everywhere there
  2672. 2:10:57will be zero now let's open up votes and
  2673. 2:11:00I'm going to change let's say that user
  2674. 2:11:02three actually downvoted that specific
  2675. 2:11:06feature so instead of one we're going to
  2676. 2:11:08put right there zero so it is not up
  2677. 2:11:11vote meaning it is down vote so now if I
  2678. 2:11:14refresh the
  2679. 2:11:16page we see instead of three we see just
  2680. 2:11:20one okay that one means that this up
  2681. 2:11:24voted and this upvoted but this down
  2682. 2:11:27voted so two upvotes one down vote
  2683. 2:11:30totally the score is actually one so if
  2684. 2:11:34I simply don't want to down vote don't
  2685. 2:11:37want to up vote I delete the record and
  2686. 2:11:40then we're going to see two right
  2687. 2:11:43here okay that's pretty cool now we need
  2688. 2:11:46to also identify if the current user has
  2689. 2:11:49up voted or downvoted voted so for this
  2690. 2:11:53I'm going to again open this feature
  2691. 2:11:55controller and I'm going to add um the
  2692. 2:11:58following relation with
  2693. 2:12:01exists so with exists we Define the
  2694. 2:12:04relation here and I need two relations
  2695. 2:12:08right here okay so the first one
  2696. 2:12:12actually I'm going to access um upvs in
  2697. 2:12:15any case but I'm going to select two
  2698. 2:12:18different columns first is going to be
  2699. 2:12:20user
  2700. 2:12:21has
  2701. 2:12:23upvoted okay this is going to be the
  2702. 2:12:26function and second is going to be user
  2703. 2:12:30has
  2704. 2:12:32downvoted so two flags will be added
  2705. 2:12:35into the total uh the the query of each
  2706. 2:12:38feature so inside this we on that query
  2707. 2:12:43I'm going to execute the following we so
  2708. 2:12:46we user ID equals to the currently
  2709. 2:12:50authentic user ID which I can select
  2710. 2:12:54from here current user ID this is going
  2711. 2:12:59to be
  2712. 2:13:02out
  2713. 2:13:04ID cool now I have this current user ID
  2714. 2:13:07which I can use here and then I'm
  2715. 2:13:12providing current user ID here and I'm
  2716. 2:13:15going to add additional we upvote equals
  2717. 2:13:191 now let me me copy this put this down
  2718. 2:13:23below uh the current user ID is the user
  2719. 2:13:26ID but the upfold is zero so basically
  2720. 2:13:30now this will select if the current user
  2721. 2:13:33has upvoted if that exists we because we
  2722. 2:13:36are using here with exists so if that
  2723. 2:13:39cury exists this is going to return uh
  2724. 2:13:42true user has upvoted and this is going
  2725. 2:13:45to return
  2726. 2:13:47false now we save this again let's open
  2727. 2:13:49feature resource Let's uh print this DD
  2728. 2:13:53we need zero here save refresh the page
  2729. 2:13:59and now let's have a look out manager
  2730. 2:14:06ID let's use
  2731. 2:14:08out user ID or simply out ID should work
  2732. 2:14:13as
  2733. 2:14:17well
  2734. 2:14:19cool look at this user has up voted
  2735. 2:14:22equals zero user has downvoted equals
  2736. 2:14:25zero this means that the particular user
  2737. 2:14:28which is admin user has neither upvoted
  2738. 2:14:31neither downvoted but if we add the
  2739. 2:14:34record user three upvoted one now
  2740. 2:14:39refresh the page we're going to see user
  2741. 2:14:41has upvoted one user has downvoted zero
  2742. 2:14:45now if we change this into zero refresh
  2743. 2:14:48the page user has uped is zero Z and
  2744. 2:14:51user has downloaded is actually one
  2745. 2:14:55that's pretty cool let's open this
  2746. 2:14:57feature resource remove this and we have
  2747. 2:15:01to return these two columns user has
  2748. 2:15:10upvoted this user has up
  2749. 2:15:16voted and duplicate this user has
  2750. 2:15:20downvoted
  2751. 2:15:22here we need user has downvoted as well
  2752. 2:15:26now if we open this feature item we have
  2753. 2:15:29to mark if the current user has up voted
  2754. 2:15:31this or not and for this I'm going to
  2755. 2:15:34add extra CSS classes so inside the
  2756. 2:15:37class
  2757. 2:15:38name uh I'm going to do the following so
  2758. 2:15:41if feature uh actually we have to again
  2759. 2:15:44open feature and add those two flags
  2760. 2:15:47user has uploaded
  2761. 2:15:51and user has
  2762. 2:15:54downvoted and both actually should be
  2763. 2:15:59Boolean and from this feature Resource
  2764. 2:16:01as well we can cast them into
  2765. 2:16:06Boolean cool in the feature item now we
  2766. 2:16:09can access user has upvoted if the user
  2767. 2:16:13has upvoted we can add text
  2768. 2:16:17Ember 500 otherwise we don't add
  2769. 2:16:20anything
  2770. 2:16:22and right here this is the second button
  2771. 2:16:24if feature user the current user has
  2772. 2:16:28down voted we add text Ember 500
  2773. 2:16:34otherwise we don't add anything we save
  2774. 2:16:37that refresh the
  2775. 2:16:39page and have a look so right here it
  2776. 2:16:43seems like user has
  2777. 2:16:46downvoted now let's open up votes that's
  2778. 2:16:49correct we can change this into one
  2779. 2:16:52refresh the page and now we see user has
  2780. 2:16:56upfold it I'm going to do two tiny
  2781. 2:16:59changes first is that I'm going to
  2782. 2:17:01increase this 500 into 600 here and here
  2783. 2:17:05and then I'm going to make these three
  2784. 2:17:08also in Amber style if the user has up
  2785. 2:17:12voted or
  2786. 2:17:13downvoted
  2787. 2:17:15so let's change this into the following
  2788. 2:17:18way if
  2789. 2:17:21feature has user has up voted or if
  2790. 2:17:26feature user has down
  2791. 2:17:29voted then I am going to add text
  2792. 2:17:34Ember let's move this down
  2793. 2:17:37text uh where is that 600 otherwise an
  2794. 2:17:40empty string okay awesome this is this
  2795. 2:17:44is cool
  2796. 2:17:45now I
  2797. 2:17:47think yeah from the UI perspective i' I
  2798. 2:17:50think everything is done now we can
  2799. 2:17:52focus on actually implementing the
  2800. 2:17:54functionality to up vote and down vote
  2801. 2:17:58so for this let's open up V controller
  2802. 2:18:02and create the function store we're
  2803. 2:18:04going to accept request here and then
  2804. 2:18:08from that request we are going to take
  2805. 2:18:10two
  2806. 2:18:12things um so let's execute valid dat
  2807. 2:18:16we're going to take feature ID
  2808. 2:18:20okay and this is going to be required
  2809. 2:18:23and it must exist inside the features
  2810. 2:18:26table inside the ID column and we're
  2811. 2:18:28going to also
  2812. 2:18:29take
  2813. 2:18:31upvote which is going to be required and
  2814. 2:18:34it needs to be bullan so now we take
  2815. 2:18:37that
  2816. 2:18:39data and then I'm going to execute on
  2817. 2:18:43upfold um update or create because if
  2818. 2:18:49the user has up voted and then if the
  2819. 2:18:52user clicked on the down vad that is
  2820. 2:18:55going to actually update the record and
  2821. 2:18:58change the upload flag from one into
  2822. 2:19:01zero and this is what we are going to do
  2823. 2:19:04here so we need actually attributes and
  2824. 2:19:07values so inside the attributes uh we
  2825. 2:19:11have to provide the feature ID as well
  2826. 2:19:13as the user
  2827. 2:19:16ID cool so we have to update the record
  2828. 2:19:19for the following feature feature and
  2829. 2:19:21for the following um
  2830. 2:19:25user
  2831. 2:19:28next uh we have to perform the update by
  2832. 2:19:32providing the data right
  2833. 2:19:34here okay so this will do update or
  2834. 2:19:37create and once this is done we have to
  2835. 2:19:40return to
  2836. 2:19:43root feature.
  2837. 2:19:48index okay we perform the the redirect
  2838. 2:19:51into feature Index this is cool now
  2839. 2:19:53let's open web.php and we have to work
  2840. 2:19:58right
  2841. 2:20:00here so let's define
  2842. 2:20:03root host
  2843. 2:20:06on
  2844. 2:20:08on okay let me think well we can just
  2845. 2:20:11write here up vote and nothing else or
  2846. 2:20:14we can do the following feature we can
  2847. 2:20:17provide the actual feature which needs
  2848. 2:20:19to be a full
  2849. 2:20:21and then we can provide um up vote so
  2850. 2:20:26I'm going to do the following way so
  2851. 2:20:28then we're going to use upvote
  2852. 2:20:30controller
  2853. 2:20:32class uh and this is going to be store
  2854. 2:20:36I'm going to just rename this into store
  2855. 2:20:38it is actually called store so we have
  2856. 2:20:40to use store here and here I'm going to
  2857. 2:20:43call this
  2858. 2:20:45feature uh not feature
  2859. 2:20:48H how should we call this
  2860. 2:20:52upfold store probably let's call this
  2861. 2:20:55upfold
  2862. 2:20:57store now let's open feature
  2863. 2:21:02item and we're going to open also show
  2864. 2:21:05because we
  2865. 2:21:07have that up vote down vades on both and
  2866. 2:21:12in our case if we open the details page
  2867. 2:21:14we don't display anything right here
  2868. 2:21:16because we have done this on the in the
  2869. 2:21:18listing feature item component so I
  2870. 2:21:21should probably create a component out
  2871. 2:21:24of this so
  2872. 2:21:28this is something I'm going to extract
  2873. 2:21:31into resources JS components and let's
  2874. 2:21:34create new
  2875. 2:21:36component
  2876. 2:21:38feature
  2877. 2:21:41upfold um feature app vote okay let's
  2878. 2:21:46call this feature app
  2879. 2:21:47vote down vote
  2880. 2:21:51okay longer but more descriptive export
  2881. 2:21:54default
  2882. 2:21:56function uh feature up vote
  2883. 2:22:00down
  2884. 2:22:01[Music]
  2885. 2:22:03vote and then we return the following
  2886. 2:22:08js6 and obviously we're going to accept
  2887. 2:22:12right here
  2888. 2:22:17feature we need to import that type
  2889. 2:22:20let's accept feature here now we have
  2890. 2:22:25the entire
  2891. 2:22:26feature and we have to use
  2892. 2:22:30that here feature uplo down vote
  2893. 2:22:34providing the feature and we can use
  2894. 2:22:37that component in show as
  2895. 2:22:43well okay now if you open the show page
  2896. 2:22:45we're going to
  2897. 2:22:47see okay we don't see some thing because
  2898. 2:22:51we don't actually select everything what
  2899. 2:22:54we have this with count and with exist
  2900. 2:22:58we don't select this on the um show page
  2901. 2:23:02right here we're going to come back to
  2902. 2:23:04this and select that as well but let's
  2903. 2:23:08actually try to implement or maybe we
  2904. 2:23:10can do this right now uh scroll down
  2905. 2:23:12below um where's this
  2906. 2:23:16show this is index we're going to
  2907. 2:23:18collapse this create
  2908. 2:23:21store show here it is and on
  2909. 2:23:25that uh feature we have to yeah we we
  2910. 2:23:30can execute a separate cures because
  2911. 2:23:33this is for listing that's clear but for
  2912. 2:23:36cures is we're going to do it
  2913. 2:23:37differently
  2914. 2:23:39so let me actually take this DB Ru or
  2915. 2:23:44maybe we can tell take this entire
  2916. 2:23:47select and
  2917. 2:23:50here so on the
  2918. 2:23:52feature app vot
  2919. 2:23:56count
  2920. 2:23:57equals um from from upfold model we're
  2921. 2:24:03going to
  2922. 2:24:05select okay where's that we're going to
  2923. 2:24:08select
  2924. 2:24:12tbu let's have a
  2925. 2:24:15look we're going to select um some and
  2926. 2:24:20then we're going to add extra where
  2927. 2:24:23we're going to select only those records
  2928. 2:24:26where feature ID is the given feature
  2929. 2:24:31and finally we just need a single um I
  2930. 2:24:36think count exists single
  2931. 2:24:40value uh let's actually DD
  2932. 2:24:45feature on the show page reload it
  2933. 2:24:50up
  2934. 2:24:52count the reason for this is that we
  2935. 2:24:55have feature instead of feature ID so if
  2936. 2:24:58we save this right now refresh the
  2937. 2:25:01page uh then we're going to see the
  2938. 2:25:03upload count to be
  2939. 2:25:06three okay however um I'm going to just
  2940. 2:25:10turn this into more elegant solution so
  2941. 2:25:13I'm going to take this DB rule here we
  2942. 2:25:16need we and finally I'm going to call
  2943. 2:25:21uh
  2944. 2:25:22sum and inside this we are going to just
  2945. 2:25:25select
  2946. 2:25:27Case Case when I put one then one lse
  2947. 2:25:30minus one we don't need this parenthesis
  2948. 2:25:33and this is going to do the exact same
  2949. 2:25:35thing so where feature ID is the given
  2950. 2:25:37feature ID we're going to sum of these
  2951. 2:25:40things so I save this uh we can actually
  2952. 2:25:45remove this
  2953. 2:25:46completely and have a look in the
  2954. 2:25:49browser and and we should see three
  2955. 2:25:52right here which is the correct now we
  2956. 2:25:54are going to do something similar for
  2957. 2:25:57this user has up voted user has down
  2958. 2:26:00voted so we just need the names nothing
  2959. 2:26:03else um scroll down
  2960. 2:26:08below feature user has upvoted and now
  2961. 2:26:12from upvote we're going to execute
  2962. 2:26:16where feature ID is the feature
  2963. 2:26:23ID uh user ID is the out ID and we need
  2964. 2:26:28another we a vote equals one and we're
  2965. 2:26:32going to call
  2966. 2:26:35exists user has up voted if that exists
  2967. 2:26:38duplicate this user
  2968. 2:26:41has
  2969. 2:26:43downvoted if up vote equals zero now we
  2970. 2:26:48save this refresh the page
  2971. 2:26:52and we see the correct uh coloring on
  2972. 2:26:54this so this indicates that the admin
  2973. 2:26:57user has just um has upvoted that
  2974. 2:27:02specific um feature now we're going to
  2975. 2:27:05focus on actually upload and download
  2976. 2:27:08functionality so for this right here
  2977. 2:27:11we're going to define the
  2978. 2:27:13form
  2979. 2:27:15use form and we are going to Define
  2980. 2:27:19actually two forms one is going to be up
  2981. 2:27:22vote form and second is going to be down
  2982. 2:27:27vote
  2983. 2:27:29form so let's call this up vote form and
  2984. 2:27:35we need up vote to be true for up vote
  2985. 2:27:39for now let's duplicate this and this is
  2986. 2:27:44going to
  2987. 2:27:45be downvote form and up vote is going to
  2988. 2:27:50be false in this case so now I'm going
  2989. 2:27:53to Define
  2990. 2:27:56upvote um
  2991. 2:27:59downvote
  2992. 2:28:02function and here inside this up down
  2993. 2:28:05function we're going to accept flag up
  2994. 2:28:08vote which is going to be Boolean okay
  2995. 2:28:11and we're going to do a couple of checks
  2996. 2:28:13like if the
  2997. 2:28:17feature has user has up voted okay if
  2998. 2:28:22the feature is already uploaded by the
  2999. 2:28:25current user and user clicked on
  3000. 2:28:30upfold
  3001. 2:28:31or if the current
  3002. 2:28:34feature um is downvoted by the user and
  3003. 2:28:40user clicked on down vote not up vote it
  3004. 2:28:44means that we are going to delete our up
  3005. 2:28:47Vote or down vote whatever it is okay so
  3006. 2:28:51in our example the up arrow is Ember if
  3007. 2:28:55I click on up Arrow my vote simply
  3008. 2:28:59should be deleted should be removed and
  3009. 2:29:01there this will become two okay so this
  3010. 2:29:05is the case what we're going to do and
  3011. 2:29:08so in this case on the up form or on
  3012. 2:29:12download form actually doesn't matter
  3013. 2:29:14we're going to call delete and we're
  3014. 2:29:16going to provide root feature
  3015. 2:29:21feature destroy not the feature destroy
  3016. 2:29:23sorry up. destroy which doesn't exist in
  3017. 2:29:27the roots so let's open web.php
  3018. 2:29:31and we are going to duplicate
  3019. 2:29:34this up
  3020. 2:29:36vote
  3021. 2:29:38upot and the method will be delete upot
  3022. 2:29:45destroy and the method is going to be
  3023. 2:29:48dis d destroy as
  3024. 2:29:52well now let's create that public
  3025. 2:29:56function destroy we're going to accept
  3026. 2:29:58upvote
  3027. 2:30:00here then on the upvote we are going to
  3028. 2:30:03call delete and return to Road feature
  3029. 2:30:09index uh actually it should be either
  3030. 2:30:13feature
  3031. 2:30:14index or it should
  3032. 2:30:16be the specific feature page depending
  3033. 2:30:21on from where it is coming um can we
  3034. 2:30:25actually go back so if we call back is
  3035. 2:30:29it going to work let's try this now we
  3036. 2:30:31have this upload destroy which we can
  3037. 2:30:34use here and we have to provide um the
  3038. 2:30:41actual now let me think for the up
  3039. 2:30:44destroy I think we need to accept in the
  3040. 2:30:48up destroy not the up V itself but the
  3041. 2:30:51feature okay so we need feature here
  3042. 2:30:55yeah this is it let's import the feature
  3043. 2:30:59and we're going to do the following on
  3044. 2:31:01that feature we're going to call up
  3045. 2:31:03folds and we are going to find those up
  3046. 2:31:07folds where user ID is the currently
  3047. 2:31:11authenticated user ID and then execute
  3048. 2:31:13delete on
  3049. 2:31:15this this is it this is how we're going
  3050. 2:31:17to do that uh in the root in the delete
  3051. 2:31:22we need feature
  3052. 2:31:24here and in the up vote down vote right
  3053. 2:31:28here when we call up vote destroy we
  3054. 2:31:30have to provide feature
  3055. 2:31:32ID okay this is good now this is going
  3056. 2:31:38to actually work however we have a
  3057. 2:31:41couple of other cases actually I think
  3058. 2:31:43we need also to provide preserve scroll
  3059. 2:31:47to be
  3060. 2:31:48true okay now we need
  3061. 2:31:51else inside else um I'm going to do the
  3062. 2:31:54following let's define the form equals
  3063. 2:31:57null then if upvote is true then form
  3064. 2:32:04equals upvote
  3065. 2:32:06form uh else form equals downward
  3066. 2:32:14form then on the form I'm going to call
  3067. 2:32:17Post provide
  3068. 2:32:23upvote
  3069. 2:32:24store to store the
  3070. 2:32:27upvote and we have to provide Reserve
  3071. 2:32:32scroll to be true okay so depending on
  3072. 2:32:35whether this form is upload form or
  3073. 2:32:37download form we're going to have
  3074. 2:32:40different data upload true or upload
  3075. 2:32:42false and just like this we're making
  3076. 2:32:45correct request now we need to take this
  3077. 2:32:48up vote down vote and add event
  3078. 2:32:51listeners on these buttons on
  3079. 2:32:53click uh we are going to call upv
  3080. 2:32:57downward with true this is for up vote
  3081. 2:33:02and on click here up vote down
  3082. 2:33:06vote
  3083. 2:33:08actually like this in this case we have
  3084. 2:33:10to provide
  3085. 2:33:12false okay let's save it and have a look
  3086. 2:33:18let's open Dev Dev tools I'm going to
  3087. 2:33:20click on up vote which should remove my
  3088. 2:33:23up vote completely now there's only two
  3089. 2:33:26refresh the page um it stays there now
  3090. 2:33:29I'm going to hit on up vote and we have
  3091. 2:33:31this air up vote store parameter is
  3092. 2:33:35required for up store that's actually
  3093. 2:33:39correct for upold
  3094. 2:33:42store uh where's that I think right here
  3095. 2:33:47so for upv store right here we have to
  3096. 2:33:50provide feature.
  3097. 2:33:54ID cool now let's try uplo
  3098. 2:34:01again okay it probably didn't do
  3099. 2:34:06anything click on
  3100. 2:34:07[Music]
  3101. 2:34:09upot click on
  3102. 2:34:11upot okay let's see nothing happens what
  3103. 2:34:14request is made
  3104. 2:34:20okay it returns with 200 status code
  3105. 2:34:24we're going to check inside
  3106. 2:34:26upvs click on
  3107. 2:34:30this no the record is not
  3108. 2:34:39created feature ID field is required I
  3109. 2:34:44think I know the reason up
  3110. 2:34:48vote we need to inside the
  3111. 2:34:51fillable this is going to be feature
  3112. 2:34:55ID user ID and
  3113. 2:35:01upfold save that click on
  3114. 2:35:08upfold okay it's still not
  3115. 2:35:16working okay inside store I expect
  3116. 2:35:19feature ID to be required and that must
  3117. 2:35:23exist inside the features table uh okay
  3118. 2:35:26so we have two ways either inside the
  3119. 2:35:30store uh we we take this feature we
  3120. 2:35:33actually expect this feature so we have
  3121. 2:35:35to take that
  3122. 2:35:37Feature Feature Feature from here this
  3123. 2:35:40is one way to do it and we need to
  3124. 2:35:42remove this feature ID from
  3125. 2:35:44here and we have to provide feature ID
  3126. 2:35:49here we don't need to dollar sign that's
  3127. 2:35:53one way second way is to just return
  3128. 2:35:56everything how it was and from the front
  3129. 2:35:58end side we have to put a feature ID
  3130. 2:36:02here and here as well so that's the
  3131. 2:36:04second way okay so I'm going to do in
  3132. 2:36:06the following way let's have a look
  3133. 2:36:08click on
  3134. 2:36:09upot we have something going on table
  3135. 2:36:13upot has no column okay updated at we
  3136. 2:36:16don't have that inside upvs so we should
  3137. 2:36:19open upload model again and set time
  3138. 2:36:23stamps to be false to disable the time
  3139. 2:36:26stamps now let's try this again click on
  3140. 2:36:28up vote now we see this turned into
  3141. 2:36:32something but we will are redirected
  3142. 2:36:34into feature
  3143. 2:36:37index okay if I click on
  3144. 2:36:43upfold we stay here click on up vote we
  3145. 2:36:48will are redirected
  3146. 2:36:50into feature
  3147. 2:36:53index okay so upload download itself
  3148. 2:36:57seems like to be working if you remove
  3149. 2:37:00it is to download remove it is to upload
  3150. 2:37:05download uplo downward if we go
  3151. 2:37:09inside uplo and we go back into feature
  3152. 2:37:13index which is something I don't
  3153. 2:37:15want uh if we open upload controller we
  3154. 2:37:19have we are redirecting into feature
  3155. 2:37:21Index right here but on Destroy we go
  3156. 2:37:24back so I think that's the reason so if
  3157. 2:37:26I remove we stay here but if I upload we
  3158. 2:37:30go into index and if we just change this
  3159. 2:37:33into
  3160. 2:37:35back this should work as well so I
  3161. 2:37:38remove I stay here I upot I stay here
  3162. 2:37:42and just like this I'm on the same page
  3163. 2:37:46where I up voted or downvoted now we
  3164. 2:37:49have almost everything ready we have
  3165. 2:37:51Crow of the features we have up vote
  3166. 2:37:54down vote displaying the correct number
  3167. 2:37:56of up votes on the um on the feature and
  3168. 2:38:01I think we can focus on leaving
  3169. 2:38:04comments for this let's first open p
  3170. 2:38:07chor and I'm going to comment everything
  3171. 2:38:09what we changed so far
  3172. 2:38:13Implement up
  3173. 2:38:15vote down vote
  3174. 2:38:20cool okay so I'm going to do the
  3175. 2:38:22following I'm going to display number of
  3176. 2:38:26comments for each feature right here and
  3177. 2:38:31it's it's going to be like kind of
  3178. 2:38:32clickable button and when clicking on
  3179. 2:38:35that it's going to open that specific
  3180. 2:38:36feature Details page where you're going
  3181. 2:38:39to see all the comments as well as the
  3182. 2:38:42feature
  3183. 2:38:44details so let's
  3184. 2:38:46open um feature
  3185. 2:38:51feature
  3186. 2:38:53item
  3187. 2:38:55and so this is the up V down vote this
  3188. 2:39:00is the
  3189. 2:39:01description this is the
  3190. 2:39:04um this is the actions drop down and I
  3191. 2:39:08actually
  3192. 2:39:10want the comments button to be inside
  3193. 2:39:14here
  3194. 2:39:20so right here I'm going to create a div
  3195. 2:39:23then I'm going to have a link inside
  3196. 2:39:26that and that link will go into root
  3197. 2:39:31feature. show providing the feature so
  3198. 2:39:35that link will have a comment
  3199. 2:39:38of um not the comment but
  3200. 2:39:44the let's just write comments
  3201. 2:39:47here okay let's let's just write
  3202. 2:39:50comments nothing else okay I'm going to
  3203. 2:39:52also copy and paste some TN cisss
  3204. 2:39:55classes because just typing those
  3205. 2:39:56classes will take a lot of time
  3206. 2:39:59so class name equals this let's all this
  3207. 2:40:06on its own line and those are basically
  3208. 2:40:08the classes
  3209. 2:40:10which um should I enable
  3210. 2:40:17R yeah I I think I should should
  3211. 2:40:22enable soft
  3212. 2:40:25wrap
  3213. 2:40:28lines we need this
  3214. 2:40:33for for TS
  3215. 2:40:39and Dot
  3216. 2:40:41TSX files as
  3217. 2:40:45well okay
  3218. 2:40:49okay good so these are the classes um
  3219. 2:40:52which I added and we can have a look
  3220. 2:40:56comments okay not bad let's give it um
  3221. 2:41:00margin
  3222. 2:41:01top margin top um or maybe or we can
  3223. 2:41:06give it hiding y4 something like this
  3224. 2:41:11okay when I click on this comments it's
  3225. 2:41:12going to open the details page and right
  3226. 2:41:13here I'm going to display all the
  3227. 2:41:16comments so let's open show
  3228. 2:41:20uh and right here we have this um title
  3229. 2:41:26the name and the description and this is
  3230. 2:41:29the place where I want to display the
  3231. 2:41:33comments and I also want to display the
  3232. 2:41:35new comment form so let's first create
  3233. 2:41:38div and inside the div we need margin
  3234. 2:41:43top let's give it margin top eight and
  3235. 2:41:46then I want two components to create and
  3236. 2:41:49and let me do this right now inside
  3237. 2:41:52components uh new comment
  3238. 2:41:57form this one and second is going to be
  3239. 2:42:01comment
  3240. 2:42:02item comment
  3241. 2:42:07item okay now let's use new
  3242. 2:42:11comment
  3243. 2:42:13com excuse me so we have to create the
  3244. 2:42:17components export d default
  3245. 2:42:21function new comment
  3246. 2:42:25form return
  3247. 2:42:29this new comment form uh we can already
  3248. 2:42:34use this new comment form here but this
  3249. 2:42:37new comment form needs feature as well
  3250. 2:42:40for the for which feature it is going to
  3251. 2:42:42create the
  3252. 2:42:44comment so let's accept right
  3253. 2:42:47here feature
  3254. 2:42:59okay uh I'm I'm going to come back to
  3255. 2:43:03this so far this is good now on the
  3256. 2:43:05feature uh we are going to return
  3257. 2:43:08comments as well so let's open feature
  3258. 2:43:13controller and find that index method we
  3259. 2:43:18have with count
  3260. 2:43:19with exists um paginate and I'm going to
  3261. 2:43:24add right here with comments and I also
  3262. 2:43:29want each comment to be selected with
  3263. 2:43:32user just like this just make sure if we
  3264. 2:43:35open comment.php it has a user there and
  3265. 2:43:39if we open Feature Feature has comments
  3266. 2:43:42there okay we have the relations defined
  3267. 2:43:44properly and I'm selecting this with the
  3268. 2:43:46comments user now if I open in feature
  3269. 2:43:50resource from here I am going to return
  3270. 2:43:55comments comments is going to be um
  3271. 2:44:01collection okay so here uh I'm going to
  3272. 2:44:04execute these
  3273. 2:44:08comments
  3274. 2:44:09map function for each comment I am going
  3275. 2:44:13to return um array where we need the
  3276. 2:44:17comment ID we need the actual comment we
  3277. 2:44:21need the user information through this
  3278. 2:44:23new user resource and I also need
  3279. 2:44:27created it uh in the following way okay
  3280. 2:44:32now each feature has
  3281. 2:44:35comments the thing is that we are
  3282. 2:44:38actually returning those comments in the
  3283. 2:44:42feature uh listing as well which is
  3284. 2:44:45something I don't want so I should not
  3285. 2:44:48actually I shouldn't have actually added
  3286. 2:44:50this
  3287. 2:44:52here and we also don't
  3288. 2:44:56need um we also don't
  3289. 2:45:00need uh comments in the listing so
  3290. 2:45:04either we have to Define new Resource
  3291. 2:45:07One is going to be feature list resource
  3292. 2:45:10and second is going to be feature
  3293. 2:45:12resource for The Details page uh for
  3294. 2:45:15comments or without comments
  3295. 2:45:20uh okay I'm going to create Now new
  3296. 2:45:22resource I can easily duplicate this
  3297. 2:45:25feature
  3298. 2:45:26resource let's call this feature
  3299. 2:45:29list list
  3300. 2:45:33resource uh okay and inside the feature
  3301. 2:45:36list we don't need comments so we can
  3302. 2:45:38remove that and if we go into feature
  3303. 2:45:41controller we're going to use feature
  3304. 2:45:43list resource
  3305. 2:45:46here and we can remove this with
  3306. 2:45:49we don't need that if I scroll down
  3307. 2:45:51below and find this store not the store
  3308. 2:45:55let's go upstairs and not the create but
  3309. 2:45:58we are interested in show here we are
  3310. 2:46:00using this feature resource and in the
  3311. 2:46:02feature resource we are returning
  3312. 2:46:03comments but not in the least
  3313. 2:46:06resource okay now let's go into show
  3314. 2:46:12again and on the feature we have now
  3315. 2:46:16comments and this is something we have
  3316. 2:46:18to to describe right here as
  3317. 2:46:24well so we have this uh feature above
  3318. 2:46:28that let's export type
  3319. 2:46:34comment and we need ID to be
  3320. 2:46:38number we need comment to be
  3321. 2:46:42string and we need created it to be
  3322. 2:46:46string as well and we need user to be
  3323. 2:46:51user now on the feature we can provide
  3324. 2:46:55that it has comments array in
  3325. 2:46:58instance array of comment type now in
  3326. 2:47:02the show we can iterate over comments we
  3327. 2:47:06can call map we can take each
  3328. 2:47:09comment and we need to return the
  3329. 2:47:16comment item from here so I'm going to
  3330. 2:47:18use comment
  3331. 2:47:20item uh which we don't have defined we
  3332. 2:47:26just created the file
  3333. 2:47:28export um
  3334. 2:47:31function export default
  3335. 2:47:34function comment
  3336. 2:47:37item return something I'm going to come
  3337. 2:47:41back to this and then I'm using this
  3338. 2:47:43comment item and we're going to accept
  3339. 2:47:46we're going to provide comment
  3340. 2:47:50here and we're going to provide key to
  3341. 2:47:52be comment ID let's accept the comment
  3342. 2:47:58here comment to be an instance of common
  3343. 2:48:05type
  3344. 2:48:07okay so now we have to implement these
  3345. 2:48:10two files new comment form and the
  3346. 2:48:14comment item so for comment item uh I am
  3347. 2:48:18going to
  3348. 2:48:21actually uh it's a very repetitive thing
  3349. 2:48:24so I'm I was thinking about copying and
  3350. 2:48:26pasting um few
  3351. 2:48:32things okay uh let me just try to type
  3352. 2:48:36it okay so we're going to have one div
  3353. 2:48:40which will have display of um
  3354. 2:48:43flex and gap of four and margin bottom
  3355. 2:48:48three
  3356. 2:48:49okay then we're going to have three divs
  3357. 2:48:51the first one is going to be for the
  3358. 2:48:53user Avatar second is going to be for
  3359. 2:48:56the actual comment itself and the third
  3360. 2:48:58one is going to be for the comment
  3361. 2:49:00delete okay now the first one which is
  3362. 2:49:03going to be for the user Avatar let's
  3363. 2:49:05give it proper classes like W12
  3364. 2:49:09h12 let's give it rounded full PG gray
  3365. 2:49:14um 600 and give it Flex items Center and
  3366. 2:49:20justify Center and inside here we're
  3367. 2:49:23going to put the icon user icon so let's
  3368. 2:49:27search for
  3369. 2:49:29user outline let's copy the first one
  3370. 2:49:32paste here and check change this stroke
  3371. 2:49:37with line cap line
  3372. 2:49:42join okay so this is the user
  3373. 2:49:46now for the
  3374. 2:49:50actual comment itself first we're going
  3375. 2:49:51to display the user uh name so let's
  3376. 2:49:56give it uh font bold and give it margin
  3377. 2:50:00top of one and we're going to Output
  3378. 2:50:05comment comment usern name okay and I'm
  3379. 2:50:10going to also provide right here span
  3380. 2:50:14which will have the following CSS
  3381. 2:50:17classes like text
  3382. 2:50:19gray uh 500 text extra small and margin
  3383. 2:50:24left four and this is going to be
  3384. 2:50:27comment created at when the comment was
  3385. 2:50:30created after this we're going to have
  3386. 2:50:32div and this is going to be an actual
  3387. 2:50:35comment let's give it italic class we
  3388. 2:50:38output
  3389. 2:50:40comment. comment and let's also give it
  3390. 2:50:43margin top
  3391. 2:50:45one okay and finally finally we need
  3392. 2:50:49that delete button so right here I'm
  3393. 2:50:52going to put button and then inside we
  3394. 2:50:56need this trash icon to delete the
  3395. 2:51:01comment let's paste
  3396. 2:51:04this
  3397. 2:51:06with line cap and line join so then on
  3398. 2:51:11that we need onclick which should call
  3399. 2:51:14something like delete delete comment as
  3400. 2:51:18an example ex Le we are going to create
  3401. 2:51:19that um what else do we need I'm not
  3402. 2:51:23going to put anything else here we just
  3403. 2:51:26need to provide on that div Flex items
  3404. 2:51:33Center flex and item Center that's it
  3405. 2:51:37maybe also some uh pading Y 2 pading x
  3406. 2:51:42uh six maybe and let's now Define this
  3407. 2:51:46delete comment
  3408. 2:51:50cons delete comment
  3409. 2:51:54equals the following function and we
  3410. 2:51:57need form as well so const form equals
  3411. 2:52:02use form an empty form nothing else and
  3412. 2:52:06on that form we can call delete we're
  3413. 2:52:09going to
  3414. 2:52:10provide uh comment do destroy which
  3415. 2:52:14doesn't exist we're going to create that
  3416. 2:52:17providing
  3417. 2:52:19comment.
  3418. 2:52:21ID okay and we have to provide right
  3419. 2:52:25here preserve
  3420. 2:52:28scroll true and I also want to provide
  3421. 2:52:31preserve State because uh on that page
  3422. 2:52:35there might be some State modified like
  3423. 2:52:38something might be typed in the add new
  3424. 2:52:41comment field and I don't want that to
  3425. 2:52:44be
  3426. 2:52:44lost so we're going to open web.php
  3427. 2:52:48and we have to Define new rules for
  3428. 2:52:50comments but I think we don't even have
  3429. 2:52:52controller so let's create the
  3430. 2:52:53controller PHP artisan
  3431. 2:52:57make control
  3432. 2:53:00control
  3433. 2:53:02controller comment controller we hit the
  3434. 2:53:06enter comment controller was created uh
  3435. 2:53:09let's open comment controller and the
  3436. 2:53:12only method we need or we need two
  3437. 2:53:15methods basically right here one is
  3438. 2:53:17going to be store and the comment is
  3439. 2:53:19stored for specific feature so we can
  3440. 2:53:22accept feature
  3441. 2:53:24here and we can obviously accept request
  3442. 2:53:28as well and then on
  3443. 2:53:32the on the controller we need to
  3444. 2:53:36validate so
  3445. 2:53:38request
  3446. 2:53:40validate we only need comment which
  3447. 2:53:42needs to be required okay so we take the
  3448. 2:53:46data and we're going to call
  3449. 2:53:49comment create we provide the data
  3450. 2:53:53however inside the data we're going to
  3451. 2:53:55put uh feature ID to be feature ID
  3452. 2:54:02and user ID to be authenticated user ID
  3453. 2:54:09uh out
  3454. 2:54:11ID let's import this
  3455. 2:54:14oops let's import
  3456. 2:54:17this out
  3457. 2:54:19okay let's open comment create and we
  3458. 2:54:21are going to Define
  3459. 2:54:24failable uh
  3460. 2:54:27comment feature ID and user
  3461. 2:54:34ID okay cool now let's return to
  3462. 2:54:40root uh feature.
  3463. 2:54:44show and we have to provide the feature
  3464. 2:54:47as well
  3465. 2:54:49and just like this the creating new
  3466. 2:54:51comment is ready let's define the second
  3467. 2:54:53function which is going to be for
  3468. 2:54:55destroy
  3469. 2:54:56destroy and
  3470. 2:54:59comment that comment needs to be
  3471. 2:55:01destroyed so we call comment delete and
  3472. 2:55:06actually we
  3473. 2:55:07should we should go into feature show
  3474. 2:55:11again but we need the feature ID so
  3475. 2:55:16let's take this feature
  3476. 2:55:18ID comment
  3477. 2:55:22feature uh feature uncore ID and then we
  3478. 2:55:25provide right here the feature ID to go
  3479. 2:55:29to that uh page if we open now Roots
  3480. 2:55:34file root we
  3481. 2:55:38need we need post for uh
  3482. 2:55:44comments um let me think uh actually
  3483. 2:55:48actually it can be
  3484. 2:55:52Feature Feature uh comments so the post
  3485. 2:55:56request on the following URL and we're
  3486. 2:55:59going to use comment
  3487. 2:56:02controller uh
  3488. 2:56:06store comment controller store uh the
  3489. 2:56:09name is going to be comment store and
  3490. 2:56:12let's define the second Road this is
  3491. 2:56:15going to be to delete specific comment
  3492. 2:56:20comment and the comment to be deleted
  3493. 2:56:24the method is destroy the rote name is
  3494. 2:56:27comment
  3495. 2:56:30destroy awesome so this is the comment
  3496. 2:56:33item the delete actually should work but
  3497. 2:56:36we should focus on creating a new
  3498. 2:56:39comment as
  3499. 2:56:42well so here let's create the form it
  3500. 2:56:46needs on sub
  3501. 2:56:49submit uh on submit equals
  3502. 2:56:52create comment we're going to come back
  3503. 2:56:55to this function and create that we need
  3504. 2:56:57label and we can make this just um for
  3505. 2:57:01screen read
  3506. 2:57:02only is R only let's give
  3507. 2:57:07it um your
  3508. 2:57:10comment I think yeah we we have not
  3509. 2:57:14taken care any of the accessibility
  3510. 2:57:16things uh because we're doing something
  3511. 2:57:19um just for learning purposes if you are
  3512. 2:57:23doing something in production obviously
  3513. 2:57:25you should consider this but because so
  3514. 2:57:27far we haven't done anything
  3515. 2:57:29like regarding accessibility I think we
  3516. 2:57:32don't need that label as well um we need
  3517. 2:57:36extra div and the div should contain the
  3518. 2:57:38text area in the primary Button as well
  3519. 2:57:44okay so let's give that div or maybe we
  3520. 2:57:46can just uh use that for let's give it
  3521. 2:57:50Flex items Center we need pading X3 ping
  3522. 2:57:56Y 2 rounded LG BG gray
  3523. 2:58:0350 and on dark
  3524. 2:58:06mode we're going to make p grade
  3525. 2:58:09800 uh and then right here we're going
  3526. 2:58:12to use text area
  3527. 2:58:14input and let's give it um some of the
  3528. 2:58:19properties
  3529. 2:58:21like it should have doesn't need name I
  3530. 2:58:24don't know uh let's give it rowes to be
  3531. 2:58:27equal one let's give it
  3532. 2:58:30value to
  3533. 2:58:34be um we have to define the form as well
  3534. 2:58:37const data equals use
  3535. 2:58:42form okay so we provide
  3536. 2:58:45comment to be an empty string
  3537. 2:58:48and we provide we can provide feature ID
  3538. 2:58:52here or we can put that feature ID in
  3539. 2:58:54the URL so I think we don't need this
  3540. 2:58:56because when creating new comment we
  3541. 2:58:58have this feature in the URL okay so
  3542. 2:59:01let's also Define this create comment
  3543. 2:59:05which is form event handler type of um
  3544. 2:59:13function so we accept
  3545. 2:59:15event then on that event we call prevent
  3546. 2:59:19default and we are going to take we have
  3547. 2:59:22the data we have to take set data we
  3548. 2:59:25have to take post and we have to take
  3549. 2:59:29processing we can put
  3550. 2:59:32them on New
  3551. 2:59:37Line okay
  3552. 2:59:40awesome now we are going to call
  3553. 2:59:45Post um comment
  3554. 2:59:50create comment um not create but
  3555. 2:59:55store so we're going to provide preserve
  3556. 2:59:58scroll to be true and we can provide
  3557. 3:00:01preserve state to be true as
  3558. 3:00:06well okay and we need on success and
  3559. 3:00:09when this happens we have to call set
  3560. 3:00:13data on comment to be an empty string so
  3561. 3:00:17we reset the comment actually when new
  3562. 3:00:19comment is created we reset the comment
  3563. 3:00:22input now instead of value we have to
  3564. 3:00:25provide uh data comment and we have to
  3565. 3:00:29listen on
  3566. 3:00:30change on change um we take the event
  3567. 3:00:36and then call set
  3568. 3:00:38data on comment we provide
  3569. 3:00:42event.
  3570. 3:00:44target. value
  3571. 3:00:48okay and what else do we need we can
  3572. 3:00:50provide some class name a margin top
  3573. 3:00:53block and full width and let's give it
  3574. 3:00:56also
  3575. 3:00:58placeholder um a
  3576. 3:01:02comment uh let's just give
  3577. 3:01:07it your
  3578. 3:01:11comment okay and I need primary button
  3579. 3:01:15primary button right here and let's give
  3580. 3:01:18it text comment and that button should
  3581. 3:01:21be disabled if processing is true now if
  3582. 3:01:26we open
  3583. 3:01:29show we have this new comment form
  3584. 3:01:32everything looks good now let's open the
  3585. 3:01:34show page refresh
  3586. 3:01:38it and have a look okay so this looks
  3587. 3:01:44ugly because
  3588. 3:01:48we have that extra div let's remove this
  3589. 3:01:50extra
  3590. 3:01:53div okay so that doesn't look ideal um
  3591. 3:01:57but I'm not going to spend more time on
  3592. 3:01:59just uh styling this
  3593. 3:02:04thing let's test the functionality okay
  3594. 3:02:07test comment item let's click on
  3595. 3:02:12comment and we're going to see what's
  3596. 3:02:16happened
  3597. 3:02:19comment store feature parameter is
  3598. 3:02:21required for comment store that's
  3599. 3:02:23correct so we have to provide feature.
  3600. 3:02:25ID
  3601. 3:02:27here let's clear this click on comment
  3602. 3:02:31and as you see comment was added that's
  3603. 3:02:36not bad
  3604. 3:02:38so there are some pings which should be
  3605. 3:02:43probably adjusted in the comment form
  3606. 3:02:50I think we don't need padding X at
  3607. 3:02:57all but we need margin bottom
  3608. 3:03:01four something like this and this
  3609. 3:03:06one uh this St needs Flex
  3610. 3:03:10one if we open comment item we have
  3611. 3:03:13three
  3612. 3:03:15divs this one should have
  3613. 3:03:18Le
  3614. 3:03:20one
  3615. 3:03:21okay another comment click on comment
  3616. 3:03:26another comment goes at the top so the
  3617. 3:03:28latest comment should be at the top
  3618. 3:03:30another comment actually went to the
  3619. 3:03:32bottom so the latest comment should be
  3620. 3:03:34at the top so we should open feature.
  3621. 3:03:38PHP and find the comments and we're
  3622. 3:03:40going to provide latest method here
  3623. 3:03:43refresh the page now latest comment is
  3624. 3:03:47going to be
  3625. 3:03:48at the top uh one more click on comment
  3626. 3:03:53now one more is at the top that's
  3627. 3:03:56awesome now if we try to delete
  3628. 3:03:59this it is working
  3629. 3:04:03successfully uh test another comment and
  3630. 3:04:07also the scroll is preserved and if I
  3631. 3:04:10have something written here which is
  3632. 3:04:12part of the State uh if I click on this
  3633. 3:04:16now this also stays here doesn't clear
  3634. 3:04:18and this is exactly
  3635. 3:04:20what this preserve state is
  3636. 3:04:25doing okay so what else do we need so we
  3637. 3:04:28have also added functionality to leave
  3638. 3:04:32comments on the
  3639. 3:04:34feature so we have I think almost the
  3640. 3:04:37whole functionality and I think right
  3641. 3:04:40now uh if I didn't miss anything we can
  3642. 3:04:43focus on um the remaining things which
  3643. 3:04:47are basically inertia version two
  3644. 3:04:50things uh and roles and permissions now
  3645. 3:04:54let's start working on roles and
  3646. 3:04:56permissions and there are few things
  3647. 3:04:58we're going to do first right now at the
  3648. 3:05:01moment every user has possibility to
  3649. 3:05:04create new features we are going to
  3650. 3:05:06restrict this only for admin users and
  3651. 3:05:10also leaving comments is right now
  3652. 3:05:12allowed for every users leaving comments
  3653. 3:05:15is only possible for comment
  3654. 3:05:18users who has Ro commenter now let's
  3655. 3:05:21have a look in the first let me comment
  3656. 3:05:26everything
  3657. 3:05:28so
  3658. 3:05:30Implement comment
  3659. 3:05:33CR okay we actually didn't Implement
  3660. 3:05:36update for comments but that's not
  3661. 3:05:39important um okay let's close everything
  3662. 3:05:41and I'm going to open up enam
  3663. 3:05:44permissions enam so these are the
  3664. 3:05:46permissions what we have and the
  3665. 3:05:48permissions are assigned to roles and
  3666. 3:05:49users have roles so we have manage
  3667. 3:05:52features manage users manage comments
  3668. 3:05:55and upvote and
  3669. 3:05:58downvote so basically users regular
  3670. 3:06:01users can only up vote and downvote
  3671. 3:06:03commenters can only leave comments and
  3672. 3:06:06up vote and down vote uh and admin users
  3673. 3:06:09can manage users can manage features and
  3674. 3:06:12manage comments as well pretty much do
  3675. 3:06:14anything okay so we are returning those
  3676. 3:06:17roles and permissions on the front and
  3677. 3:06:18side and we need to hide certain buttons
  3678. 3:06:22on the front end side but let's first
  3679. 3:06:24focus on the backend
  3680. 3:06:27side and for this let's open spotty
  3681. 3:06:30permissions package because there are
  3682. 3:06:33few things we're going to have a look so
  3683. 3:06:35in the documentation we have this middle
  3684. 3:06:37we section and we're going to add middle
  3685. 3:06:40we um based on the permissions so this
  3686. 3:06:43can basically U is a middle we which
  3687. 3:06:46comes with this party package and we're
  3688. 3:06:48going to provide permission right here
  3689. 3:06:50and we can even provide multiple
  3690. 3:06:53permissions all right now let's open
  3691. 3:06:56web.php and find this resource for
  3692. 3:07:02feature and we can assign this middle
  3693. 3:07:07wear can and we have to provide the
  3694. 3:07:11permission name the permission name in
  3695. 3:07:14our case will
  3696. 3:07:16be per permissions
  3697. 3:07:20inam manage
  3698. 3:07:23features
  3699. 3:07:26so why do I have warning yeah we need
  3700. 3:07:30value so that pretty much means
  3701. 3:07:33that um any rout can only be accessed
  3702. 3:07:38from the user who can manage
  3703. 3:07:43features that is not actually correct
  3704. 3:07:46because uh View features should be
  3705. 3:07:49possible for regular users as well but
  3706. 3:07:54if we have a look in the browser right
  3707. 3:07:56now I'm an admin user I just need to log
  3708. 3:07:59out and I need to access for example
  3709. 3:08:04commenter and just click on features now
  3710. 3:08:08we see these 403 so the middle we works
  3711. 3:08:12but actually we did this incorrectly
  3712. 3:08:14okay so let's define uh let's have a
  3713. 3:08:18look again what roads we have PHP
  3714. 3:08:20Artisan Road list especially I'm
  3715. 3:08:24interested in the features so we have
  3716. 3:08:27possibility to create new feature which
  3717. 3:08:29only should be for um the manage
  3718. 3:08:32features
  3719. 3:08:34permission um this one as well for only
  3720. 3:08:37manage
  3721. 3:08:39features uh features show a single
  3722. 3:08:41feature should be visible for every user
  3723. 3:08:45basically update destroy so we have
  3724. 3:08:49seven right 1 2 3 4 5 six and we have
  3725. 3:08:538it as well basically all the features
  3726. 3:08:56except index and show is only available
  3727. 3:09:01for manage
  3728. 3:09:02users so what we can do is the following
  3729. 3:09:07so here we can provide only or let's
  3730. 3:09:10provide accept
  3731. 3:09:13accept
  3732. 3:09:15index and show so for any route in this
  3733. 3:09:19resource except index and show is only
  3734. 3:09:21possible if the user has permission
  3735. 3:09:24manage features and again this relates
  3736. 3:09:30to what
  3737. 3:09:35that this relates
  3738. 3:09:40to feature create feature update feature
  3739. 3:09:46destroy feature feature
  3740. 3:09:50edit and that's it right feature create
  3741. 3:09:54one 2
  3742. 3:09:573
  3743. 3:10:084 yeah index yeah that makes sense uh
  3744. 3:10:14get confused let's look
  3745. 3:10:16again so here let's rerun this root
  3746. 3:10:23list so these comments and upvote is not
  3747. 3:10:27from the feature controller so this is
  3748. 3:10:30one two
  3749. 3:10:32three four five six and seven so five of
  3750. 3:10:37them
  3751. 3:10:39store
  3752. 3:10:40create
  3753. 3:10:43update destroy and edit so this is only
  3754. 3:10:46possible for manage uh features
  3755. 3:10:49permission okay so let's return this go
  3756. 3:10:53into and rerun this and now we have uh
  3757. 3:10:58only few features we don't have index
  3758. 3:11:00and we don't have show we have to
  3759. 3:11:02register them separately okay so root
  3760. 3:11:08get feature and we're going to use
  3761. 3:11:11feature controller index feature Index
  3762. 3:11:14this doesn't need any middle wear
  3763. 3:11:16because this is available for every user
  3764. 3:11:18if the user is
  3765. 3:11:22authenticated get uh feature specific
  3766. 3:11:25feature and let's give it name feature
  3767. 3:11:29show let's move this down as well okay
  3768. 3:11:34now this is already awesome so if we try
  3769. 3:11:37to access to Features we are actually
  3770. 3:11:40able to access that however if we try to
  3771. 3:11:42access features create page we see this
  3772. 3:11:44forbidden because this is only for admin
  3773. 3:11:46users not not for us in the same way if
  3774. 3:11:49we try to edit the feature we get still
  3775. 3:11:5243 the section is unauthorized and if we
  3776. 3:11:55try to delete the feature we still get
  3777. 3:11:57this 403 this section is unauthorized
  3778. 3:11:59right now we are commenter we cannot
  3779. 3:12:02manage
  3780. 3:12:03features okay now let's log in by
  3781. 3:12:07another user which is
  3782. 3:12:11user okay um let's save this let's go
  3783. 3:12:16into feature
  3784. 3:12:17that user is also not able to do any of
  3785. 3:12:20these actions and if we open now The
  3786. 3:12:24Details page that user should not be
  3787. 3:12:26even able to leave a comment so right
  3788. 3:12:29now the user can leave a comment but
  3789. 3:12:32only commenter role users can do this so
  3790. 3:12:35let's open web.php and find the comment
  3791. 3:12:38section where you destroy you create or
  3792. 3:12:41destroy comment and right here let's use
  3793. 3:12:45middle wear can and permissions enam
  3794. 3:12:49manage comments only those users who
  3795. 3:12:52manage comments can actually create the
  3796. 3:12:56comment or to destroy the comment as
  3797. 3:12:59well so in the same
  3798. 3:13:01way to destroy the comment but to be
  3799. 3:13:04able to destroy the comment there is one
  3800. 3:13:06additional thing we have to consider and
  3801. 3:13:10the user basically must be owner of the
  3802. 3:13:14comment to be able to destroy that
  3803. 3:13:19we can do this check with in two ways
  3804. 3:13:21either we can Define gate or policy or
  3805. 3:13:24we can just write an if statement right
  3806. 3:13:26here so I'm not going to over complicate
  3807. 3:13:28things right now with Gates and policies
  3808. 3:13:30however if you're interested to know
  3809. 3:13:32more about this authorization mechanisms
  3810. 3:13:34in Lal uh that section the entire module
  3811. 3:13:38is actually covered in my laral for
  3812. 3:13:40beginners course which you can find on
  3813. 3:13:42my website the cod.com so right now I'm
  3814. 3:13:45just going to write if statement if
  3815. 3:13:48comment uh user ID is the same as out ID
  3816. 3:13:54uh or if it's not the same it's better
  3817. 3:13:56to do it like this then we simply call
  3818. 3:14:00abort and we can provide right here the
  3819. 3:14:02code 403 which means forbidden so the
  3820. 3:14:07destroy will not be called if the user
  3821. 3:14:11does not have permission to manage
  3822. 3:14:13comments however even if user has that
  3823. 3:14:16permission user should not be able to
  3824. 3:14:18delete somebody else's comment right and
  3825. 3:14:21this is exactly what we are doing in
  3826. 3:14:23this case so now if we check our website
  3827. 3:14:28if I click on this now I get this the
  3828. 3:14:30section is unauthorized and if I try to
  3829. 3:14:32create new
  3830. 3:14:34comment click on comment I get this
  3831. 3:14:36again the section is
  3832. 3:14:38unauthorized okay I think we on the
  3833. 3:14:41backend side I can't remember everything
  3834. 3:14:44else what we need if we have a look in
  3835. 3:14:46the rules tools so let's double check
  3836. 3:14:49these accessing the dashboard the
  3837. 3:14:50dashboard right now is kind of abstruct
  3838. 3:14:52page so we don't we don't display any
  3839. 3:14:54particular information yeah updating the
  3840. 3:14:57profile is for everyone the dashboard is
  3841. 3:15:00for everyone uh managing features is
  3842. 3:15:02only for those who has managed features
  3843. 3:15:05viewing
  3844. 3:15:06features um single feature or um list of
  3845. 3:15:10features is for
  3846. 3:15:12everyone um up vote and delete his own
  3847. 3:15:16app vote is also for everyone however
  3848. 3:15:20let's just make sure that uh user is not
  3849. 3:15:23able to destroy somebody else's upfold
  3850. 3:15:25no we are using the AL ID so basically
  3851. 3:15:27from the this particular feature upfold
  3852. 3:15:30we are deleting the one which is made by
  3853. 3:15:32that user okay so far so good in the
  3854. 3:15:35comment section yeah only manage
  3855. 3:15:37comments can create comment or destroy
  3856. 3:15:40the comment so the permissions on the
  3857. 3:15:41backend side is fully ready now let's
  3858. 3:15:44focus on the front and side and I'm
  3859. 3:15:47going to open index TSX and right here
  3860. 3:15:50we have this button create new features
  3861. 3:15:53which we need to completely hide and we
  3862. 3:15:56don't want to display if the user
  3863. 3:15:58doesn't have the permission to manage
  3864. 3:16:00features okay this is what I am going to
  3865. 3:16:03do right now in the resources JS I'm
  3866. 3:16:06going to create a new typescript file
  3867. 3:16:10called maybe
  3868. 3:16:12helpers and from here I am going to
  3869. 3:16:15export
  3870. 3:16:17um some of the functions which will be
  3871. 3:16:20identical to how you use K functions in
  3872. 3:16:24blade for
  3873. 3:16:27example um from the Lal spati
  3874. 3:16:31permissions package if we check the way
  3875. 3:16:34how you test certain things blade
  3876. 3:16:37directives for example so this is the
  3877. 3:16:39way how you can check if the current
  3878. 3:16:41user can edit articles this is second
  3879. 3:16:45way however we have typescript we have
  3880. 3:16:48react so we don't have that can function
  3881. 3:16:51can directive in react so this is
  3882. 3:16:54exactly what we are going to do at the
  3883. 3:16:57moment so
  3884. 3:16:59export function can we can just use K
  3885. 3:17:03here which equals the function and we WR
  3886. 3:17:08here export function No it should not be
  3887. 3:17:11like this okay so we accept right here
  3888. 3:17:15user to be an in
  3889. 3:17:17of user and we're going to also accept
  3890. 3:17:21permissions permissions which should be
  3891. 3:17:25um array of
  3892. 3:17:28strings like this and this should return
  3893. 3:17:32Boolean if the current user uh can one
  3894. 3:17:37of the permissions one of the
  3895. 3:17:39permissions available um right here uh
  3896. 3:17:42or we can check a specific permission
  3897. 3:17:44just by providing permission here
  3898. 3:17:47and removing the arrow now the the
  3899. 3:17:50square brackets sorry so if we just
  3900. 3:17:52return user do permissions includes the
  3901. 3:17:57given permission this means that the
  3902. 3:17:58user can do the specific permission so
  3903. 3:18:02this is related to permission we can
  3904. 3:18:03duplicate this and create second
  3905. 3:18:06function um which we can call has roll
  3906. 3:18:09as an example and right here we're going
  3907. 3:18:11to
  3908. 3:18:12accept um roll if user roles includes
  3909. 3:18:17that specific role now if we go into
  3910. 3:18:20index TS6 so now we can use that method
  3911. 3:18:25right here so let's just wrap
  3912. 3:18:27this and then I'm going to use can if
  3913. 3:18:31the user and we need also to access the
  3914. 3:18:34current user so we can access current
  3915. 3:18:36user in two ways one way is to use page
  3916. 3:18:42here then access props then access out
  3917. 3:18:46and then access user okay this is the
  3918. 3:18:48current user second way is to access the
  3919. 3:18:51user directly or to access out directly
  3920. 3:18:55okay in which case instead of defining
  3921. 3:19:00the props in in the following way we
  3922. 3:19:03have to modify this and we have to use
  3923. 3:19:05uh page props and then in this we have
  3924. 3:19:09to provide some additional um additional
  3925. 3:19:13types so other than the following page
  3926. 3:19:16props which are defined right here which
  3927. 3:19:18is Al and Ziggy uh we have features as
  3928. 3:19:25well um okay so now inside this can we
  3929. 3:19:28can use
  3930. 3:19:30al.
  3931. 3:19:32user and we have to provide the
  3932. 3:19:34permission so the permission in our case
  3933. 3:19:37is
  3934. 3:19:38manage um how it's called manage
  3935. 3:19:41features so we can take this manage
  3936. 3:19:43features if the current user can manage
  3937. 3:19:46features and then we display the
  3938. 3:19:48following link now if we save this and
  3939. 3:19:51if we check in the
  3940. 3:19:53browser we go in the features we don't
  3941. 3:19:56see that button anymore now we're going
  3942. 3:19:58to do something similar in feature
  3943. 3:20:02actions dropdown we have this delete
  3944. 3:20:05feature and edit feature and we can do
  3945. 3:20:08this for both right now we have just a
  3946. 3:20:11manage features but if you have separate
  3947. 3:20:14features for your project
  3948. 3:20:17sorry separate permissions for your
  3949. 3:20:19project you can do the following so
  3950. 3:20:22right here you can just
  3951. 3:20:26write
  3952. 3:20:28can and in this case we need to access
  3953. 3:20:30the user
  3954. 3:20:32um in the following way const user
  3955. 3:20:37equals uh use
  3956. 3:20:40age.
  3957. 3:20:42crops. out.
  3958. 3:20:45user and
  3959. 3:20:47now if user and right here you need to
  3960. 3:20:51provide the permission name let's finish
  3961. 3:20:54the let's solve the synx errors and if
  3962. 3:20:56you again if you have separate
  3963. 3:20:58permissions for edit feature you can
  3964. 3:20:59just write edit feature here and in the
  3965. 3:21:03same
  3966. 3:21:04way you can just write delete
  3967. 3:21:08feature but we don't have these separate
  3968. 3:21:11permissions okay we have just single
  3969. 3:21:13permission which is called manage
  3970. 3:21:16features
  3971. 3:21:17in which case we have to just write a
  3972. 3:21:20single
  3973. 3:21:22can right here around this or
  3974. 3:21:28even I think we can do this around here
  3975. 3:21:31so let's WRA it
  3976. 3:21:38everything or we can do the
  3977. 3:21:41following so
  3978. 3:21:43if I can c current
  3979. 3:21:47user uh
  3980. 3:21:49manage features if it can manage
  3981. 3:21:53features or if it cannot manage features
  3982. 3:21:56let's do like this then we're going to
  3983. 3:21:58Simply return like empty
  3984. 3:22:01thing uh we can return fragment or we
  3985. 3:22:04can just do a return if user cannot
  3986. 3:22:07manage features otherwise we return the
  3987. 3:22:09following and again the current user
  3988. 3:22:12doesn't have any permissions so this is
  3989. 3:22:14what will happen right now so the
  3990. 3:22:16current user doesn't have uh the manage
  3991. 3:22:18features so nothing is displayed but if
  3992. 3:22:21I comment out this part now we see that
  3993. 3:22:24the button is displayed but none of the
  3994. 3:22:26actions are displayed because we expect
  3995. 3:22:28the current user to have edit feature
  3996. 3:22:31and delete feature again this is not for
  3997. 3:22:34us this is for just to give you an idea
  3998. 3:22:37how you can use different
  3999. 3:22:39permissions uh but in our case we can
  4000. 3:22:42simply remove this part
  4001. 3:22:46because we have just one
  4002. 3:22:49if remove that part as
  4003. 3:22:52well now the menu items will be visible
  4004. 3:22:57but if we uncomment this then this is
  4005. 3:23:00gone so current user cannot manage a
  4006. 3:23:03feature so we don't see any actions
  4007. 3:23:06current user can also not manage
  4008. 3:23:09comments so if we go right here the
  4009. 3:23:11current user should not be able to see
  4010. 3:23:12this comment box as well as the delete
  4011. 3:23:15icon right here so this is how we are
  4012. 3:23:18going to
  4013. 3:23:20do uh let's open new comment form scroll
  4014. 3:23:25down below and we can do the following
  4015. 3:23:28if and we need to access to the current
  4016. 3:23:30user which I am going to
  4017. 3:23:35copy like this okay so if can current
  4018. 3:23:42user
  4019. 3:23:45manage comp comments cannot manage
  4020. 3:23:48comments let's do like this then we
  4021. 3:23:50simply
  4022. 3:23:52return now current user cannot manage
  4023. 3:23:55comments so we don't see this comment
  4024. 3:23:57box at
  4025. 3:23:59all as for the delete button for the
  4026. 3:24:03comment
  4027. 3:24:04item we need to check this is the delete
  4028. 3:24:07button for the comment item and by the
  4029. 3:24:09way I think we need to reduce the size
  4030. 3:24:11of the trash icon the smaller one is
  4031. 3:24:14better and right here
  4032. 3:24:16we need to completely hide the following
  4033. 3:24:19uh div okay so let's do the
  4034. 3:24:24following if current user
  4035. 3:24:30can uh can let's provide current user
  4036. 3:24:33first then can manage
  4037. 3:24:37comments but that's not enough because
  4038. 3:24:40current user might be able to manage
  4039. 3:24:42comments we don't have the user so we
  4040. 3:24:44have to again use
  4041. 3:24:48that but that's not enough the current
  4042. 3:24:50user might be able to manage comments
  4043. 3:24:52but this specific comment might not
  4044. 3:24:54belong to the current user okay so we
  4045. 3:24:57need the following and if the comment
  4046. 3:25:01user
  4047. 3:25:02ID is the same as the
  4048. 3:25:07authenticated user
  4049. 3:25:09ID then we should display the button now
  4050. 3:25:12the comment does not actually have user
  4051. 3:25:15ID it it has user so we should probably
  4052. 3:25:19go back and change this into user.
  4053. 3:25:22ID now let's have a look we don't see
  4054. 3:25:25these trash icons anymore the user
  4055. 3:25:28doesn't see any so this this is a
  4056. 3:25:30regular user it can only up Vote or down
  4057. 3:25:32vote or see comments so they can see
  4058. 3:25:35comment but they cannot leave the
  4059. 3:25:36comment so now they can do down vote
  4060. 3:25:39they can do upfold that's all what they
  4061. 3:25:41are able to they can just browse the
  4062. 3:25:43features and see they can click on
  4063. 3:25:45comments which will open the comment the
  4064. 3:25:47actual view page this
  4065. 3:25:50particular uh this particular feature
  4066. 3:25:52doesn't have any comments that's why the
  4067. 3:25:53user doesn't see anything but yeah
  4068. 3:25:56that's it however uh if the user doesn't
  4069. 3:25:59have um such type of ability to leave a
  4070. 3:26:02comment maybe you want to show the
  4071. 3:26:05corresponding message so for
  4072. 3:26:08example if the user cannot manage
  4073. 3:26:11comments then you might need to show it
  4074. 3:26:16like you don't have permission to leave
  4075. 3:26:23comments okay and we can give it some
  4076. 3:26:26classes like text Center and text Gray
  4077. 3:26:32600 gr something like this um if the
  4078. 3:26:36user cannot manage comments yeah that's
  4079. 3:26:39correct the user cannot manage comments
  4080. 3:26:42this is in inside the comment okay no
  4081. 3:26:44this is inside the comment item we we
  4082. 3:26:46should put this in the new comment form
  4083. 3:26:49maybe if user cannot manage comments
  4084. 3:26:52this is something what we can
  4085. 3:26:57return this is what we can return you
  4086. 3:27:01don't have permission to leave comments
  4087. 3:27:02that's
  4088. 3:27:03it okay I think that's good
  4089. 3:27:08um one thing what I have to consider is
  4090. 3:27:13the
  4091. 3:27:14following uh if I log out right right
  4092. 3:27:16now and log in as admin user the admin
  4093. 3:27:21user can do everything so the admin user
  4094. 3:27:23sees the uh new feature uh it can leave
  4095. 3:27:27the comment and also edit the features
  4096. 3:27:30but the even admin users should that's a
  4097. 3:27:33question basically should the admin user
  4098. 3:27:35be able to edit somebody else's feature
  4099. 3:27:39I think yeah we can give that permission
  4100. 3:27:41so the decision right here is up to you
  4101. 3:27:44but I decided that all users will be
  4102. 3:27:47able to edit uh or delete features even
  4103. 3:27:50created by other admin users so that's
  4104. 3:27:54that's fine that's fine I allow this in
  4105. 3:27:57this application you can decide what you
  4106. 3:27:59want if you don't want one admin user to
  4107. 3:28:02be able to edit or delete another admin
  4108. 3:28:05users um admin users feature you have to
  4109. 3:28:10do some additional things like you have
  4110. 3:28:13to probably put a either Define gate or
  4111. 3:28:16policy or put um if similar to this in
  4112. 3:28:21the feature controller that the feature
  4113. 3:28:23user ID should be the currently
  4114. 3:28:24authenticated user ID when trying to um
  4115. 3:28:27destroy or update and in the same way
  4116. 3:28:32inside this feature actions drop down
  4117. 3:28:35you can hide this link or this link if
  4118. 3:28:40the currently authenticated user ID
  4119. 3:28:42doesn't equal to the feature user ID so
  4120. 3:28:45yeah I just giving you ideas how you can
  4121. 3:28:48do in your applications certain things
  4122. 3:28:50in my case I'm just going to leave it
  4123. 3:28:53and just like this we have roles we have
  4124. 3:28:55permissions uh you can use if you need
  4125. 3:28:59you can use has rooll check as well
  4126. 3:29:02right here so you use has role you
  4127. 3:29:05provide the user ID and you provide the
  4128. 3:29:07role like admin a if the user is admin
  4129. 3:29:10then the user um
  4130. 3:29:13Can display can see the following
  4131. 3:29:16uh item so the decision and
  4132. 3:29:19implementation is up to you so I just
  4133. 3:29:22give you try to give you tools and the
  4134. 3:29:24ways how I generally um would do this in
  4135. 3:29:28um an actual projects so this has really
  4136. 3:29:31something we don't need and I think the
  4137. 3:29:32last thing is that we're going to uh add
  4138. 3:29:35user section and admin user will be able
  4139. 3:29:37to manage users only admin users will be
  4140. 3:29:40able to manage users and admin users
  4141. 3:29:42will be able to give uh other r rules or
  4142. 3:29:47change rules to another users now let me
  4143. 3:29:51comment everything and we can call this
  4144. 3:29:54Implement roles uh
  4145. 3:29:59restriction restrictions based on roles
  4146. 3:30:02and
  4147. 3:30:05permissions okay one thing um I want to
  4148. 3:30:08mention is that in the
  4149. 3:30:11spotty um permissions package you can
  4150. 3:30:13find many other ways how you you can
  4151. 3:30:16restrict that uh in your project so
  4152. 3:30:20right now we use middle we approach but
  4153. 3:30:23you can do a different approach um how
  4154. 3:30:26to restrict that so you you I just
  4155. 3:30:28recommend to check the
  4156. 3:30:30documentation and find out how you can
  4157. 3:30:34do certain things uh there are always
  4158. 3:30:37more than one way how you can solve the
  4159. 3:30:40problem how you can uh restrict access
  4160. 3:30:43to certain things and so on the middle
  4161. 3:30:45we is what I used you can find other
  4162. 3:30:48things in the
  4163. 3:30:50documentation okay now what I'm going to
  4164. 3:30:51do is that when the user is trying to
  4165. 3:30:54register that user doesn't have any
  4166. 3:30:57permission okay so and we want that
  4167. 3:31:00every user basically every new user to
  4168. 3:31:03have a role uh user role and that's it
  4169. 3:31:07for this we're going to open
  4170. 3:31:10authenticated session controller which
  4171. 3:31:13is uh which comes with LEL pre is and we
  4172. 3:31:16have the store and that's it when the
  4173. 3:31:18user basically gets
  4174. 3:31:20authenticated uh session uh not
  4175. 3:31:24authenticated we want registered user
  4176. 3:31:27controller when the user
  4177. 3:31:30registers uh right here the user is
  4178. 3:31:33created and on that user we are going to
  4179. 3:31:37call method assign Ro and we have to
  4180. 3:31:41provide roles enam user V value that's
  4181. 3:31:46it so every new user will have a role of
  4182. 3:31:49the user and thus that user will be able
  4183. 3:31:51to um to up vote and down vote uh
  4184. 3:31:56without that basically right now it's
  4185. 3:31:58going to still work however if we open
  4186. 3:32:00this web PHP and we restrict certain
  4187. 3:32:04things right here for
  4188. 3:32:07example if we find this up vote and
  4189. 3:32:10download this is it so to just um leave
  4190. 3:32:13the upload and uh destroy your own
  4191. 3:32:16upvote we can provide right here middle
  4192. 3:32:20wear in the same way like we did uh for
  4193. 3:32:25the um manage features or manage
  4194. 3:32:28comments okay so we haven't used um
  4195. 3:32:31other manage it's not called manage
  4196. 3:32:34upload download permission but we can
  4197. 3:32:37use this as well and if we actually use
  4198. 3:32:41that upload download permission right
  4199. 3:32:43here and if we don't don't add this line
  4200. 3:32:48if we don't assign user role to the
  4201. 3:32:51newly registered users even these new
  4202. 3:32:54users will not be able to up vote and
  4203. 3:32:57down
  4204. 3:32:58vote okay so this is something we don't
  4205. 3:33:01want so there are two ways one way is
  4206. 3:33:03that we can completely avoid the user
  4207. 3:33:06role and we can assume that everyone who
  4208. 3:33:09doesn't have any roles at all it means
  4209. 3:33:13that they are user roles okay they have
  4210. 3:33:15user rows and we don't assign anything
  4211. 3:33:18here we don't also add the middle we
  4212. 3:33:22here and here and every authenticated
  4213. 3:33:24and verified user we have both checks
  4214. 3:33:27right here verified authenticated they
  4215. 3:33:29will be able to do these things okay or
  4216. 3:33:33we can explicitly Define
  4217. 3:33:36that up vote and down vote is only
  4218. 3:33:39possible for the users who have uh like
  4219. 3:33:43specific permissions Okay so again the
  4220. 3:33:46decision is up to you how you're going
  4221. 3:33:48to do this even if I add those this this
  4222. 3:33:51permission upvote permission right here
  4223. 3:33:54now I don't add the permission in the
  4224. 3:33:56feature show feature index um also the
  4225. 3:34:02dashboard um yeah so my point is that
  4226. 3:34:05the user role is kind of very
  4227. 3:34:08basic and
  4228. 3:34:09everyone if they have that user
  4229. 3:34:12role um they will be able to do pretty
  4230. 3:34:15much anything so what I'm going to do is
  4231. 3:34:17the following just to make these things
  4232. 3:34:19easy verified and
  4233. 3:34:22can or can or we can use the RO let's go
  4234. 3:34:26into
  4235. 3:34:27documentation and find this middle wear
  4236. 3:34:30again and we have two ways one is can
  4237. 3:34:34and second is we can also Define this
  4238. 3:34:38aliases for R permission roll or
  4239. 3:34:43permission and once we Define this then
  4240. 3:34:45we can use role and um user in our case
  4241. 3:34:49so let's actually Define this
  4242. 3:34:53aliases let's open app.php from
  4243. 3:34:57bootstrap app and we can Define these
  4244. 3:35:02aliases for roll and permission and
  4245. 3:35:06now if we go in the web PHP right here
  4246. 3:35:10we can say
  4247. 3:35:13roll rolls andam
  4248. 3:35:16um user value so the user needs to be
  4249. 3:35:21verified and also user needs to have
  4250. 3:35:23role um of the user in which case user
  4251. 3:35:27is able to view the dashboard um just
  4252. 3:35:30see the features leave up Vote or down
  4253. 3:35:33vote and that's pretty much it now again
  4254. 3:35:37if I open this registered user
  4255. 3:35:39controller and if I just comment out
  4256. 3:35:42this line don't don't activate this line
  4257. 3:35:45and then I try to sign up we go
  4258. 3:35:52into register
  4259. 3:35:55page uh I'm going to try
  4260. 3:35:57to maybe I can use zura because I think
  4261. 3:36:01I have created that user let me double
  4262. 3:36:05check no I don't have Zora user okay I
  4263. 3:36:08have to actually sign
  4264. 3:36:12up register
  4265. 3:36:17okay let's now register with user zura Z
  4266. 3:36:19WR example.com
  4267. 3:36:25okay I received an email in mail pit we
  4268. 3:36:29can open Local Host
  4269. 3:36:31Port uh
  4270. 3:36:33825 we have new email I'm going to click
  4271. 3:36:36on this okay I activated I verified my
  4272. 3:36:39email but I get this for Beed that's
  4273. 3:36:41because my user doesn't have user role
  4274. 3:36:45and user roll is actually necessary to
  4275. 3:36:48be able to access the dashboard which is
  4276. 3:36:50what we defined exactly right here in
  4277. 3:36:53the following line
  4278. 3:36:55okay now what we can do is open modu has
  4279. 3:36:59roles we can create new record here app
  4280. 3:37:02modules user and the newly registered
  4281. 3:37:04user will probably be zura uh with uh
  4282. 3:37:07with the id4 so we can provide four here
  4283. 3:37:11save that let's provide four here as
  4284. 3:37:13well save that refresh the
  4285. 3:37:17page
  4286. 3:37:18um yeah and this one needs also
  4287. 3:37:22permission probably roll has
  4288. 3:37:27permission the roll
  4289. 3:37:30um the RO has permissions just the user
  4290. 3:37:33didn't have
  4291. 3:37:40permission uh hold on
  4292. 3:37:46oh wait this should not be
  4293. 3:37:49four the role should be user one my
  4294. 3:37:55bad so this user has a role one which is
  4295. 3:38:00user zura has user RW okay now if we
  4296. 3:38:04refresh the
  4297. 3:38:06page zura is able to access the
  4298. 3:38:08dashboard to view features it user zura
  4299. 3:38:11doesn't see this um create new feature
  4300. 3:38:14or edit features and also Zur is not
  4301. 3:38:17able to leave a comment or delete the
  4302. 3:38:19comment they can um he can just uh view
  4303. 3:38:22existing comments but we're going to do
  4304. 3:38:25this for every new user so we're going
  4305. 3:38:26to put this in this registered user
  4306. 3:38:28controller I'm going to uncomment this
  4307. 3:38:30part right now and if we try to register
  4308. 3:38:34right now with another
  4309. 3:38:37user let's use Mary Mary at example.com
  4310. 3:38:47okay we received an
  4311. 3:38:50email
  4312. 3:38:53verify uh let's see what happened the
  4313. 3:38:56section is unauthorized why it's not
  4314. 3:39:02unauthorized
  4315. 3:39:06okay user assigned
  4316. 3:39:08Ro Let's see we have new user marry 5
  4317. 3:39:13assigned
  4318. 3:39:14rle we see see this five here uh let's
  4319. 3:39:17check the email verified dat okay email
  4320. 3:39:21verifi
  4321. 3:39:22dat probably yeah I opened the same one
  4322. 3:39:25I just opened the same previous URL so
  4323. 3:39:27this is the new one for Mary click on
  4324. 3:39:31this now Mary's account was verified and
  4325. 3:39:35Mary is able to access features leave an
  4326. 3:39:38app
  4327. 3:39:39vote
  4328. 3:39:42awesome now let's Implement a assigning
  4329. 3:39:46roles to other users and removing those
  4330. 3:39:48roles for admin
  4331. 3:39:50users let's open PHP storm and I'm going
  4332. 3:39:53to close everything and I'm going to
  4333. 3:39:57open first let's comment everything we
  4334. 3:40:00can call
  4335. 3:40:01this
  4336. 3:40:03um
  4337. 3:40:05assign user rooll
  4338. 3:40:09to to every new user
  4339. 3:40:17okay so I need to create now user
  4340. 3:40:20controller so let me execute PHP artisan
  4341. 3:40:24make controller
  4342. 3:40:27user controller and this should be
  4343. 3:40:30resource
  4344. 3:40:31controller uh so I have to provide model
  4345. 3:40:34to be user as
  4346. 3:40:37well now let's see user
  4347. 3:40:43controller Okay so so I need to list the
  4348. 3:40:47users I need I'm not going to implement
  4349. 3:40:50creating users from admin users we have
  4350. 3:40:52the user registration so we don't need
  4351. 3:40:57create we don't need store as
  4352. 3:41:00well uh we don't want
  4353. 3:41:03show we want edit and update to assign
  4354. 3:41:07the rules to the user and we also don't
  4355. 3:41:11want destroy
  4356. 3:41:15do we yeah we don't want so our main
  4357. 3:41:18focus is just uh roles and permissions
  4358. 3:41:21so that admin user can manage roles and
  4359. 3:41:23permissions if you want to allow admin
  4360. 3:41:25users to delete other users you can do
  4361. 3:41:27this as well and implement this part as
  4362. 3:41:31well okay
  4363. 3:41:32so let's return now inertia render user
  4364. 3:41:38index and we have to provide in return
  4365. 3:41:42um actually we can do this All users
  4366. 3:41:45okay okay um or we can do the paginated
  4367. 3:41:47result as well but um I don't want also
  4368. 3:41:49to over complicate things with
  4369. 3:41:51pagination um I feel that that's kind of
  4370. 3:41:54out of scope of this specific
  4371. 3:41:56tutorial and um cool so we have to
  4372. 3:42:00Define this react file and we have to
  4373. 3:42:04also use user
  4374. 3:42:08resource uh well this is something else
  4375. 3:42:11we don't want to use existing user
  4376. 3:42:13resource collection because that user
  4377. 3:42:16had that um resource only has ID email
  4378. 3:42:20and name and email but we actually
  4379. 3:42:24want the existing roles uh which only
  4380. 3:42:28admin user should be able to see so let
  4381. 3:42:33me do the following let's just return
  4382. 3:42:35user all at the moment then I will come
  4383. 3:42:38back to this so in the edit we are going
  4384. 3:42:41to return inertia render user edit and
  4385. 3:42:45and we want to return specific uh user
  4386. 3:42:48and in the update yeah I will come back
  4387. 3:42:51to this now let's open web.php
  4388. 3:42:55and only admin user should be able to do
  4389. 3:42:59this uh so let's define a new middle
  4390. 3:43:05wear group right here middle we
  4391. 3:43:10verified and roll should be
  4392. 3:43:16rols
  4393. 3:43:17enam
  4394. 3:43:19admin
  4395. 3:43:20value uh let's import this rules enum
  4396. 3:43:25then we call
  4397. 3:43:27group
  4398. 3:43:29function and then Define the rules so
  4399. 3:43:34root get for
  4400. 3:43:38user we're going to use user
  4401. 3:43:40[Music]
  4402. 3:43:42controller index
  4403. 3:43:45and we have to provide name as well
  4404. 3:43:49user.
  4405. 3:43:50index let's import
  4406. 3:43:54this okay next we need update right so
  4407. 3:43:59we're going to copy this uh get we need
  4408. 3:44:02to get specific
  4409. 3:44:04user
  4410. 3:44:06user and this is going to be edit we can
  4411. 3:44:10give it also edit URL user edit and the
  4412. 3:44:15last one is going to be put
  4413. 3:44:21user
  4414. 3:44:22update and user
  4415. 3:44:25update now let's go into resources JS
  4416. 3:44:30pages and feature and I am going to
  4417. 3:44:35actually copy and paste this feature
  4418. 3:44:37folder and call this
  4419. 3:44:43user uh I don't need need create so I'm
  4420. 3:44:47going to delete the
  4421. 3:44:48create I need a list of the users I
  4422. 3:44:52need edit I don't need show as well so
  4423. 3:44:55I'm going to delete show as well so
  4424. 3:44:57let's open out this index and have a
  4425. 3:45:00look so I'm going to look
  4426. 3:45:02for features let's search for all all
  4427. 3:45:06lowercase features and replace that with
  4428. 3:45:11users okay
  4429. 3:45:17then let's search for uppercase F
  4430. 3:45:20features which is the page Title Here in
  4431. 3:45:23here and replace this uppercase you
  4432. 3:45:26users replace this now let's search for
  4433. 3:45:30if we use features anywhere
  4434. 3:45:35else we have the following
  4435. 3:45:38permission which we actually don't need
  4436. 3:45:41create new feature this is called
  4437. 3:45:42feature let's search for feature this is
  4438. 3:45:44used in 12 places we can use the match
  4439. 3:45:48case and wording maybe we can remove
  4440. 3:45:51this wording and just match case uh and
  4441. 3:45:54replace this uppercase F feature with
  4442. 3:45:57the uppercase U
  4443. 3:45:59user let's replace this
  4444. 3:46:05everywhere we don't have this user item
  4445. 3:46:07after replace which we can
  4446. 3:46:10create but I plan to actually turn this
  4447. 3:46:13into table
  4448. 3:46:17so uh let me just use flow flow byte
  4449. 3:46:23table I want to just copy the table
  4450. 3:46:27example this is simple table I just want
  4451. 3:46:30to get the copy uh the um Talon CSS code
  4452. 3:46:34of that and we have this users data
  4453. 3:46:39map yeah I can completely remove this
  4454. 3:46:46so this is TR and here we're going to
  4455. 3:46:49use
  4456. 3:46:50users. dat. map we have user
  4457. 3:46:56here and then we need to return
  4458. 3:46:59TR where is the end of TR here is the
  4459. 3:47:02end of
  4460. 3:47:03TR parentheses and then the curly brace
  4461. 3:47:07and I think we can delete other two tis
  4462. 3:47:11this and this now we have just one
  4463. 3:47:15TR and we have the table headings that
  4464. 3:47:19should be
  4465. 3:47:21username that should be
  4466. 3:47:25email we can just call this name
  4467. 3:47:28email um we can give it created at when
  4468. 3:47:33the user was
  4469. 3:47:34registered and we can use roles maybe
  4470. 3:47:40here and we probably need some
  4471. 3:47:43actions now let's
  4472. 3:47:48output user.name
  4473. 3:47:55user.
  4474. 3:47:58email user do created
  4475. 3:48:04it and user do roles maybe which we can
  4476. 3:48:11join with common space
  4477. 3:48:15user doesn't have created that and also
  4478. 3:48:19we have some syntax
  4479. 3:48:23error uh this parenthesis ends here but
  4480. 3:48:27this parenthesis doesn't end anywhere so
  4481. 3:48:30we have to put this here as well now
  4482. 3:48:33user doesn't have created yet so we need
  4483. 3:48:38to we can remove this user item we need
  4484. 3:48:40to open this user and we have to provide
  4485. 3:48:46created Created it as
  4486. 3:48:50well uh
  4487. 3:48:53string yeah it can be string we can
  4488. 3:48:56Define it as
  4489. 3:48:58string okay now we have that created
  4490. 3:49:02that as
  4491. 3:49:02[Music]
  4492. 3:49:07well we can remove this use page and I
  4493. 3:49:10think that's good so user controller now
  4494. 3:49:13let's open Authentication
  4495. 3:49:15ated layout and we're going to find
  4496. 3:49:19features I'm going to duplicate this and
  4497. 3:49:23call it
  4498. 3:49:25users then right here we need user index
  4499. 3:49:28and let's find the second place where we
  4500. 3:49:31have these
  4501. 3:49:35features here and here we need user and
  4502. 3:49:40here we need
  4503. 3:49:41users cool let's open open the page
  4504. 3:49:45let's click on
  4505. 3:49:47users okay user doesn't have the right
  4506. 3:49:52roles okay that makes perfect sense and
  4507. 3:49:54I think even the menu should not be
  4508. 3:49:58visible if the user doesn't have the
  4509. 3:50:00correct role so we can use has rooll if
  4510. 3:50:05the current user has rooll admin if it
  4511. 3:50:08doesn't have has roll admin we can use
  4512. 3:50:11has roll or k which checks the permit
  4513. 3:50:15so can if current
  4514. 3:50:18user let's import this can first then we
  4515. 3:50:22have the current user and the permission
  4516. 3:50:24is called manage users if the current
  4517. 3:50:27user can manage users we display the
  4518. 3:50:29following navigation item we're going to
  4519. 3:50:31copy this this is for the responsive Now
  4520. 3:50:34link we're going to search for
  4521. 3:50:38second right here if the current user
  4522. 3:50:41can manage users then we display the
  4523. 3:50:44menual item okay now the current user
  4524. 3:50:46cannot manage users so the user doesn't
  4525. 3:50:48see users um navigation item and even
  4526. 3:50:52the user is not able to access this
  4527. 3:50:54through URL perfect let's log
  4528. 3:50:57out login is
  4529. 3:51:00admin okay what do what's going on user
  4530. 3:51:03doesn't have the right rules
  4531. 3:51:06okay
  4532. 3:51:10user okay let's access dashboard
  4533. 3:51:16now let's let's check uh am I
  4534. 3:51:20authenticated I think I am authenticated
  4535. 3:51:22with admin user right
  4536. 3:51:31so H that's interesting so current
  4537. 3:51:36user current
  4538. 3:51:39user doesn't have user
  4539. 3:51:42role and that's why admin user is not
  4540. 3:51:45able to access the dashboard that's
  4541. 3:51:48actually very interesting
  4542. 3:51:51thing so we we have not defined that the
  4543. 3:51:55admin user is kind of superet of other
  4544. 3:52:01roles okay we have just roles and
  4545. 3:52:03permissions and permissions are
  4546. 3:52:05associated to roles in this case because
  4547. 3:52:07the current user is admin user and
  4548. 3:52:09current user is not doesn't have user
  4549. 3:52:11role the current user is not not
  4550. 3:52:15actually able to access the following
  4551. 3:52:19page now what we can do is to Define
  4552. 3:52:24multiple roles that the current user
  4553. 3:52:27needs to have um one role or second or
  4554. 3:52:31third something like this uh in the
  4555. 3:52:34following way so here we have the RO
  4556. 3:52:39let's move this
  4557. 3:52:42down and I think we can
  4558. 3:52:45use Sprint
  4559. 3:52:48F uh
  4560. 3:52:50roll then one R comma then we can use
  4561. 3:52:55second R comma and third R we have
  4562. 3:52:58actually three rols right so one is user
  4563. 3:53:03second is commenter we can move
  4564. 3:53:08this down as
  4565. 3:53:11well and the last one is
  4566. 3:53:18admin so to be able to access these
  4567. 3:53:21roots the user should have at least one
  4568. 3:53:24of the following
  4569. 3:53:30rules now let's reload the
  4570. 3:53:37page uh actually that was related to
  4571. 3:53:40cards not roles
  4572. 3:53:48yeah we have to use pipe not the comma
  4573. 3:53:51the the comma is for CS so here we need
  4574. 3:53:54pipe here we need
  4575. 3:53:58pipe okay now admin user is able to
  4576. 3:54:02access dashboard
  4577. 3:54:05and uh it should be able to access
  4578. 3:54:09to users page as
  4579. 3:54:12well what station
  4580. 3:54:15page not found page users
  4581. 3:54:19index uh it is user not users so we have
  4582. 3:54:23to open user controller and change this
  4583. 3:54:25into user edit user index and that's
  4584. 3:54:30it refresh
  4585. 3:54:33it click on
  4586. 3:54:37user okay cannot read properties of
  4587. 3:54:40undefined reading map okay that makes
  4588. 3:54:42sense so from here we are rning just
  4589. 3:54:44user all and then in the index of the
  4590. 3:54:48user we just treat that users to be
  4591. 3:54:51paginated data meaning that it has data
  4592. 3:54:54inside there again if you are going to
  4593. 3:54:56do pagination you probably need that but
  4594. 3:54:59in our case I'm just going to change
  4595. 3:55:00this into an array of user so users is
  4596. 3:55:04an array of user and instead
  4597. 3:55:07of uh instead of
  4598. 3:55:10users um. data map I'm just going to do
  4599. 3:55:14user users.
  4600. 3:55:16map refresh
  4601. 3:55:20that okay this is another thing we try
  4602. 3:55:24to call join on roles but the user
  4603. 3:55:28doesn't have
  4604. 3:55:30rooll uh so this is what we are going to
  4605. 3:55:34do uh let me check
  4606. 3:55:37out
  4607. 3:55:39user resource here we have the
  4608. 3:55:42permissions and rules and we probably
  4609. 3:55:45need also created
  4610. 3:55:48at so admin user is
  4611. 3:55:52able basically to view more sensitive
  4612. 3:55:55information than regular users so if if
  4613. 3:55:59we can use this out user resource we can
  4614. 3:56:02create new Resource as well but we can
  4615. 3:56:04use this out user
  4616. 3:56:06resource uh so that these
  4617. 3:56:10users uh user all to go inside that out
  4618. 3:56:14user resource collection provide user
  4619. 3:56:17all here uh yeah I think that should be
  4620. 3:56:22it however the returned response will
  4621. 3:56:24still have data inside
  4622. 3:56:26there users map is not a function so if
  4623. 3:56:30we
  4624. 3:56:31just
  4625. 3:56:34um if we just disable
  4626. 3:56:38WP let me
  4627. 3:56:41think yeah we actually have the r
  4628. 3:56:44disabled so then we probably need to
  4629. 3:56:48access the
  4630. 3:56:49collection and we can just return an
  4631. 3:56:51array of
  4632. 3:56:53that which is going to be plain array
  4633. 3:56:56just like this and we have to add extra
  4634. 3:57:00column which is going to be for
  4635. 3:57:04actions just like this okay so create
  4636. 3:57:08new user name email created at
  4637. 3:57:15okay what do I return inside created
  4638. 3:57:19it okay created at
  4639. 3:57:24format
  4640. 3:57:27this and here we see rules as
  4641. 3:57:31well every user has some
  4642. 3:57:36role and we can provide some additional
  4643. 3:57:38actions like what we want here is just
  4644. 3:57:41edit action so we can open this
  4645. 3:57:44and put a button here or maybe we need
  4646. 3:57:48to put a link with hre which is going to
  4647. 3:57:51be Roots
  4648. 3:57:53dot uh not dot but um user edit
  4649. 3:57:59providing user we can call this
  4650. 3:58:04edit what's wrong with
  4651. 3:58:07that let's see we see this
  4652. 3:58:11edit which is a
  4653. 3:58:15we is regular link we
  4654. 3:58:19can we can make this
  4655. 3:58:23button but why do I hear this
  4656. 3:58:38morning user.
  4657. 3:58:41edit user edit
  4658. 3:58:48where's this user
  4659. 3:58:55edit yeah it expects user not sure
  4660. 3:58:59what's what's wrong with
  4661. 3:59:01that okay so when we click on this it's
  4662. 3:59:04going to open the edit
  4663. 3:59:09page that probably needs some pings
  4664. 3:59:21and
  4665. 3:59:23probably last
  4666. 3:59:26name uh text
  4667. 3:59:29blue 500 something like
  4668. 3:59:33this okay clicking on this should open
  4669. 3:59:35the edit page which we don't have right
  4670. 3:59:38now uh let's just remove that create
  4671. 3:59:42button because we don't want uh uh new
  4672. 3:59:44user creation by admin users we just
  4673. 3:59:46want ass signing roles and permissions
  4674. 3:59:48to them so this edit should
  4675. 3:59:52open uh this edit now let's let's have a
  4676. 3:59:56look so here we have this feature let's
  4677. 3:59:59again do a replace so let's search for
  4678. 4:00:02lowercase feature and replace this with
  4679. 4:00:05user and that's going to be probably in
  4680. 4:00:08multiple
  4681. 4:00:09places let's do this replace then we can
  4682. 4:00:13search for uppercase F feature replace
  4683. 4:00:17this with uppercase U
  4684. 4:00:23user
  4685. 4:00:27okay then do we have any more feature
  4686. 4:00:30here
  4687. 4:00:31available we don't have any more feature
  4688. 4:00:35here so we have
  4689. 4:00:37[Music]
  4690. 4:00:38username uh we can duplicate this we
  4691. 4:00:40have email
  4692. 4:00:46we
  4693. 4:00:47have what information do we
  4694. 4:00:50have email verify that password I don't
  4695. 4:00:53want to manage password or even email or
  4696. 4:00:55anything like this what I want to manage
  4697. 4:00:58is
  4698. 4:00:59roles which is going to be user
  4699. 4:01:05roles now if we scroll down below we
  4700. 4:01:09have the
  4701. 4:01:10description uh I think I'm going to
  4702. 4:01:12remove this
  4703. 4:01:17we don't need this we have just username
  4704. 4:01:21let's see if the form
  4705. 4:01:23opens click on edit okay the form opens
  4706. 4:01:27we just have
  4707. 4:01:32name we have email as well we can
  4708. 4:01:38display so that should be disabled
  4709. 4:01:44okay we should not be able to make
  4710. 4:01:45changes to the name uh
  4711. 4:01:50and we
  4712. 4:01:52can duplicate this for
  4713. 4:01:59email this is for
  4714. 4:02:05email
  4715. 4:02:08oops then we have email here we should
  4716. 4:02:11change
  4717. 4:02:12that let me do this very quickly is
  4718. 4:02:14you I'm going to remove that email here
  4719. 4:02:18and that should be disabled as
  4720. 4:02:20well
  4721. 4:02:22okay now we
  4722. 4:02:24need
  4723. 4:02:26roles now that's
  4724. 4:02:29interesting so we need to use checkbox
  4725. 4:02:32for this let me Define t and we do have
  4726. 4:02:37uh checkbox component which is used
  4727. 4:02:41somewhere probably in login so let's
  4728. 4:02:45search for
  4729. 4:02:46checkbox in the login this is how it is
  4730. 4:02:50used so let me copy this open user
  4731. 4:02:54edit paste this but I want to iterate
  4732. 4:02:57this over user roles so user
  4733. 4:03:02rolls.
  4734. 4:03:04map
  4735. 4:03:07roll I want to display checkboxes for
  4736. 4:03:10each
  4737. 4:03:11role but actually I don't want to to
  4738. 4:03:13iterate over user roles but I want to
  4739. 4:03:15iterate over all the available
  4740. 4:03:19roles uh this is how I'm going to do
  4741. 4:03:22this I'm going to open user controller
  4742. 4:03:24and right here I'm going to select all
  4743. 4:03:29roles
  4744. 4:03:31um
  4745. 4:03:33roll spoty permission model roll
  4746. 4:03:37all let's cure them and return them now
  4747. 4:03:41we have
  4748. 4:03:44current user and we
  4749. 4:03:47have uh we have roles as
  4750. 4:03:51well p uh we can Define that at the
  4751. 4:03:55moment rules has type of
  4752. 4:03:59any and let's just print what is
  4753. 4:04:03rules but we have syntax zos it is not
  4754. 4:04:05going to work so we assume that roles is
  4755. 4:04:08an array we iterate over
  4756. 4:04:11roles and we print some some information
  4757. 4:04:14for each Ro so we can check in the
  4758. 4:04:16database as well rooll has name and
  4759. 4:04:19guard name created it and update that so
  4760. 4:04:22we just need probably
  4761. 4:04:25name we have roll here and let's just
  4762. 4:04:29put the
  4763. 4:04:33checkbox
  4764. 4:04:36unchecked um I will come back to this
  4765. 4:04:39let me just have a visual look
  4766. 4:04:44okay uh the role actually has a type of
  4767. 4:04:47any again let me Define this right
  4768. 4:04:51now console
  4769. 4:04:56refresh okay we need
  4770. 4:04:58um we need key and we need
  4771. 4:05:02this
  4772. 4:05:04here well actually I need to Define
  4773. 4:05:09div checkbox and then I need roll. name
  4774. 4:05:13name
  4775. 4:05:14maybe and we need to give key roll.
  4776. 4:05:21ID okay user commenter
  4777. 4:05:25admin uh where we use this check
  4778. 4:05:32box we have this label as well I'm going
  4779. 4:05:36to copy this
  4780. 4:05:41label and put this here
  4781. 4:05:45and it
  4782. 4:05:47needs key to be r.
  4783. 4:05:51ID again let's remove
  4784. 4:05:53this instead of remember
  4785. 4:05:56me we
  4786. 4:05:58need roll.
  4787. 4:06:02name okay so we can give this
  4788. 4:06:06one uh margin btom
  4789. 4:06:118 Okay so that's not bad however these
  4790. 4:06:15are just the RO names but we have the
  4791. 4:06:17corresponding userfriendly
  4792. 4:06:20uh Ro names so which are inside roles
  4793. 4:06:25Anam so here it goes with uppercase a
  4794. 4:06:28and u and commenter so you might have
  4795. 4:06:31also more complex roles and permissions
  4796. 4:06:34where you have uh multiple names
  4797. 4:06:37multiple words in a name of a role and
  4798. 4:06:40so on so we have to use these labels as
  4799. 4:06:43well I'm going to go into user
  4800. 4:06:46controller and from here we're going to
  4801. 4:06:48return roll uh
  4802. 4:06:51labels this is going to be rolls
  4803. 4:06:55enam uh
  4804. 4:06:58labels now we have this Ro labels which
  4805. 4:07:01we can accept what's that user item we
  4806. 4:07:05can remove this imated data we can
  4807. 4:07:07remove this text are input we can remove
  4808. 4:07:09this so right here we have R labels and
  4809. 4:07:13again we can Define that roll
  4810. 4:07:18labels
  4811. 4:07:19is an array of string or we can Define
  4812. 4:07:24record of string and
  4813. 4:07:28string it has key value peers
  4814. 4:07:34basically so here from this R labels we
  4815. 4:07:39need to access R
  4816. 4:07:41name that's going to be Ro label
  4817. 4:07:44let's have a
  4818. 4:07:47look now as you see we have the uh nice
  4819. 4:07:52um
  4820. 4:07:53labels of the permissions and if we add
  4821. 4:07:57um this is admin as an example we can
  4822. 4:08:03see this is admin here so this is coming
  4823. 4:08:06from here
  4824. 4:08:07also okay now the thing is that we have
  4825. 4:08:10to we have to put that into data and
  4826. 4:08:14send that to the server right
  4827. 4:08:17so let me
  4828. 4:08:20print data here and at the moment in the
  4829. 4:08:26data we have array that's why it's not
  4830. 4:08:31possible to print that so we're going to
  4831. 4:08:32use Json
  4832. 4:08:34stringify data undefined to
  4833. 4:08:39oops cool email name and email only and
  4834. 4:08:44if we check the data we have
  4835. 4:08:47roles as well which
  4836. 4:08:51is user roles however user roles is an
  4837. 4:08:55area
  4838. 4:08:56right why I don't see that user roles
  4839. 4:08:59let me just
  4840. 4:09:02print let's duplicate this and print
  4841. 4:09:05user as
  4842. 4:09:06well user one two three four yeah we
  4843. 4:09:12don't see we don't see user roles and
  4844. 4:09:15probably because from the user
  4845. 4:09:17controller we are just returning this
  4846. 4:09:19user but we should return new out user
  4847. 4:09:23resource because this is what we are
  4848. 4:09:25returning from the
  4849. 4:09:27list now we are going to have roles as
  4850. 4:09:31well and
  4851. 4:09:32permissions and here we have roles as
  4852. 4:09:37well
  4853. 4:09:40okay let me check this checkbox
  4854. 4:09:44which has value
  4855. 4:09:50there let's go into user
  4856. 4:09:56edit and right
  4857. 4:10:00here uh we have to provide value to
  4858. 4:10:05be roll
  4859. 4:10:08dot
  4860. 4:10:10name we have to provide checked as as
  4861. 4:10:13well this should be
  4862. 4:10:15checked
  4863. 4:10:19if let me think if
  4864. 4:10:23user. roles
  4865. 4:10:25includes R
  4866. 4:10:29name now refresh the
  4867. 4:10:34page we have
  4868. 4:10:38this okay we have the checked prop on
  4869. 4:10:41form filled without unchain we need
  4870. 4:10:43unchange Handler as well
  4871. 4:10:46unchange and what we expect here
  4872. 4:10:54event and we have to um we have to
  4873. 4:10:58update data
  4874. 4:11:00rules so here we have event Target
  4875. 4:11:04checked if that specific thing is
  4876. 4:11:07checked or not and we have to put this
  4877. 4:11:09inside data so we're going to call set
  4878. 4:11:12data
  4879. 4:11:13for
  4880. 4:11:21roles uh let me actually change this
  4881. 4:11:24into its own function like on Roll
  4882. 4:11:33change const on Roll
  4883. 4:11:40change okay so we take event here let's
  4884. 4:11:45print the event uh and print the event
  4885. 4:11:50Target value we can provide this this is
  4886. 4:12:01anything okay when I check something we
  4887. 4:12:04get admin even Target value uh that's
  4888. 4:12:11admin okay and we're going to put
  4889. 4:12:14that uh let's also print if it's checked
  4890. 4:12:17or not not only value but
  4891. 4:12:21checked so click on this admin
  4892. 4:12:24true admin true so we are trying to
  4893. 4:12:28check
  4894. 4:12:30that however because we have this
  4895. 4:12:34checked uh the user
  4896. 4:12:38roles it should be data roles includes
  4897. 4:12:42rle name
  4898. 4:12:46so if I remove this
  4899. 4:12:51checked now it is get checked and
  4900. 4:12:54checked look at this so I checked admin
  4901. 4:12:58true then uncheck admin
  4902. 4:13:03false uh let's actually print what we
  4903. 4:13:07had previously Json
  4904. 4:13:11stringify data
  4905. 4:13:13undefined to I'm interested in the rules
  4906. 4:13:18so we're going to put that inside
  4907. 4:13:24rules set
  4908. 4:13:28data
  4909. 4:13:30roles and we're going to see if it's
  4910. 4:13:33checked or unchecked so
  4911. 4:13:36event
  4912. 4:13:38Target uh checked if it's checked
  4913. 4:13:43then we have data
  4914. 4:13:45rules so we are going to do the
  4915. 4:13:47following inside set
  4916. 4:13:51data we are going to put data roles
  4917. 4:13:56filter not filter but actually push
  4918. 4:13:59inside data
  4919. 4:14:01roles we are going to add new rle and
  4920. 4:14:04this is going to be event Target
  4921. 4:14:09value if it is not checked then we are
  4922. 4:14:13going to remove from data roles so we
  4923. 4:14:16are going to
  4924. 4:14:18do data rols
  4925. 4:14:24filter if R does not equal
  4926. 4:14:29to event Target value basically filter
  4927. 4:14:34everything that is not this event Target
  4928. 4:14:39value okay and we need to destructure
  4929. 4:14:42this
  4930. 4:14:44and now we can have a look if I refresh
  4931. 4:14:49it uh commenter
  4932. 4:14:53why hold
  4933. 4:14:57on data okay data rules contains
  4934. 4:15:02commenter okay we need this checked to
  4935. 4:15:05be if data
  4936. 4:15:09roles includes r. name then we Market
  4937. 4:15:13has
  4938. 4:15:14checked now let's let's try
  4939. 4:15:18to test this Okay commenter click on
  4940. 4:15:22this now commenter was removed from rols
  4941. 4:15:24click on this commenter was added into
  4942. 4:15:26rols now we added admin and we edit user
  4943. 4:15:31okay so we we can have this as checkbox
  4944. 4:15:36and give user multiple roles but
  4945. 4:15:38basically uh our implementation
  4946. 4:15:44is um so that one permission actually
  4947. 4:15:49covers another and we are mostly working
  4948. 4:15:51with permissions not roles um on
  4949. 4:15:55the on the router level so we only use
  4950. 4:15:59rules right here and we use all three
  4951. 4:16:02roles but right here we use permissions
  4952. 4:16:04okay and generally it's good practice to
  4953. 4:16:06work with permissions and we should have
  4954. 4:16:08roles and permissions and the user
  4955. 4:16:10should have roles and permissions should
  4956. 4:16:11be part of the roles
  4957. 4:16:14so in this case we can even switch this
  4958. 4:16:15into radio so that that's what I'm
  4959. 4:16:17trying to tell
  4960. 4:16:20you user commenter or admin yeah I think
  4961. 4:16:24we can do this so I'm going to just
  4962. 4:16:25duplicate checkbox call this
  4963. 4:16:31radio uh change this into
  4964. 4:16:34radio type
  4965. 4:16:38radio and inside this edit we can change
  4966. 4:16:43this into
  4967. 4:16:45radio components radio name is not
  4968. 4:16:49remember name
  4969. 4:16:52is
  4970. 4:16:55rolls now
  4971. 4:16:58let's so this looks like a radio but
  4972. 4:17:01it's a square radio because we probably
  4973. 4:17:05have rounded
  4974. 4:17:10oh let's look no this looks like
  4975. 4:17:17radio and and
  4976. 4:17:20and let's give it also margin bottom of
  4977. 4:17:24something like three or it's too much
  4978. 4:17:28one
  4979. 4:17:29oops one so now let's refresh the page
  4980. 4:17:36now user has only one role and that's
  4981. 4:17:38commenter now I click on
  4982. 4:17:40admin okay that gets edit
  4983. 4:17:45uh on Roll change okay if we decide that
  4984. 4:17:49we're going to only
  4985. 4:17:51have one
  4986. 4:17:55roll to the user then if that gets
  4987. 4:17:59checked we're going to add only that
  4988. 4:18:02nothing
  4989. 4:18:04else that's that's how we're going to do
  4990. 4:18:07this we can remove this
  4991. 4:18:11part refresh
  4992. 4:18:14it we have one roll click on user now it
  4993. 4:18:17has only user commenter admin and we can
  4994. 4:18:21have only one role to the user at a
  4995. 4:18:23given moment so this is a commentary
  4996. 4:18:24user and we can click on admin and click
  4997. 4:18:28on Save and now um we're going to go to
  4998. 4:18:31the back end and see uh what information
  4999. 4:18:34we're getting right here so
  5000. 4:18:37request
  5001. 4:18:41validate uh we don't actually need name
  5002. 4:18:44or email we are interested in just roles
  5003. 4:18:48so let's get roles is going to be
  5004. 4:18:52required an
  5005. 4:18:54array and let's take data and let's
  5006. 4:18:59print what data we
  5007. 4:19:02have so we have only admin click on Save
  5008. 4:19:05we have roles and admin that's perfect
  5009. 4:19:07so on the following user we can call
  5010. 4:19:11synchr
  5011. 4:19:12and provide data roles so basically
  5012. 4:19:15every other rle should be removed so if
  5013. 4:19:18we check right now uh model has roles
  5014. 4:19:22the user we are trying to edit has id2
  5015. 4:19:26so it has Ro two which is
  5016. 4:19:29commenter now if we click on hold on um
  5017. 4:19:34let's remove this DD and return
  5018. 4:19:38back
  5019. 4:19:41with success
  5020. 4:19:44roles updated
  5021. 4:19:46successfully okay I'm switching to admin
  5022. 4:19:49click on
  5023. 4:19:50Save rolls updated successfully and we
  5024. 4:19:53can
  5025. 4:19:55check right here now we see that
  5026. 4:19:57something was changed on user which has
  5027. 4:20:02id2 this is it now it has role three and
  5028. 4:20:07that's awesome um now if I log out and
  5029. 4:20:12log in
  5030. 4:20:14with commenter
  5031. 4:20:16[Music]
  5032. 4:20:17role now that commenter user is not
  5033. 4:20:19commenter anymore that user is admin and
  5034. 4:20:22that user can actually create new
  5035. 4:20:23features and manage other users and
  5036. 4:20:27that's actually pretty
  5037. 4:20:30cool okay uh in the web
  5038. 4:20:35PHP managing
  5039. 4:20:38users is only for admin but yes this
  5040. 4:20:42user is able to actually see the users
  5041. 4:20:45and click on this and let's see if the
  5042. 4:20:50that commenter user will just change his
  5043. 4:20:53own role into commenter
  5044. 4:20:57again user doesn't have the right role
  5045. 4:20:59okay something happened and that
  5046. 4:21:01something was that probably the request
  5047. 4:21:03was updated so the role was changed and
  5048. 4:21:06then we were trying to go back into user
  5049. 4:21:09page in which case we got the following
  5050. 4:21:12error now that commenter user is still
  5051. 4:21:14commenter and doesn't have uh admin
  5052. 4:21:17permission to view
  5053. 4:21:20users and that's basically it so I
  5054. 4:21:26can remove this pre from here I can log
  5055. 4:21:31out and I can log in as
  5056. 4:21:35admin and see that admin user can see
  5057. 4:21:38other users can edit and change the roll
  5058. 4:21:43let's just put um label right here
  5059. 4:21:47inside
  5060. 4:21:48H3 uh
  5061. 4:21:53roll
  5062. 4:21:55front bold something like
  5063. 4:21:59this yeah margin buttom
  5064. 4:22:07one uh we have this simp label which is
  5065. 4:22:11just a label
  5066. 4:22:13text
  5067. 4:22:14as yeah we can we can give it something
  5068. 4:22:17like this as
  5069. 4:22:22well value should be
  5070. 4:22:24roll HTML 4 is going to be
  5071. 4:22:29for
  5072. 4:22:32nothing okay that's
  5073. 4:22:35it okay now we have also implemented
  5074. 4:22:40functionality to change roles admin
  5075. 4:22:43users now have ability to change the
  5076. 4:22:45roles on another
  5077. 4:22:48users which is pretty cool so if we
  5078. 4:22:50imagine the following case that there
  5079. 4:22:53are some regular
  5080. 4:22:57users um which are just up voting down
  5081. 4:23:00voting but admin users want to promote
  5082. 4:23:02those regular users they can open that
  5083. 4:23:05regular user and change the role into
  5084. 4:23:09commenter and now that regular user
  5085. 4:23:13which previously wasn't able to leave
  5086. 4:23:14comments now can access
  5087. 4:23:17features and leave a comment as
  5088. 4:23:23well that's awesome and they can also
  5089. 4:23:25delete their own comments obviously now
  5090. 4:23:28let's start working on inertia 2.0 new
  5091. 4:23:32features let's open inertia
  5092. 4:23:34documentation and here we have this
  5093. 4:23:36version to iners js. comom and if we
  5094. 4:23:39check the upgrade guide we see the
  5095. 4:23:40upgrade guide as well as the new
  5096. 4:23:42features ping prefetching deferred props
  5097. 4:23:46infinite scrolling and theay loading
  5098. 4:23:48data on scroll okay let's start one by
  5099. 4:23:53one and the first one which I'm going to
  5100. 4:23:55do is polling so that's actually pretty
  5101. 4:23:57straightforward let let's actually
  5102. 4:23:59implement this in our code and then we
  5103. 4:24:00can cover the documentation as well the
  5104. 4:24:03implementation is super easy uh first
  5105. 4:24:05let me comment everything what uh we
  5106. 4:24:07made so
  5107. 4:24:09far
  5108. 4:24:11implement
  5109. 4:24:12users listing and Rule
  5110. 4:24:20changing cool let's close everything and
  5111. 4:24:24then I'm going to reopen index. TS6
  5112. 4:24:28that's the features uh actually that's
  5113. 4:24:31the users component we want index TSX
  5114. 4:24:34from feature folder that's it okay and
  5115. 4:24:37it's super easy to actually activate
  5116. 4:24:40polling in inertia uh version two and we
  5117. 4:24:44have to use for this use Paul so we just
  5118. 4:24:48use use Paul hook and we provide the
  5119. 4:24:52interval how often we want it to be
  5120. 4:24:54updated I Believe by default this is 2
  5121. 4:24:57seconds we can set this whatever we want
  5122. 4:25:00um the we have to provide number of
  5123. 4:25:02milliseconds right here and that's all
  5124. 4:25:05so now if we open our features page we
  5125. 4:25:08open the developer tools we check the
  5126. 4:25:11network and we see that once in every 3
  5127. 4:25:15second it is making requests and um
  5128. 4:25:19performing long polling actually so if I
  5129. 4:25:22copy this URL right now and we open um
  5130. 4:25:26another guest right here we try to
  5131. 4:25:29access to the features page and I'm
  5132. 4:25:32going to use now different user user at
  5133. 4:25:34example.com provide the password and
  5134. 4:25:38just have a look so now here we see this
  5135. 4:25:40is the admin user admin user is that
  5136. 4:25:42there are three up folds and the admin
  5137. 4:25:45user itself has up folded that now this
  5138. 4:25:47is a regular user and regular user is
  5139. 4:25:50clicking on this upfold now look at this
  5140. 4:25:53what happens in couple of seconds this
  5141. 4:25:56gets updated immediately because of the
  5142. 4:25:59long polling we download this we see two
  5143. 4:26:02here we're going to see two here as well
  5144. 4:26:04so that gets updated like almost in real
  5145. 4:26:07time and that's because of this polling
  5146. 4:26:10now let's check the documentation of the
  5147. 4:26:11polling
  5148. 4:26:12usage is super easy as we saw so we can
  5149. 4:26:15provide right here the number of
  5150. 4:26:17milliseconds and we even can provide on
  5151. 4:26:19start and on finished uh callbacks so we
  5152. 4:26:24if we want to notify the user something
  5153. 4:26:27that the data has been updated once uh
  5154. 4:26:29it has been completed or we can even
  5155. 4:26:31show a toast that the data polling has
  5156. 4:26:33been started or something like this so
  5157. 4:26:35if the operation of updating the UI is
  5158. 4:26:38kind of expensive it takes a couple of
  5159. 4:26:40seconds we can uh use use these hooks
  5160. 4:26:44not the hooks but the callbacks just
  5161. 4:26:47to update the user about this so we can
  5162. 4:26:50also provide update start false if we
  5163. 4:26:53don't want it to be automatically
  5164. 4:26:54started and we can take this start and
  5165. 4:26:57stop functions and we can bind this into
  5166. 4:27:00buttons or into any action uh from where
  5167. 4:27:03we can start and stop the polling so we
  5168. 4:27:06we could put a buttons right here in the
  5169. 4:27:08exact same way which I'm not going to do
  5170. 4:27:10I think because this is very obvious
  5171. 4:27:12and in the following way we could do
  5172. 4:27:14this so I recommend to check the
  5173. 4:27:16documentation regarding polling it's
  5174. 4:27:18super easy to use and we are actually
  5175. 4:27:20already using that um yeah cool now
  5176. 4:27:24let's move on in on the next uh one
  5177. 4:27:27which is deferred props so deferred
  5178. 4:27:29props is another awesome thing we can
  5179. 4:27:32see the documentation as well but the
  5180. 4:27:34whole idea of the differred props is
  5181. 4:27:36that if some of the props which we are
  5182. 4:27:40going to return or the page takes a lot
  5183. 4:27:44of time or quite some time to be fetched
  5184. 4:27:47from the database or fetched from some
  5185. 4:27:49external apis so we can make them as
  5186. 4:27:54deferred and those props uh the page
  5187. 4:27:57will be loaded without those props but
  5188. 4:27:59those props will be added a later stage
  5189. 4:28:02to the page now let's open a single
  5190. 4:28:05feature this is features and now let's
  5191. 4:28:07do the following so we're going to
  5192. 4:28:10display the uh features itself but for
  5193. 4:28:13the comments we are going to return it
  5194. 4:28:15as a deferred prop okay let's try this
  5195. 4:28:19let's open now
  5196. 4:28:22Feature Feature controller and find a
  5197. 4:28:26method called show and from here we have
  5198. 4:28:29couple of things like the upvote count
  5199. 4:28:31user has upvoted and few other things
  5200. 4:28:33and the feature itself has access to
  5201. 4:28:37comments we are returning this in the
  5202. 4:28:38following way so this is what I'm going
  5203. 4:28:40to do let's just remove these comments
  5204. 4:28:42from this uh feature resource okay now
  5205. 4:28:45there will be an error on the front end
  5206. 4:28:47which we're going to fix and we're going
  5207. 4:28:49to put those comments here but we're
  5208. 4:28:52going to make this as deferred prop so
  5209. 4:28:54we're going to use
  5210. 4:28:56inertia defer let's use function here
  5211. 4:29:01use feature and we are going to
  5212. 4:29:07return feature comments now uh let's
  5213. 4:29:12let's imagine that selecting these
  5214. 4:29:13feature comments is actually heavy
  5215. 4:29:15operation and it takes like five 10
  5216. 4:29:18seconds okay so I'm going to use sleep
  5217. 4:29:20here provide
  5218. 4:29:22five and because now feature doesn't
  5219. 4:29:24have comments and comments is a separate
  5220. 4:29:26thing we have to update the front end as
  5221. 4:29:28well so here we are taking now this is
  5222. 4:29:31index we're going to open
  5223. 4:29:34show in here we have this feature and
  5224. 4:29:38feature has comments so we're going to
  5225. 4:29:39search for comments and instead of
  5226. 4:29:42feature comments we can directly access
  5227. 4:29:44comments and we need to directly access
  5228. 4:29:47take these comments from here as well
  5229. 4:29:49and let's just Define the proper type
  5230. 4:29:53feature comments is an array of comment
  5231. 4:29:58like this okay cool uh we can also
  5232. 4:30:01assume that feature doesn't have
  5233. 4:30:03comments but that's not important uh
  5234. 4:30:05right now so the result is not going to
  5235. 4:30:09change let's have a look so we are
  5236. 4:30:11iterating over comments we have comment
  5237. 4:30:14and we're providing comment right here
  5238. 4:30:17what's the
  5239. 4:30:22error the comment
  5240. 4:30:24item yeah it expects the comment so
  5241. 4:30:27what's the
  5242. 4:30:30issue the
  5243. 4:30:32comment hold on so that's a different
  5244. 4:30:35comment my bad so that
  5245. 4:30:39comment should be any import from types
  5246. 4:30:44like
  5247. 4:30:45this and we can remove this feature
  5248. 4:30:47right okay this is how we should have it
  5249. 4:30:50and now if we refresh the
  5250. 4:30:54page let's have a look now the comments
  5251. 4:30:57doesn't exist and we have the following
  5252. 4:30:59error which is something we're going to
  5253. 4:31:00fix so comments at first when the page
  5254. 4:31:03is rendered is null so it doesn't exist
  5255. 4:31:05that's why we try to call map and it
  5256. 4:31:08gives us simply an error so we don't
  5257. 4:31:11need to render the following section if
  5258. 4:31:14the comment doesn't
  5259. 4:31:16exist which will fix the error now we
  5260. 4:31:19refresh the
  5261. 4:31:20page the error is
  5262. 4:31:24gone let's wait the error is gone but
  5263. 4:31:26the comments are not rendered and after
  5264. 4:31:295 Seconds the comments will appear okay
  5265. 4:31:33but if selecting comments is heavy
  5266. 4:31:36operation which takes 5 Seconds let's
  5267. 4:31:39say so if we don't have this as deferred
  5268. 4:31:42prop the page rendering is delayed for 5
  5269. 4:31:46seconds so that's the significant
  5270. 4:31:48difference so if we select those
  5271. 4:31:50comments right here again let's turn
  5272. 4:31:52this out put them right here comments or
  5273. 4:31:56we can directly return them like this
  5274. 4:31:59and we just call sleep for 5 seconds
  5275. 4:32:02because selecting of the comments which
  5276. 4:32:04we we're doing right here takes 5
  5277. 4:32:06seconds I do have some semic clone is
  5278. 4:32:10extra so now if we refresh the page
  5279. 4:32:12we're going to see that rendering of
  5280. 4:32:14this page is actually delayed for 5
  5281. 4:32:17seconds because selecting comments takes
  5282. 4:32:18a lot of time so I'm I know I'm
  5283. 4:32:20repeating this many times but I just
  5284. 4:32:22want to make this very clear so let's
  5285. 4:32:24turn turn this into defer prop and which
  5286. 4:32:28makes the rendering of the page super
  5287. 4:32:31super nice and fast all right let's move
  5288. 4:32:34on the next one which is actually
  5289. 4:32:36prefetching one of my favorite things so
  5290. 4:32:39right now if we just open the dashboard
  5291. 4:32:42for example we have two pages like
  5292. 4:32:45features and users and both of them
  5293. 4:32:48actually have um like they are selecting
  5294. 4:32:52some data from the database right so I
  5295. 4:32:54just refreshed the dashboard page and
  5296. 4:32:56now if I click on features um it's
  5297. 4:33:00really fast let's click on users it's
  5298. 4:33:03not so fast uh let's do the
  5299. 4:33:06following uh we probably have some error
  5300. 4:33:09let's see
  5301. 4:33:11let's go on the
  5302. 4:33:15dashboard let's refresh the
  5303. 4:33:18page click on the features that makes
  5304. 4:33:21request it needs some time this is what
  5305. 4:33:23I'm going to do let's change this into
  5306. 4:33:26slow 4G for
  5307. 4:33:29example let's go into
  5308. 4:33:32dashboard refresh
  5309. 4:33:36it it's low 4G now let's click on
  5310. 4:33:39features and look at this so it is
  5311. 4:33:41loading and finally it got loaded okay
  5312. 4:33:45if the data is large if the uh SQL cure
  5313. 4:33:49is heavy then it's going to take more
  5314. 4:33:52time however in inera 2.0 there is one
  5315. 4:33:56cool thing which is called prefetching
  5316. 4:33:59so if we open authenticated
  5317. 4:34:03layout and if we find this features here
  5318. 4:34:08we see features link and we can simply
  5319. 4:34:11add one attribute which is called
  5320. 4:34:14prefetch and this prefetch means that
  5321. 4:34:18when we Mouse over on this features
  5322. 4:34:21navigation menu item it is going to
  5323. 4:34:23prefetch the content for us okay so
  5324. 4:34:26again I want to let's switch this into
  5325. 4:34:30no throttling to make this fast let's
  5326. 4:34:32remove this prefet and I'm going to make
  5327. 4:34:34the different significant uh we can
  5328. 4:34:37remove this sleep on the comments as
  5329. 4:34:39well but let's put this sleep right
  5330. 4:34:43here sleep right here directly when
  5331. 4:34:46rendering features okay now we refresh
  5332. 4:34:50the dashboard the dashboard Got Loaded
  5333. 4:34:53now I click on the
  5334. 4:34:55features and it should not be that fast
  5335. 4:34:58because we have that was show my bad we
  5336. 4:35:02should put this inside index cool let's
  5337. 4:35:06go into dashboard
  5338. 4:35:08again
  5339. 4:35:10and click on features now it is thinking
  5340. 4:35:14thinking thinking and after some time it
  5341. 4:35:18got loaded right so now let's reduce
  5342. 4:35:21this into like two seconds now if we go
  5343. 4:35:24into authenticated layout and add this
  5344. 4:35:27prefet here now this is what
  5345. 4:35:31happens when we Mouse over on the
  5346. 4:35:33features it is going to make request
  5347. 4:35:35look at the dev tools it's is going to
  5348. 4:35:36make request to fet those features and
  5349. 4:35:39once we click on it it's it's going to
  5350. 4:35:41instantly uh open that and so by Mouse
  5351. 4:35:46overing on this inertia thinks that we
  5352. 4:35:49want to load this and we can make this
  5353. 4:35:51even more optimal and inside prefet we
  5354. 4:35:54can provide um other options like
  5355. 4:35:57whether we want to prefetch on hover or
  5356. 4:36:01on Mount and so on so we can have a look
  5357. 4:36:04at the uh documentation these were on
  5358. 4:36:07the different props we can go back into
  5359. 4:36:09prefetching and we can find in the react
  5360. 4:36:12examples that we can provide the cash
  5361. 4:36:15duration it is going to also cach
  5362. 4:36:19those the prefetched pages for some time
  5363. 4:36:23and by default it's I think 30 seconds
  5364. 4:36:26but inside the prefetch we can provide
  5365. 4:36:28uh click or Mount or can we can even do
  5366. 4:36:31both so if we do these
  5367. 4:36:35both it means the following so again if
  5368. 4:36:38we open the dashboard
  5369. 4:36:41so when we open the dashboard it is
  5370. 4:36:43going to still make the request on the
  5371. 4:36:46features Now features are already loaded
  5372. 4:36:48even if I don't Mouse over on it once I
  5373. 4:36:51click on this the opening is instant and
  5374. 4:36:54that actually uh is cached for 30
  5375. 4:36:58seconds and on Mouse over it is also
  5376. 4:37:00fetching that information um and saving
  5377. 4:37:03that uh for next 30 seconds and that's
  5378. 4:37:07cool right now it uses the polling to
  5379. 4:37:08fetch that information actually so
  5380. 4:37:12now the features is going to open always
  5381. 4:37:15instantly and we can do something
  5382. 4:37:16similar on
  5383. 4:37:20users here we have this nav link and
  5384. 4:37:24let's add pref
  5385. 4:37:28patch and we can provide also on Mount
  5386. 4:37:32and hover but the users is something
  5387. 4:37:34which um you are not going to always
  5388. 4:37:37open so this is also a heavy thing so
  5389. 4:37:39you don't want to uh always load the
  5390. 4:37:43data if you don't think that user is
  5391. 4:37:45going to open that but in this case
  5392. 4:37:47features is the most important page of
  5393. 4:37:48the application that's why we prefetch
  5394. 4:37:51uh those features but not for the users
  5395. 4:37:53for the users we can just provide the
  5396. 4:37:55default one which is um on Hover let's
  5397. 4:37:59go in the features and remove this sleep
  5398. 4:38:01and now if I Mouse over on this actually
  5399. 4:38:04I Mouse
  5400. 4:38:07over okay now user is not loaded i m
  5401. 4:38:09over this it got loaded right click and
  5402. 4:38:12the uh open is actually very instant now
  5403. 4:38:15let's go into prefetch and right here
  5404. 4:38:18I'm going to implement something similar
  5405. 4:38:21for each feature so if I'm Mouse overing
  5406. 4:38:24for each feature it means that I want to
  5407. 4:38:26open that so let's go into feature item
  5408. 4:38:30we have
  5409. 4:38:31this H2 inside where is that H2 inside
  5410. 4:38:37which we have this link and let's add
  5411. 4:38:40prefetch pre
  5412. 4:38:42Fetch and now if I Mouse over on this
  5413. 4:38:46look at this so it made the request uh
  5414. 4:38:49prefetch the feature too I click on this
  5415. 4:38:51opening is instant so let's go back
  5416. 4:38:55let's hover on the other one prefetched
  5417. 4:38:58feature three click on this opening is
  5418. 4:39:01instant and just like this we are
  5419. 4:39:03increasing the user experience like uh
  5420. 4:39:06user is browsing the native application
  5421. 4:39:09where the data is saved on his own
  5422. 4:39:12computer so it's pretty fast and pretty
  5423. 4:39:15awesome functionality I recommend to
  5424. 4:39:17check the prefetching documentation we
  5425. 4:39:19have this programmatic prefetching where
  5426. 4:39:21we can prefetch on button click or on
  5427. 4:39:24some action and we also have additional
  5428. 4:39:26information when it was last prefetched
  5429. 4:39:29uh we can provide the cach duration as
  5430. 4:39:31well if it's prefetching right now if
  5431. 4:39:34it's prefetched and so on and we can
  5432. 4:39:37also Flash the prefet cache by through
  5433. 4:39:40the rotor flash all to flash all the pre
  5434. 4:39:43cach or um to flash a specific URL with
  5435. 4:39:48the method get and with some additional
  5436. 4:39:50data so as always I recommend to check
  5437. 4:39:53the documentation for this but I'm going
  5438. 4:39:55to leave these prefetching for features
  5439. 4:39:57uh for individual feature and we
  5440. 4:40:00probably need to do this for comments as
  5441. 4:40:02well so if I reload right
  5442. 4:40:06now and just have a look if I Mouse over
  5443. 4:40:10on this comments it is not going to
  5444. 4:40:11prefetch that particular feature so I I
  5445. 4:40:13click on this then it makes the request
  5446. 4:40:16and if the opening of that page is not
  5447. 4:40:18that fast then it's going to open
  5448. 4:40:21actually very slow so we can do
  5449. 4:40:23something similar if we search for
  5450. 4:40:27comments here we have that comments and
  5451. 4:40:29we can add
  5452. 4:40:30prefetch and we can also add something
  5453. 4:40:33in the um profile page so we can search
  5454. 4:40:37for profile this is the drop-down link
  5455. 4:40:41and and we can open this drop down link
  5456. 4:40:43from
  5457. 4:40:45here where's that
  5458. 4:40:49link here it is we can add
  5459. 4:40:52additional
  5460. 4:40:55refetch
  5461. 4:40:57here comma as a separate prop uh and now
  5462. 4:41:01this
  5463. 4:41:02one accepts prefetch so we add that not
  5464. 4:41:07for the log out but actually for
  5465. 4:41:10profile okay that was for the desktop
  5466. 4:41:13and I think we need to do something
  5467. 4:41:14similar for
  5468. 4:41:17responsive um does this responsive
  5469. 4:41:20support
  5470. 4:41:22prefetch prefetch okay we format this on
  5471. 4:41:25two
  5472. 4:41:27spaces
  5473. 4:41:29now here we are using
  5474. 4:41:33prefetch cool now if we refresh the
  5475. 4:41:38page then let's clear the network then I
  5476. 4:41:42open this drop down Mouse over on the
  5477. 4:41:45profile
  5478. 4:41:47uh okay why didn't
  5479. 4:41:53prefet uh I ex yeah I took the prefet
  5480. 4:41:56but I didn't add this here and probably
  5481. 4:42:00I have to do something for the other nav
  5482. 4:42:03link search for
  5483. 4:42:06link yeah I took the prefet but have to
  5484. 4:42:09add that here
  5485. 4:42:12fetch so yeah this happens on Mouse over
  5486. 4:42:15on Mouse over like you can add this
  5487. 4:42:18pretty much to every link because if you
  5488. 4:42:21Mouse over on something it's it has
  5489. 4:42:24quite high probability that I'm going to
  5490. 4:42:26click on that right so again I open this
  5491. 4:42:31I Mouse over on this profile was fetched
  5492. 4:42:33click on this and open is now instant
  5493. 4:42:37the next cool feature inside in version
  5494. 4:42:392.0 is uh laser loading data on scroll
  5495. 4:42:42and more specifically infinite scrolling
  5496. 4:42:45so right here we have this features and
  5497. 4:42:46we're displaying only 10 or 15 by
  5498. 4:42:50default and the idea is that when we
  5499. 4:42:52scroll more features should be actually
  5500. 4:42:55loaded however right now inertia 2.0 is
  5501. 4:42:58still in beta and inside the
  5502. 4:43:01documentation I couldn't find a best
  5503. 4:43:04example uh of using this load when
  5504. 4:43:07visible especially related to infinite
  5505. 4:43:10scroll L okay so there are some also
  5506. 4:43:14some articles regarding view I also
  5507. 4:43:16tested this on vuejs and it works
  5508. 4:43:19perfectly but on react it doesn't work
  5509. 4:43:23perfectly and it doesn't even work at
  5510. 4:43:26all the infinite scrolling I mean and I
  5511. 4:43:28can demonstrate this to you so first
  5512. 4:43:31we're going to open this feature
  5513. 4:43:33controller and we're going to change
  5514. 4:43:35these um this is the index we're going
  5515. 4:43:38to change this into uh the following way
  5516. 4:43:41so if we have a look in the
  5517. 4:43:42documentation we're going to change this
  5518. 4:43:43into mergeable props so if we go back
  5519. 4:43:47lazy load on
  5520. 4:43:49data let's search for merge U merging
  5521. 4:43:53props right here we see that so merging
  5522. 4:43:55props is does the following so whenever
  5523. 4:44:00we return something inside this inertia
  5524. 4:44:03merge the inertia will not replace the
  5525. 4:44:07results but it will append the results
  5526. 4:44:11okay so instead of returning this
  5527. 4:44:14paginated result uh of the collection
  5528. 4:44:17which has actually couple of other
  5529. 4:44:20fields other than features in fact we
  5530. 4:44:23can check this
  5531. 4:44:25inside uh the index that the features is
  5532. 4:44:31paginated data paginated data has data
  5533. 4:44:33and links and few other things but we
  5534. 4:44:35only declare data and links but what I
  5535. 4:44:38want that features to be plain array of
  5536. 4:44:41feature objects instead of paginated
  5537. 4:44:43data so this is what I'm going to do I'm
  5538. 4:44:45going to change these features to be
  5539. 4:44:48just array of feature now we need to go
  5540. 4:44:53uh let's scroll down below and the
  5541. 4:44:54iteration should be changed as well
  5542. 4:44:56instead of features data we should
  5543. 4:44:58iterate feature um actually let me
  5544. 4:45:02quickly undo these
  5545. 4:45:05things Okay cool so uh this this is
  5546. 4:45:08something um I mentioned does not work
  5547. 4:45:11in react so I probably have to undo
  5548. 4:45:14these things but I'm going to first make
  5549. 4:45:15comments so uh
  5550. 4:45:19Implement inertia version
  5551. 4:45:222.0 features let's comment
  5552. 4:45:26this and now let's redo the changes I
  5553. 4:45:29made so iterating over features now
  5554. 4:45:32let's open this feature controller and I
  5555. 4:45:34want to return not the paginated result
  5556. 4:45:38and which has data and links inside but
  5557. 4:45:40I want to actually access the collection
  5558. 4:45:43of it and then convert this into an
  5559. 4:45:47array so in the following way I'm just
  5560. 4:45:49returning features now let's save this
  5561. 4:45:52refresh the page feature page and that
  5562. 4:45:55should already work so if we check this
  5563. 4:45:59uh not this one or maybe this one as
  5564. 4:46:01well here we see the features and this
  5565. 4:46:03is now plain array it doesn't have data
  5566. 4:46:05and links inside now we're going to make
  5567. 4:46:08this mergeable so I'm going to going to
  5568. 4:46:11use inertia merge providing this
  5569. 4:46:15here awesome now it is not going to
  5570. 4:46:19change but now we have to implement this
  5571. 4:46:22load when visible and when we do this
  5572. 4:46:25the idea is the following that when we
  5573. 4:46:26hit the bottom area it is going to make
  5574. 4:46:29the request fetch the props and it's
  5575. 4:46:31going to merge it into existing one for
  5576. 4:46:34Simplicity right now I'm going to
  5577. 4:46:36comment out the polling at the moment so
  5578. 4:46:39the idea is the following that if scroll
  5579. 4:46:41down below uh here we are going to use
  5580. 4:46:45after these features we're going to use
  5581. 4:46:47when visible component which has
  5582. 4:46:50fallback and
  5583. 4:46:51data and whenever this is visible
  5584. 4:46:56whenever this gets visible so it's going
  5585. 4:46:58to start the loading so for
  5586. 4:47:01loading uh we are going to write some
  5587. 4:47:05text like loading so and this is one
  5588. 4:47:08thing that is different from the actual
  5589. 4:47:10document mation and from the
  5590. 4:47:11implementation so if we check the
  5591. 4:47:13documentation right
  5592. 4:47:15now so we are going to see inside load
  5593. 4:47:19when visible that the fallback is
  5594. 4:47:21actually a function which Returns the
  5595. 4:47:25jsx but if I make this function then we
  5596. 4:47:29have the typescript errors and if we
  5597. 4:47:32check this load when visible actually it
  5598. 4:47:36has these when visible props and the
  5599. 4:47:39fallback is actually react child it is
  5600. 4:47:42not function so I don't know what's
  5601. 4:47:46what's the thing maybe the documentation
  5602. 4:47:47is not updated um yeah we should
  5603. 4:47:50consider that right now at the moment
  5604. 4:47:52inertia version 2.0 is still in beta and
  5605. 4:47:55that's that's probably the reason but if
  5606. 4:47:58we have this as um react child this is
  5607. 4:48:01okay this is going to work now the next
  5608. 4:48:04thing is regarding this data so load
  5609. 4:48:07when visible is actually has different
  5610. 4:48:09purposes one of them is that whenever
  5611. 4:48:13this component is visible load the
  5612. 4:48:15following data okay which is not
  5613. 4:48:17necessarily connected to infinite
  5614. 4:48:19scrolling so in our specific case we can
  5615. 4:48:22do when this is visible load something
  5616. 4:48:25and that load something can be any prop
  5617. 4:48:28of the component right but we want to
  5618. 4:48:32implement infinite scrolling and this is
  5619. 4:48:34done in the following way which as I
  5620. 4:48:36mentioned works perfectly in vue.js so
  5621. 4:48:38we have to provide params here
  5622. 4:48:42and which the params actually should be
  5623. 4:48:44object okay and we have to provide some
  5624. 4:48:47data here and the data is what will be
  5625. 4:48:50sent to the server uh when this gets
  5626. 4:48:55visible so and because we're going to do
  5627. 4:48:58actually like load more type of thing
  5628. 4:49:01infinite scrolling we have to provide
  5629. 4:49:03page so page is current Page Plus one so
  5630. 4:49:07we actually want to load next page what
  5631. 4:49:10is this current page that's going to be
  5632. 4:49:12a prop right here page which actually
  5633. 4:49:18should be number uh page should be
  5634. 4:49:22number just like this and we should also
  5635. 4:49:26pass that page from feature
  5636. 4:49:28controller so here we're going to pass H
  5637. 4:49:32which needs to be paginated from from
  5638. 4:49:35this we need comma here so from this
  5639. 4:49:39paginated we need to get
  5640. 4:49:41current current
  5641. 4:49:44page okay let's go back into index T6
  5642. 4:49:48and we're going to pass this
  5643. 4:49:51data okay cool and we're going to also
  5644. 4:49:54pass some additional information like
  5645. 4:49:57we're going to pass um
  5646. 4:49:59preserve Reserve URL true so we don't
  5647. 4:50:04want the URL to be updated when we load
  5648. 4:50:07the second page or third page
  5649. 4:50:09information so with without this
  5650. 4:50:11preserve URL in the um true in the URL
  5651. 4:50:15we're going to see page two three and so
  5652. 4:50:17on so we format this and the next is
  5653. 4:50:20that we only want to retrieve the
  5654. 4:50:23information uh
  5655. 4:50:25regarding
  5656. 4:50:28features and
  5657. 4:50:32page now the react itself is complaining
  5658. 4:50:35that the when visible should actually
  5659. 4:50:37have children also and if we follow the
  5660. 4:50:40this we're going to see this right here
  5661. 4:50:42that it requires this uh children fall
  5662. 4:50:44back in data all of them are required
  5663. 4:50:47but those are actually optional but this
  5664. 4:50:49children is something what even has not
  5665. 4:50:52been mentioned inside here children
  5666. 4:50:56inside the documentation of inertial
  5667. 4:50:58version 2.0 so yeah again something is
  5668. 4:51:02kind of not finished regarding this when
  5669. 4:51:05visible on react but now let's have a
  5670. 4:51:07look and also I want to add one extra
  5671. 4:51:09thing always without always whenever the
  5672. 4:51:13browser hits and make this visible it's
  5673. 4:51:15going to load the data and it's going to
  5674. 4:51:17just finish it okay it's not going to do
  5675. 4:51:19this second time or third time but by
  5676. 4:51:21providing always here it is going to
  5677. 4:51:24always try to load the data when this
  5678. 4:51:27gets visible now I save this again we
  5679. 4:51:30have this error but it's still going to
  5680. 4:51:32work if we don't try to build
  5681. 4:51:35that and if we reload the page right now
  5682. 4:51:39let's refresh it
  5683. 4:51:42okay now if you scroll down below it is
  5684. 4:51:45going to load the second page
  5685. 4:51:46information and it actually loaded the
  5686. 4:51:49data but the problem is that if we hit
  5687. 4:51:51that when again it still is sending this
  5688. 4:51:54page to so it should actually increase
  5689. 4:51:58that page two and it should have that uh
  5690. 4:52:01page three page four and so on and it's
  5691. 4:52:03actually just fetching the same
  5692. 4:52:05information over and over again and the
  5693. 4:52:08exact same functionality as I mentioned
  5694. 4:52:10works perfectly in vue.js so that is
  5695. 4:52:13something not finished and if you open
  5696. 4:52:14this feature controller like I tried to
  5697. 4:52:16use inera merge here as well this can be
  5698. 4:52:20also Arrow function but that doesn't
  5699. 4:52:23change it at all we can just turn this
  5700. 4:52:26into Arrow function scroll up refresh
  5701. 4:52:30it so I tried many different
  5702. 4:52:32combinations of that scroll down below
  5703. 4:52:34it is still two and keep scrolling it is
  5704. 4:52:37always two we can again change this into
  5705. 4:52:40inertia merge again use Arrow function
  5706. 4:52:44here and return this paginated current
  5707. 4:52:47page scroll at the very
  5708. 4:52:50top refresh
  5709. 4:52:54it then scroll down below page two
  5710. 4:52:56scroll down below and it's again page
  5711. 4:52:58two page two page two so yeah this will
  5712. 4:53:01get probably fixed in the future and if
  5713. 4:53:03you're watching this in the future um
  5714. 4:53:06probably this is already fixed the
  5715. 4:53:08implementation might be different so I
  5716. 4:53:09recommend to the documentation and uh I
  5717. 4:53:12hope that this video still will be
  5718. 4:53:15helpful especially related to
  5719. 4:53:18this uh when visible now let's talk
  5720. 4:53:21about one of the most important part of
  5721. 4:53:23the fullstack developer and that is
  5722. 4:53:26deploying the project on production
  5723. 4:53:27environment assigning domain to it and
  5724. 4:53:30managing the server side things if you
  5725. 4:53:33grab the VPS with hostinger this is all
  5726. 4:53:35what we need and we probably need just
  5727. 4:53:38to purchase the domain or if you have
  5728. 4:53:39already existing domain or subdomain of
  5729. 4:53:42your domain you can always connect that
  5730. 4:53:45to your application so I previously I
  5731. 4:53:48was actually using a single domain and I
  5732. 4:53:50had different subdomains of this single
  5733. 4:53:52domain to deploy my particular projects
  5734. 4:53:55depending on your use case you can just
  5735. 4:53:57grab a new domain or use the subdomain
  5736. 4:53:59the main thing is that we're going to
  5737. 4:54:00grab the VPS server and you can get this
  5738. 4:54:03from the following place right now they
  5739. 4:54:05have amazing sales for Black Friday and
  5740. 4:54:09you you can just check this and grab it
  5741. 4:54:11so this is for the uh VPS and which
  5742. 4:54:15actually starts with the $2 per month um
  5743. 4:54:19but this is only when we get the four
  5744. 4:54:22year subscription okay so you can check
  5745. 4:54:25their uh the websites uh in terms of the
  5746. 4:54:28pricing and everything and they
  5747. 4:54:30obviously have different tiers as well
  5748. 4:54:33so when you grab the VPS then you're
  5749. 4:54:35going to have something like this the
  5750. 4:54:37VPS um hsg r. Cloud domain assigned to
  5751. 4:54:42it and uh this is what I'm going to set
  5752. 4:54:45up right now we're going to click on set
  5753. 4:54:48up to set up the VPS and we have to
  5754. 4:54:50choose the region where we want to
  5755. 4:54:52deploy this let me choose United States
  5756. 4:54:54click on continue and right here we have
  5757. 4:54:57three options plain o always with panel
  5758. 4:54:59and application and we're going to go
  5759. 4:55:01with the application scroll down below
  5760. 4:55:03and we're going to find this Lal version
  5761. 4:55:06into
  5762. 4:55:10want this click on continue then I have
  5763. 4:55:12to provide the panel password this is
  5764. 4:55:15the cloud panel which uh is a user
  5765. 4:55:18interface from which we can manage uh
  5766. 4:55:20many things regarding our server so I'm
  5767. 4:55:23going to provide some random password
  5768. 4:55:25which I'm going to actually um reset
  5769. 4:55:29later so this is the random password I'm
  5770. 4:55:31going to copy this and I'm going to
  5771. 4:55:32click on continue and I don't want to
  5772. 4:55:35lose this random password so I'm going
  5773. 4:55:37to open new scratch file and put this
  5774. 4:55:39right here
  5775. 4:55:40okay so next we have to provide the root
  5776. 4:55:43password and I'm going to actually
  5777. 4:55:44provide the same root password right
  5778. 4:55:47here that's good and we this is our host
  5779. 4:55:50name VPS host name using which we will
  5780. 4:55:52be able to access that in the browser
  5781. 4:55:54right now it probably doesn't show
  5782. 4:55:56anything and we can add the optional SSH
  5783. 4:55:59key if you know what is SSH key I
  5784. 4:56:01recommend to add this if you don't know
  5785. 4:56:04no worries we can always access this um
  5786. 4:56:07using username and password I just don't
  5787. 4:56:09want to make is very complicated but um
  5788. 4:56:12generally it's recommended to always
  5789. 4:56:14generate public private keys and add
  5790. 4:56:16your public SSH key right here so next
  5791. 4:56:20click on continue uh let me close this
  5792. 4:56:24and this is our overview and we're going
  5793. 4:56:25to click on finish setup which is going
  5794. 4:56:28to take several minutes so right here it
  5795. 4:56:32says that it's going to take up to 10
  5796. 4:56:34minutes but in like from my experience I
  5797. 4:56:37have uh created many servers on hosting
  5798. 4:56:40er uh weps servers and it actually takes
  5799. 4:56:44much less than 10 minutes so just wait
  5800. 4:56:47for a couple of seconds and you will
  5801. 4:56:49receive an email when the setup is
  5802. 4:56:53completed I just received an email that
  5803. 4:56:55the VPS setup has been completed and
  5804. 4:56:59right here we see this
  5805. 4:57:0033% and if I reload this it is going to
  5806. 4:57:04redirect us to the VPS page let's click
  5807. 4:57:07on
  5808. 4:57:08VPS and the IP address what we just set
  5809. 4:57:12up is this one so we can get the
  5810. 4:57:15actually let's click on manage and let's
  5811. 4:57:18refresh the domain also we're going to
  5812. 4:57:20see something yeah the domain is still
  5813. 4:57:23in the setting up process so the VPS is
  5814. 4:57:26done but the domain is in the setting up
  5815. 4:57:28process so what we want is to access
  5816. 4:57:31that um through
  5817. 4:57:34SSH uh here we also see this Pro you w't
  5818. 4:57:37be able to meure well okay so I an email
  5819. 4:57:40is very strange I received an email my
  5820. 4:57:43VPS is using Bo to let's try to access
  5821. 4:57:46on
  5822. 4:57:47SSH and for this I'm going to use um we
  5823. 4:57:52can use Powershell or gitbash I
  5824. 4:57:55generally prefer to use G bash so I'm
  5825. 4:57:57going to open that let's zoom in SSH
  5826. 4:58:01root at we have to provide the IP
  5827. 4:58:05address uh we have to type yes here and
  5828. 4:58:09then we have to provide the root
  5829. 4:58:10password and this is the password what
  5830. 4:58:13we assigned to it click on paste hit the
  5831. 4:58:16enter and we we are able to access to
  5832. 4:58:19the server and
  5833. 4:58:23now let's see what folders and files we
  5834. 4:58:27have in home so inside home we have
  5835. 4:58:30Ubuntu and user that user is the user
  5836. 4:58:34inside which the default LL installation
  5837. 4:58:38will be so we need to authenticate as
  5838. 4:58:41the user and make some changes in the
  5839. 4:58:44project so I'm going to use Sue Das
  5840. 4:58:48user and right now I am authenticated as
  5841. 4:58:51user previously I was
  5842. 4:58:54root so if we now navigate inside HG
  5843. 4:58:57docs this is the place where the project
  5844. 4:58:59is installed and if we type LS we're
  5845. 4:59:02going to see the following domain and
  5846. 4:59:04this is actually a folder so inside that
  5847. 4:59:07folder we have the Lal installation
  5848. 4:59:10and this is the default lateral
  5849. 4:59:12installation which comes with our
  5850. 4:59:14project but this is what we are going to
  5851. 4:59:16do I'm going to actually uh delete
  5852. 4:59:20everything from the following folder
  5853. 4:59:22actually we need to navigate inside
  5854. 4:59:24there and let me delete everything or
  5855. 4:59:26maybe we can just make sure that it
  5856. 4:59:28works first no the domain is still in
  5857. 4:59:32the setting up process if you want you
  5858. 4:59:34can wait this for few more minutes and
  5859. 4:59:37the domain will got activated and then
  5860. 4:59:41when you refresh you're going to see
  5861. 4:59:42latest installed LEL version but I want
  5862. 4:59:46to see my LEL project inside there so
  5863. 4:59:51I'm going to copy now uh my GitHub
  5864. 4:59:55project URL here is my project
  5865. 4:59:57repository which is a private repository
  5866. 5:00:00so if it's public things are a little
  5867. 5:00:01bit easy you can directly clone that
  5868. 5:00:04into the VPS server but because this is
  5869. 5:00:07private repository we have to generate
  5870. 5:00:09public private keys on the server add
  5871. 5:00:12public key on this repository so that
  5872. 5:00:15the server has permission to access to
  5873. 5:00:18the GitHub server and clone that
  5874. 5:00:21repository okay so this is what we're
  5875. 5:00:24going to do let's go into the server and
  5876. 5:00:29before I delete everything in the
  5877. 5:00:31following folder let me actually
  5878. 5:00:33generate public private Keys you can
  5879. 5:00:36just
  5880. 5:00:37Google SSH key
  5881. 5:00:40generate and the very first thing is
  5882. 5:00:43going to be probably what we need if we
  5883. 5:00:45scroll down below generate new SSH key
  5884. 5:00:48and this is the commment we're going to
  5885. 5:00:50execute on the server I'm going to copy
  5886. 5:00:52this go to the server paste that and
  5887. 5:00:55we're going to change the email that's
  5888. 5:00:58actually um identifier of your SSH key
  5889. 5:01:02but very common thing is just to provide
  5890. 5:01:05our email address so here is my email
  5891. 5:01:09address let's hit the enter now this is
  5892. 5:01:12the default location where the public
  5893. 5:01:14private keys will be generated under
  5894. 5:01:16home user SS folder we're going to hit
  5895. 5:01:19enter as for the passphrase I'm going to
  5896. 5:01:22leave this empty so hit the
  5897. 5:01:24enter hit the enter again and the key
  5898. 5:01:27was generated and that is now located
  5899. 5:01:30under SSH folder in my home directory so
  5900. 5:01:33using cut command I can access this SSH
  5901. 5:01:37folder ID Ed whatever do pbpb is the
  5902. 5:01:43public file without PB it's a private
  5903. 5:01:46file so we're going to open this pub
  5904. 5:01:48file and this is actually the uh public
  5905. 5:01:53key so we're going to copy that and we
  5906. 5:01:56are going to open our repository go into
  5907. 5:02:00settings scroll down below and we need
  5908. 5:02:03deploy keys and add deploy key so we're
  5909. 5:02:07going to paste this and we can provide
  5910. 5:02:09this
  5911. 5:02:10hostinger VPS server as a title you can
  5912. 5:02:14name it whatever you want and we can
  5913. 5:02:16also give it optionally write access so
  5914. 5:02:18that VPS server will be able to push
  5915. 5:02:21something on the following
  5916. 5:02:24repository okay I have to approve this
  5917. 5:02:27using my two Factor authentication
  5918. 5:02:30through GitHub
  5919. 5:02:31[Music]
  5920. 5:02:34mobile okay it didn't work sometimes it
  5921. 5:02:36doesn't work so let me provide my
  5922. 5:02:38password
  5923. 5:02:40okay here we go so we added this deploy
  5924. 5:02:43key and now that server is actually able
  5925. 5:02:47to clone the repository uh right here on
  5926. 5:02:50the following folder now let's check
  5927. 5:02:52this one last time if it was set up no
  5928. 5:02:54this is still in the progress no problem
  5929. 5:02:56let's delete everything from the
  5930. 5:02:58following folder rm-rf or maybe we can
  5931. 5:03:02just move everything into another folder
  5932. 5:03:05so here we have just one folder let me
  5933. 5:03:08copy the name of that
  5934. 5:03:11and we're going to move everything into
  5935. 5:03:14a different folder called TMP okay and
  5936. 5:03:17then I'm going to execute git clone here
  5937. 5:03:20I have to provide the repository name
  5938. 5:03:23and then I'm going to provide it right
  5939. 5:03:26now and then I have to provide the local
  5940. 5:03:28folder name inside which I want to clone
  5941. 5:03:31the repository and the local folder name
  5942. 5:03:34is going to be that this server name
  5943. 5:03:37this one okay now let's get the
  5944. 5:03:40repository URL to clone it locally and
  5945. 5:03:43we're going to use SSH URL copy that and
  5946. 5:03:47we have to provide it here so clone the
  5947. 5:03:52following repository in the following
  5948. 5:03:54folder finally let's hit the enter we
  5949. 5:03:57have to type yes here and look at this
  5950. 5:04:00so it was cloned and now we see the
  5951. 5:04:04following folder this is the old project
  5952. 5:04:06which comes with a VPS and this is what
  5953. 5:04:09we cloned now let's navigate into this
  5954. 5:04:13SRV and first let's copy en example
  5955. 5:04:19into and then we need to execute
  5956. 5:04:21composer
  5957. 5:04:23install now it went ahead and install
  5958. 5:04:27all the packages that was actually done
  5959. 5:04:30now let's execute PHP Artisan migrate by
  5960. 5:04:34default this is using SQ light and we
  5961. 5:04:37can leave this or we can switch it into
  5962. 5:04:39my ql uh if you want so I'm just going
  5963. 5:04:42to type yes migrations have been applied
  5964. 5:04:46let's check this in the browser it is
  5965. 5:04:48still in the finishing and we have to
  5966. 5:04:51unfortunately wait for this or we can
  5967. 5:04:53check this in the Incognito and have a
  5968. 5:04:55look no we have to wait for
  5969. 5:04:58that meanwhile we can try to access
  5970. 5:05:02panel through the following uh URL so we
  5971. 5:05:06just click this because we don't have
  5972. 5:05:08the domain assigned to it so it tells us
  5973. 5:05:11the connection is not private we just
  5974. 5:05:13click to Advanced we're going to
  5975. 5:05:15proceed and we have to provide admin and
  5976. 5:05:19the password what we gave to it now we
  5977. 5:05:23click on login and we are on the server
  5978. 5:05:25let me switch to dark mode and here we
  5979. 5:05:27have just one site and this is our site
  5980. 5:05:30we can obviously add more sites if we
  5981. 5:05:33need so if we click on that then we have
  5982. 5:05:36a lot of options so we have the uh
  5983. 5:05:39domain related settings and the path
  5984. 5:05:41where the project installed user related
  5985. 5:05:44settings PHP related settings I'm going
  5986. 5:05:46to switch into PHP
  5987. 5:05:488.3 and from here you can control the
  5988. 5:05:52most common things let's click on Save
  5989. 5:05:55uh we have the virtual host related
  5990. 5:05:57thing here we have this domain and SSL
  5991. 5:06:00certificate path and this is engin
  5992. 5:06:03config we have the database section
  5993. 5:06:05which is something we need to work on
  5994. 5:06:08I'm going to click on database and you
  5995. 5:06:10can call this whatever you want I'm
  5996. 5:06:11going to call this just test database
  5997. 5:06:13username test and this is the user
  5998. 5:06:17password I'm going to copy this add
  5999. 5:06:19database the database has been created
  6000. 5:06:23now we can open Terminal our VPS server
  6001. 5:06:26and we can type Vim or do we have Nano
  6002. 5:06:30Nano is easier to use Nano that's it so
  6003. 5:06:34here we have this application name this
  6004. 5:06:36is our enan now let's scroll down below
  6005. 5:06:39and find the database related things
  6006. 5:06:43here we have the DB connection and we
  6007. 5:06:44can change this into MySQL so now let's
  6008. 5:06:48uncomment the host Port database
  6009. 5:06:51username and password and the
  6010. 5:06:54database is test the username is test
  6011. 5:06:59the password is what we what we copied
  6012. 5:07:04but I lost that for some reason so I
  6013. 5:07:08have to delete that
  6014. 5:07:10database user has been deleted let's
  6015. 5:07:12delete the database as well and a new
  6016. 5:07:16database let's give it test
  6017. 5:07:19test get that a
  6018. 5:07:23database now let's paste
  6019. 5:07:26here and the port and the host is
  6020. 5:07:28actually the default one so we're going
  6021. 5:07:30to leave this now hit contrl and O enter
  6022. 5:07:34contrl and X we we have to reexecute
  6023. 5:07:37migrations so
  6024. 5:07:40PHP
  6025. 5:07:41Artisan Artisan migrate hit the enter
  6026. 5:07:45now the migrations have been applied in
  6027. 5:07:47the myql
  6028. 5:07:48database and now let's check the domain
  6029. 5:07:51again it is still not working so what do
  6030. 5:07:55we have in this Cloud panel we have this
  6031. 5:07:57varnish cache we have this TLS and SSL
  6032. 5:08:00and we see that the following
  6033. 5:08:04domain it is actually not installed so
  6034. 5:08:08let's click on install
  6035. 5:08:10certificate has been installed so this
  6036. 5:08:12is self signed certificate which has one
  6037. 5:08:15year okay
  6038. 5:08:19now okay after some time I installed let
  6039. 5:08:23encrypt certificate back and now I'm
  6040. 5:08:26going to um if it's if it's not possible
  6041. 5:08:29to delete the self-signed I'm going to
  6042. 5:08:32just leave that but the application
  6043. 5:08:33actually started working so we don't
  6044. 5:08:36just don't have this encryption key uh
  6045. 5:08:38specified so we're going to execute PHP
  6046. 5:08:41Artisan uh key generate
  6047. 5:08:45d-i hit the enter application key set
  6048. 5:08:48successfully and if we refresh this now
  6049. 5:08:51we see the following error which is very
  6050. 5:08:53common we don't have the V config file
  6051. 5:08:56and we have two options one we have to
  6052. 5:08:58execute npm run Dev which is generally
  6053. 5:09:00recommended for locally or we have to
  6054. 5:09:03execute mpm run build which is for
  6055. 5:09:05production and which is what we are
  6056. 5:09:07going to do however we don't have mpm
  6057. 5:09:11command installed on this VPS server and
  6058. 5:09:14this is what we are going to do next
  6059. 5:09:17let's open nodejs.org
  6060. 5:09:21download let's actually access the main
  6061. 5:09:23page click on download and then in the
  6062. 5:09:26package manager we are going to click on
  6063. 5:09:28The Following last link package
  6064. 5:09:37managers and what I'm meing interested
  6065. 5:09:40is Debian and Ubunto based Linux
  6066. 5:09:45distributions and we're going to click
  6067. 5:09:47on this this is going to open the GitHub
  6068. 5:09:49link no Source SL distributions and if
  6069. 5:09:53we scroll down below we're going to find
  6070. 5:09:55this Ubuntu
  6071. 5:09:57versions and here we have that so
  6072. 5:09:59depending on which version we want to
  6073. 5:10:02install just check it the LTS version is
  6074. 5:10:05right now 22 so under node.js 22
  6075. 5:10:09I'm going to execute the following code
  6076. 5:10:13first we're going to install
  6077. 5:10:15curl I'm going to paste this hit the
  6078. 5:10:18enter we have to provide the root
  6079. 5:10:21password which I have right here so I'm
  6080. 5:10:24going to paste hit the
  6081. 5:10:27enter uh my bad right now we are
  6082. 5:10:29authenticated as a user but we want to
  6083. 5:10:32install nodejs we must install node.js
  6084. 5:10:35as root user so I'm going to type exit
  6085. 5:10:38now I'm auth indicated as root user and
  6086. 5:10:41I'm going to
  6087. 5:10:43execute the following
  6088. 5:10:46command paste hit the enter okay that
  6089. 5:10:51was completed crl was actually already
  6090. 5:10:53installed now let's execute the second
  6091. 5:10:58command that has been completed as well
  6092. 5:11:02now let's
  6093. 5:11:04follow to read me
  6094. 5:11:09so we have copied and executed this and
  6095. 5:11:12the first the last one is to install the
  6096. 5:11:15node js so I'm going to copy
  6097. 5:11:19this and as soon as this is completed we
  6098. 5:11:22are going to paste the sud sudo op get
  6099. 5:11:25install Dy
  6100. 5:11:29nodejs okay so this has been completed
  6101. 5:11:31we can type node DV we see version 22
  6102. 5:11:35and we can type mpmv and we see this as
  6103. 5:11:38well now now we need to authenticate
  6104. 5:11:41back as user so
  6105. 5:11:43su- user now let's go into HD do folder
  6106. 5:11:48and
  6107. 5:11:49SRV uh whatever is the domain name so
  6108. 5:11:53right here we need to execute mpm
  6109. 5:11:57install and then mpm run
  6110. 5:12:01build now this is building typescript V
  6111. 5:12:04build and V build uh with SSR and right
  6112. 5:12:08here we have the following error and we
  6113. 5:12:11have to fix this error locally push it
  6114. 5:12:13and then we have to pull on the server
  6115. 5:12:16so let's close this and reexecute mpm
  6116. 5:12:19run build on a local environment and see
  6117. 5:12:23if we have the same error we do have the
  6118. 5:12:26same error and which is coming from
  6119. 5:12:28property rows is missing in type ID
  6120. 5:12:32class name value and so on so we're
  6121. 5:12:35going to open html text area let's open
  6122. 5:12:38this
  6123. 5:12:41uh
  6124. 5:12:43create then we have here this text area
  6125. 5:12:47and the rose
  6126. 5:12:49row is missing right here it seems
  6127. 5:13:00like Okay so let's just provide rules
  6128. 5:13:04equals
  6129. 5:13:06six we save that
  6130. 5:13:09um then we execute mpm run
  6131. 5:13:14build so that if that builds we don't
  6132. 5:13:18have any more
  6133. 5:13:19errors now we have to comit
  6134. 5:13:22this fix using text
  6135. 5:13:29area we have to push
  6136. 5:13:32that then we have to open the VPS server
  6137. 5:13:37and we have to execute G pool
  6138. 5:13:40to grab the changes what we just made
  6139. 5:13:43and then we execute mpm run
  6140. 5:13:46build let me clear this up mpm run build
  6141. 5:13:51we hit the enter now it's going to
  6142. 5:13:55build
  6143. 5:13:59everything and finally we can check the
  6144. 5:14:01result in the
  6145. 5:14:03browser and we have the application up
  6146. 5:14:05and running so we have to probably
  6147. 5:14:08execute migrations with seed command PHP
  6148. 5:14:12Artisan
  6149. 5:14:14migrate D-
  6150. 5:14:17seed uh actually let's provide
  6151. 5:14:21migrate fres d d
  6152. 5:14:25seed okay now refresh the database and
  6153. 5:14:28let's try to log in with admin
  6154. 5:14:31example.com provide the password and
  6155. 5:14:35here we go so we are authenticated as
  6156. 5:14:37admin user we can click on features we
  6157. 5:14:39see that this is actually super fast
  6158. 5:14:42very smooth uh we have the prefetching
  6159. 5:14:44as well it's like immediate a thing so
  6160. 5:14:48we can click on this one it's going to
  6161. 5:14:50open scroll down below leave a
  6162. 5:14:55comment we can see the comment right
  6163. 5:14:57here another
  6164. 5:15:01comment okay now we can up vote this
  6165. 5:15:04down vote this so this is awesome now
  6166. 5:15:09let's talk about server side rendering
  6167. 5:15:11so far we have single page application
  6168. 5:15:14everything is working everything seems
  6169. 5:15:16to be good but the whole idea of the
  6170. 5:15:18server side rendering is that the actual
  6171. 5:15:21content is rendered on the server side
  6172. 5:15:23so we have different server uh inertia
  6173. 5:15:26server running node.js server which
  6174. 5:15:28renders the react components on the
  6175. 5:15:31server s side and serves that and we are
  6176. 5:15:33going to have much better ACO
  6177. 5:15:36capabilities on our website or or in any
  6178. 5:15:39project basically where we are going to
  6179. 5:15:41use this react with server side
  6180. 5:15:43rendering right now if we check check
  6181. 5:15:46the page Source let's grab the title or
  6182. 5:15:51part of the title and if we search this
  6183. 5:15:53on the page we're going to see that this
  6184. 5:15:55is used only once and this is the
  6185. 5:15:59entire uh large JavaScript object which
  6186. 5:16:04is bound to that page okay so the only
  6187. 5:16:08place where that title is mentioned is
  6188. 5:16:10that JavaScript part which is bound to
  6189. 5:16:13the component this is not right now
  6190. 5:16:16serers side rendered content to make
  6191. 5:16:18this server side rendered content from
  6192. 5:16:21inside our folder basically we're going
  6193. 5:16:24to execute PHP Artisan
  6194. 5:16:28inertia start SSR this is going to start
  6195. 5:16:31server side rendering server on the
  6196. 5:16:34following Port but the port doesn't
  6197. 5:16:36matter uh the main thing is that if we
  6198. 5:16:39right now refresh that so the content
  6199. 5:16:42right now is served from the server and
  6200. 5:16:44it's again very fast and if we open this
  6201. 5:16:48on the page source and if we search the
  6202. 5:16:50same title actually this is the title
  6203. 5:16:54now we see that it is used in four
  6204. 5:16:56places now this is the place where it
  6205. 5:16:59was used previously but additionally we
  6206. 5:17:02have now this already rendered inside B
  6207. 5:17:05tag inside
  6208. 5:17:07H2 so let me use the horizontal scroll
  6209. 5:17:11we see that feature inside B tag we have
  6210. 5:17:15that information additionally we have
  6211. 5:17:18that inside h2 tag so we have that
  6212. 5:17:23here check this
  6213. 5:17:26here
  6214. 5:17:27here additionally it is inside the title
  6215. 5:17:31tag of the browser so here if we Mouse
  6216. 5:17:35over on the
  6217. 5:17:36title we're going to see that here is as
  6218. 5:17:39well and then the last one is inside
  6219. 5:17:41that uh JavaScript object and just like
  6220. 5:17:44this we have now this server side
  6221. 5:17:46rendered however that is not enough so
  6222. 5:17:48we just started this manually but we
  6223. 5:17:51want this to be automatically started
  6224. 5:17:53and supervised as well for this we're
  6225. 5:17:56going to set up the supervisor so let's
  6226. 5:17:58open
  6227. 5:18:00laravel
  6228. 5:18:02supervisor and we have this probably
  6229. 5:18:05inside cues and if we search for super
  6230. 5:18:08visor
  6231. 5:18:09configuration this is what we are going
  6232. 5:18:12to do but this example is for cues we're
  6233. 5:18:16going to change this into our um command
  6234. 5:18:19which is inertia start SSR let's close
  6235. 5:18:23this and let me copy the following
  6236. 5:18:25common to install the supervisor paste
  6237. 5:18:29actually we have to we are again user
  6238. 5:18:33but we have to exit to be root now we
  6239. 5:18:36are root paste the following Comm
  6240. 5:18:40command paste copy paste hit the enter
  6241. 5:18:45supervisor will be installed let's
  6242. 5:18:47scroll down below and then we have to do
  6243. 5:18:50the following configuration so we have
  6244. 5:18:52to create new file on the following
  6245. 5:18:54directory we can call this whatever we
  6246. 5:18:56want just make sure that it has this
  6247. 5:18:58conf extension okay so the supervisor
  6248. 5:19:02got installed let's
  6249. 5:19:04again now login as user go to HT
  6250. 5:19:09docks uh or first we have to do this as
  6251. 5:19:13root user my bad let's exit
  6252. 5:19:16again so let's navigate into the
  6253. 5:19:18following folder so
  6254. 5:19:20CD supervisor comt in here we don't have
  6255. 5:19:25any files at the moment and we have to
  6256. 5:19:27create new file and we have to copy the
  6257. 5:19:29following common to put that inside the
  6258. 5:19:33file let's define the file and call
  6259. 5:19:36these um
  6260. 5:19:40LEL serid rendering
  6261. 5:19:44docon the extension should be Doc let's
  6262. 5:19:47hit the enter now I'm going to paste the
  6263. 5:19:50following command and we have to modify
  6264. 5:19:53a few things so the program is the name
  6265. 5:19:55and let's call this laravel
  6266. 5:19:59SSR SSR and square
  6267. 5:20:02bracket then we are going to leave the
  6268. 5:20:04process name which is the program name
  6269. 5:20:08um then in so right here we have to
  6270. 5:20:11adjust the path the path is where our
  6271. 5:20:14application is installed so this is
  6272. 5:20:17inside
  6273. 5:20:18home
  6274. 5:20:20user
  6275. 5:20:22slht dox and then we have to use this
  6276. 5:20:26domain name so we can get that
  6277. 5:20:28information from the cloud panel as well
  6278. 5:20:32inside um that was inside V hosts
  6279. 5:20:35probably or right here so that is the
  6280. 5:20:39path where the application is also
  6281. 5:20:43installed and then we can actually
  6282. 5:20:46delete this
  6283. 5:20:48completely paste that and then inside
  6284. 5:20:50that project we have Artisan
  6285. 5:20:54comment next there's this Q worker
  6286. 5:20:57example which we don't need we just need
  6287. 5:20:59inertia start so we provide
  6288. 5:21:03inertia
  6289. 5:21:05inera colum start
  6290. 5:21:09D SSR this is the command we started
  6291. 5:21:12manually so we have to provide auto
  6292. 5:21:14start Auto restart stop his group stop
  6293. 5:21:18okay we can leave everything for the
  6294. 5:21:20user we're going to provide user number
  6295. 5:21:23of processes we can set this to one and
  6296. 5:21:27we have to provide also the log file
  6297. 5:21:29where all logs is going to be saved and
  6298. 5:21:32let's do the
  6299. 5:21:35following I'm going to paste
  6300. 5:21:40the
  6301. 5:21:44path home user HT docs the path and
  6302. 5:21:49inside here or maybe outside here inside
  6303. 5:21:52HT docs we can give it the following
  6304. 5:21:56name let's copy the domain
  6305. 5:21:59name paste. log okay now we're going to
  6306. 5:22:04save that I used VM so I have to type
  6307. 5:22:06escape on the keyboard then colon then W
  6308. 5:22:10and Q on the keyboard hit the enter that
  6309. 5:22:13was saved you can also use Nano to um
  6310. 5:22:18create the same
  6311. 5:22:19file okay now we have that file saved
  6312. 5:22:22and if we check the
  6313. 5:22:24documentation we have to reread this new
  6314. 5:22:29file so we have to execute the following
  6315. 5:22:31commment hit the enter that was
  6316. 5:22:35available now the second common
  6317. 5:22:39that was
  6318. 5:22:42added and instead of Lal worker we have
  6319. 5:22:46to give it name laral SSR we hit the
  6320. 5:22:51enter uh I believe that was already
  6321. 5:22:54started and now if we check the page
  6322. 5:22:56Source refresh
  6323. 5:23:00that now we see that this is used in
  6324. 5:23:03four places so the server side rendering
  6325. 5:23:07is active running and even if we restart
  6326. 5:23:11the server it is going to start
  6327. 5:23:12automatically and it's going to server
  6328. 5:23:14side render the content and the
  6329. 5:23:19pages here we have the um like I don't
  6330. 5:23:23see the common to actually stop a
  6331. 5:23:27supervisor but probably in the similar
  6332. 5:23:30way we executed start Lal SSR we can
  6333. 5:23:34execute stop Lal SSR we hit the enter
  6334. 5:23:39that was stopped and now if we check the
  6335. 5:23:41page
  6336. 5:23:42Source now we see this only once server
  6337. 5:23:45side rendering is off so we have to
  6338. 5:23:49execute start again server side
  6339. 5:23:52rendering is started and we have that
  6340. 5:23:56title used in four places that's
  6341. 5:24:01awesome and we can navigate on the
  6342. 5:24:03website and we see that this is super
  6343. 5:24:05fast it's it's it's using the uh rebuild
  6344. 5:24:09um react components we can edit that
  6345. 5:24:13user try to give it another role click
  6346. 5:24:16on save that got updated and we got
  6347. 5:24:19actually great user experience in the uh
  6348. 5:24:24in the
  6349. 5:24:26browser now let's try to assign custom
  6350. 5:24:29domain to that so in the hosting or AG
  6351. 5:24:33panel you can go to domain section you
  6352. 5:24:35can always get the new domain from here
  6353. 5:24:38you just type your domain name choose
  6354. 5:24:40the extension you want you can search if
  6355. 5:24:42it's available or not and you can get
  6356. 5:24:44the domain for as low as $1 or $2 and I
  6357. 5:24:49have used actually that so in my
  6358. 5:24:52specific case I actually have one of the
  6359. 5:24:55existing uh domains free domains
  6360. 5:24:57available so I'm going to click on claim
  6361. 5:25:00domain uh but the flow whether you're
  6362. 5:25:03going to purchase the domain or just get
  6363. 5:25:05the claim domain uh what I have right
  6364. 5:25:07now doesn't change so I'm going to use
  6365. 5:25:10domain like larar rea.com check the
  6366. 5:25:14availability that is available awesome
  6367. 5:25:17let's click on claim
  6368. 5:25:19domain and I have the domain right here
  6369. 5:25:23so this is my personal contact details
  6370. 5:25:26which generally uh you have to feel if
  6371. 5:25:31you're purchasing the domain very first
  6372. 5:25:33time in hostinger so this is going to be
  6373. 5:25:35blurred out because um I don't want to
  6374. 5:25:37reveal my personal information regarding
  6375. 5:25:39the phone number or anything so but you
  6376. 5:25:42have to feel this information if you're
  6377. 5:25:44purchasing the domain very first time
  6378. 5:25:46then we're going to click on this finish
  6379. 5:25:47registration it is registering the
  6380. 5:25:50domain once it is done we have to
  6381. 5:25:53connect the domain to the VPS
  6382. 5:25:56server it's going to take a few seconds
  6383. 5:25:58okay the domain is ready let's click on
  6384. 5:26:03continue uh even when it is ready it
  6385. 5:26:06might take few seconds meaning
  6386. 5:26:09need uh let's check my
  6387. 5:26:12domains
  6388. 5:26:14Lara Lara react okay that looks like to
  6389. 5:26:18be active let's click on the
  6390. 5:26:22domain Okay order not
  6391. 5:26:25found it might take
  6392. 5:26:29few minutes until the domain actually
  6393. 5:26:31gets fully activated so let's click on L
  6394. 5:26:35react again now we have this domain over
  6395. 5:26:38view we're going to click on this DNS
  6396. 5:26:40and name servers and we have to adjust
  6397. 5:26:44that domain actually if we copy the
  6398. 5:26:47domain L react let's open this in the
  6399. 5:26:50browser Lara rea.com
  6400. 5:26:55yeah we have this SSL Error which is
  6401. 5:26:58okay not a big deal uh but we have to
  6402. 5:27:01associate now the VPS server um IP
  6403. 5:27:05address to that domain okay let's go
  6404. 5:27:09back into home into
  6405. 5:27:12VPS
  6406. 5:27:14and I think this is the one what we just
  6407. 5:27:17set up we're going to copy the IP
  6408. 5:27:19address and go into domain
  6409. 5:27:22portfolio we have to find the domain
  6410. 5:27:25what we just
  6411. 5:27:28purchased L react click on
  6412. 5:27:31manage uh click on DNS and name
  6413. 5:27:35servers
  6414. 5:27:36and right here we have the following a
  6415. 5:27:39record which we have to remove but again
  6416. 5:27:42we can check this before remove just to
  6417. 5:27:45make sure that um it is finally
  6418. 5:27:48available that's it it's available and
  6419. 5:27:50it is uh pointing to the following
  6420. 5:27:53server which we have to remove so we are
  6421. 5:27:56removing this a record and we are going
  6422. 5:27:59to add new a record that domain points
  6423. 5:28:02to the following IP address and that IP
  6424. 5:28:05address is our VPS server IP address DNS
  6425. 5:28:10record created successfully awesome next
  6426. 5:28:13we're going to open the VPS
  6427. 5:28:16server what we just created click on
  6428. 5:28:20manage then I'm going to go into DNS
  6429. 5:28:22manager and right here we have to assign
  6430. 5:28:24the domain to that VPS server let's give
  6431. 5:28:27it Lara rea.com let's click on
  6432. 5:28:33add the domain was detected that it's in
  6433. 5:28:36my account and that we can that that was
  6434. 5:28:39actually added we can go into domain
  6435. 5:28:42dashboard and from here we can manage
  6436. 5:28:44the specific domain not renew but manage
  6437. 5:28:47in terms of the DNS things what we have
  6438. 5:28:49already done so we have cname www which
  6439. 5:28:52is for this lar rea.com and we have this
  6440. 5:28:57um the root domain which points to the
  6441. 5:29:00following IP address next let's go into
  6442. 5:29:03vhost file and we're going to add our
  6443. 5:29:06new domain into the server name name so
  6444. 5:29:09this is lar rea.com and we can also add
  6445. 5:29:14www Lara rea.com we're going to copy
  6446. 5:29:18both of them and there are second usage
  6447. 5:29:22this is for Port at which is without
  6448. 5:29:25SSL um if we scroll down below actually
  6449. 5:29:29so this is for p port at and with SSL as
  6450. 5:29:33well um but if we scroll down below here
  6451. 5:29:35we have the server name used in the
  6452. 5:29:37second place place and we have to add
  6453. 5:29:39this L rea.com with the www as well now
  6454. 5:29:43let's click on Save which is going to to
  6455. 5:29:47the vhost has been so that that's going
  6456. 5:29:49to do the reload of the vhost and now if
  6457. 5:29:52we go into SSL TLS click on new let's
  6458. 5:29:56encrypt certificate and then add domain
  6459. 5:30:00L rea.com click on Create and install
  6460. 5:30:05Okay certificate has been installed and
  6461. 5:30:08now let's open lara.com and we see our
  6462. 5:30:12application up and running on SSL so we
  6463. 5:30:16can authenticate now admin at
  6464. 5:30:18example.com we can provide some
  6465. 5:30:21password okay and we are actually
  6466. 5:30:24authenticated we can navigate on our
  6467. 5:30:27custom domain so because we assigned no
  6468. 5:30:30custom domain to the application we have
  6469. 5:30:33to change the en file as well I was
  6470. 5:30:36actually logged out from the SSH session
  6471. 5:30:39so we have to relog in SSH root at and
  6472. 5:30:43right here instead of IP address right
  6473. 5:30:45now we can provide the domain L rea.com
  6474. 5:30:48we hit the enter we have to we have to
  6475. 5:30:51first type yes here to accept the
  6476. 5:30:53fingerprint and then we're going to copy
  6477. 5:30:56the root password provide it here hit
  6478. 5:31:00the enter we have an authenticated on
  6479. 5:31:02the server let's now authenticate as
  6480. 5:31:04user and navigate into HD Docs and here
  6481. 5:31:08we have the project now we get into SRV
  6482. 5:31:11folder and let's open let's use Nano do
  6483. 5:31:17file we hit the enter and the
  6484. 5:31:20application name is something we can
  6485. 5:31:21leave we can change we create a test
  6486. 5:31:23application so I don't care about the
  6487. 5:31:25application name the an environment
  6488. 5:31:27basically should always be changed into
  6489. 5:31:30production when we deploy the
  6490. 5:31:31application to production we're going to
  6491. 5:31:33change the debug mode into false or we
  6492. 5:31:37can leave the time Zone and we're going
  6493. 5:31:38to change the application URL into
  6494. 5:31:41https
  6495. 5:31:43Lara rea.com
  6496. 5:31:48okay if you scroll down below if you
  6497. 5:31:51haven't actually working SMTP
  6498. 5:31:54credentials you can find this mailing
  6499. 5:32:00section where is it here it is so mail
  6500. 5:32:03mailer and you have to provide the SMTP
  6501. 5:32:05right here provide the host port
  6502. 5:32:07username password of your SMTP server
  6503. 5:32:10and it's going to actually start sending
  6504. 5:32:12emails now let's save that if you don't
  6505. 5:32:15like the following domain name and also
  6506. 5:32:18the folder name is the following domain
  6507. 5:32:20name we can also change this and let's
  6508. 5:32:23give it Lara react. comom however we
  6509. 5:32:27have to move the project into the
  6510. 5:32:30following location
  6511. 5:32:33so let me open this SSH and I'm going to
  6512. 5:32:37go back and we're going to execute move
  6513. 5:32:41SRV into l
  6514. 5:32:44rea.com
  6515. 5:32:46so that's going to be the new folder
  6516. 5:32:48name inside which we're going to have
  6517. 5:32:49our LEL project so we did this uh we did
  6518. 5:32:55that let's click on
  6519. 5:32:57Save however there is one additional
  6520. 5:32:59thing to do I'm going to hit on exit
  6521. 5:33:02here and clear this up and we're going
  6522. 5:33:04to actually go into the supervisor
  6523. 5:33:07location we we have the supervisor
  6524. 5:33:08config let me have a look in the history
  6525. 5:33:13this is inside Etc supervisor DC so
  6526. 5:33:16we're going to navigate into the
  6527. 5:33:18following folder oops I have cd twice so
  6528. 5:33:23here we are let's clear this up and have
  6529. 5:33:26a look so we have only one file now
  6530. 5:33:29let's open this
  6531. 5:33:33Nano and let's have a look so this is
  6532. 5:33:36right now the location which needs to be
  6533. 5:33:37changed okay
  6534. 5:33:40so let's come
  6535. 5:33:42here change into L rea.com let's come
  6536. 5:33:48here as
  6537. 5:33:50well and we're going to change that log
  6538. 5:33:53file into Lara rea.com
  6539. 5:33:58dolog so we save this then we have to
  6540. 5:34:02execute supervisor CTL reread to read
  6541. 5:34:06the new config file
  6542. 5:34:08I actually rerun this so I see no config
  6543. 5:34:10updates to processes but you're going to
  6544. 5:34:12see that um it uh something was changed
  6545. 5:34:16okay so here we need to execute
  6546. 5:34:20updates after this we need to execute
  6547. 5:34:23supervisor
  6548. 5:34:25CTL stop and we have to provide the uh
  6549. 5:34:28service name so ll- SSR colum and
  6550. 5:34:34asterisk hit the enter it got stopped
  6551. 5:34:37and then we have to provide start we hit
  6552. 5:34:41the enter it got started now if we check
  6553. 5:34:45that in the
  6554. 5:34:46browser we are going to see BL rea.com
  6555. 5:34:50so the applications up and running we're
  6556. 5:34:54navigating click on this we can copy the
  6557. 5:34:57title and
  6558. 5:34:59view the page source and we're going to
  6559. 5:35:02see that this is used in four places
  6560. 5:35:04this is server side rendered content
  6561. 5:35:07actually and just like this we change
  6562. 5:35:09the name the location where the
  6563. 5:35:11application is located and that's
  6564. 5:35:13actually pretty useful if you plan to
  6565. 5:35:16have multiple projects in on this VPS
  6566. 5:35:19server if we right now navigate into as
  6567. 5:35:24login as user and then go inside HG dos
  6568. 5:35:29here we see L rea.com we can remove uh
  6569. 5:35:35TMP completely remove remove D
  6570. 5:35:39rfmp and we can also remove this SRV log
  6571. 5:35:43file we can leave the SK ignore uh and
  6572. 5:35:47just like this we have just lara.com and
  6573. 5:35:50you can add new projects in the
  6574. 5:35:53following folder with your own domains
  6575. 5:35:56and then you can just assign different
  6576. 5:35:58domains or subdomains to that project
  6577. 5:36:01this is pretty awesome now let's see one
  6578. 5:36:04of the coolest part of the deployment
  6579. 5:36:06and which is automat deployment through
  6580. 5:36:08GitHub actions for this I just created a
  6581. 5:36:12new yml file inside GitHub workflows
  6582. 5:36:17folder you can name this whatever you
  6583. 5:36:19want I call this hostinger deploy yml
  6584. 5:36:22and it has the following synx you can
  6585. 5:36:24get the following yml in from the
  6586. 5:36:26project repository under GitHub
  6587. 5:36:28workflows folder and now let's explain
  6588. 5:36:31this so here you give the name again
  6589. 5:36:32whatever you want to this and now this
  6590. 5:36:35is the event so we're listening on push
  6591. 5:36:38on the following branches so here inside
  6592. 5:36:41on you can actually listen to multiple
  6593. 5:36:44events like there is support for a
  6594. 5:36:47release when the new release is made uh
  6595. 5:36:50then we can trigger something okay but
  6596. 5:36:53right now we are only listening to push
  6597. 5:36:55events on the main branch and these are
  6598. 5:36:57actually jobs that will be executed we
  6599. 5:37:00have only one job so this is going to
  6600. 5:37:02run so whenever we push something on the
  6601. 5:37:05main branch GitHub will spin up the uh
  6602. 5:37:10Runner server and this Runner server
  6603. 5:37:13everything right here happens on the
  6604. 5:37:15Runner server that Runner will take the
  6605. 5:37:18latest buun okay so it is going to have
  6606. 5:37:22um the following steps to set up so this
  6607. 5:37:25is just the name and the action what
  6608. 5:37:26should happen this action will use this
  6609. 5:37:29actions checkout version two that is
  6610. 5:37:31actually necessary thing for this GitHub
  6611. 5:37:33actions Runner and then we're going to
  6612. 5:37:35use the following image to set up PHP
  6613. 5:37:39and we specify that we want version
  6614. 5:37:428.3 then we're going to set up the
  6615. 5:37:44node.js this is just name and with the
  6616. 5:37:46following action and we use node version
  6617. 5:37:4922 next we are going to do some things
  6618. 5:37:52on that Runner server okay on that
  6619. 5:37:55Runner server we're going to make sure
  6620. 5:37:57that the application is actually started
  6621. 5:38:00at least okay so we create this file
  6622. 5:38:05through just copying en example into Yan
  6623. 5:38:09we're going to execute composer install
  6624. 5:38:10with the following Flex to install the
  6625. 5:38:12dependencies we're going to execute PHP
  6626. 5:38:14Artisan key generate to generate the
  6627. 5:38:16application key we're going to also
  6628. 5:38:18storage the link now we're going to
  6629. 5:38:20execute the migrations mpm install we're
  6630. 5:38:24going now execute mpm run build and
  6631. 5:38:27right here we have this interesting step
  6632. 5:38:29which is PHP Artisan test we haven't
  6633. 5:38:31written any tests but if you have uh
  6634. 5:38:34written tests for your application you
  6635. 5:38:36want to run this
  6636. 5:38:38so we are B basically setting up the
  6637. 5:38:40entire project on GitHub Runner server
  6638. 5:38:42and finally running test just to make
  6639. 5:38:46sure that everything runs before it is
  6640. 5:38:49deployed on the
  6641. 5:38:51server so one if that success uh
  6642. 5:38:55succeeds then we're going to deploy that
  6643. 5:38:57to the server for this we're going to
  6644. 5:38:59use the following SSH action image H
  6645. 5:39:02which has the following variables
  6646. 5:39:05additional variables so we need uh some
  6647. 5:39:09host username port and key to
  6648. 5:39:12authenticate to the server and GitHub
  6649. 5:39:15Runner server needs to authenticate on
  6650. 5:39:19our hostinger server so GitHub Runner
  6651. 5:39:22server needs to connect to the server to
  6652. 5:39:25be able to execute some uh commands
  6653. 5:39:28right here and for this when the
  6654. 5:39:30connection happens with the following uh
  6655. 5:39:33variables then the following scripts
  6656. 5:39:35should be executed
  6657. 5:39:37okay now imagine the
  6658. 5:39:40following whenever the hostinger
  6659. 5:39:43whenever the GitHub Runner server
  6660. 5:39:45authenticates on the server as regular
  6661. 5:39:48user not as root as regular user the
  6662. 5:39:51GitHub Runner server uh will access the
  6663. 5:39:55users's home directory so this is going
  6664. 5:39:57to be the state for the GitHub Runner
  6665. 5:40:00server then the following steps will be
  6666. 5:40:02executed so this will
  6667. 5:40:05happen then this will
  6668. 5:40:08happen so we are already on the main
  6669. 5:40:11bran so that doesn't do anything so
  6670. 5:40:13we're going to execute git pool which is
  6671. 5:40:15going to pull the latest main branch
  6672. 5:40:18right now we don't have anything but
  6673. 5:40:19when there is new push on the main
  6674. 5:40:21branch what we are listening to
  6675. 5:40:24obviously there will be something to
  6676. 5:40:25pull then it's going to execute composer
  6677. 5:40:28install mpm C mpm run build and so on
  6678. 5:40:31and finally it is going to execute a PHP
  6679. 5:40:34Artisan inertia toop SSR this stop SSR
  6680. 5:40:38is necessary to just stop the server
  6681. 5:40:40side rendering server which will be
  6682. 5:40:41automatically started using supervisor
  6683. 5:40:44and once we have that information this
  6684. 5:40:47is all what you need for automatic
  6685. 5:40:49deployment now we have to take care of
  6686. 5:40:53this variables which is coming from
  6687. 5:40:54these secrets the secrets is
  6688. 5:40:57actually
  6689. 5:40:59um let me open the GitHub the secrets is
  6690. 5:41:02a variable is a container inside the
  6691. 5:41:05repository so this is the Repository
  6692. 5:41:08we're going to go into
  6693. 5:41:10settings we need
  6694. 5:41:13actions uh sorry we need secrets and
  6695. 5:41:15variables and click on actions and right
  6696. 5:41:18here we have to add those secret
  6697. 5:41:20variables which are described right here
  6698. 5:41:23so let's add them one after another so
  6699. 5:41:27the first one is SSH host which is going
  6700. 5:41:31to be in our case Lara react Lara
  6701. 5:41:35rea.com so this this is the host on
  6702. 5:41:38which this should connect the GitHub
  6703. 5:41:40Runner server should
  6704. 5:41:42connect okay head
  6705. 5:41:45secret
  6706. 5:41:47next is going to be SSH username which
  6707. 5:41:50is going to be a regular user our user
  6708. 5:41:53is called user so we're going to provide
  6709. 5:41:56user here if your buntu user would be
  6710. 5:41:59called zoraa you would write zoraa here
  6711. 5:42:03add
  6712. 5:42:04secret then we have
  6713. 5:42:08Port SSH
  6714. 5:42:10port and the port is actually
  6715. 5:42:1422 the default SSH Port is always 22 and
  6716. 5:42:18when we don't provide when we try to
  6717. 5:42:20authenticate and when we don't provide
  6718. 5:42:22that it means it is
  6719. 5:42:2422 uh next is the SSH key and this is
  6720. 5:42:28the mo most interesting part so let's
  6721. 5:42:32put this and what we're going to put
  6722. 5:42:34right here so the GitHub Runner server
  6723. 5:42:38we mentioned that needs to talk to the
  6724. 5:42:40our VPS server to be able to connect it
  6725. 5:42:43and execute some scripts right there for
  6726. 5:42:46this there are two types of
  6727. 5:42:48authentication with password or without
  6728. 5:42:51password but through SSH keys so we are
  6729. 5:42:54going to do this authentication through
  6730. 5:42:56SSH keys because we cannot actually
  6731. 5:42:58enter the password uh the password needs
  6732. 5:43:01to be entered when we try to
  6733. 5:43:04authenticate and let me just demonstrate
  6734. 5:43:07at this to you I'm going to log out so
  6735. 5:43:10this is my gitbash server and right now
  6736. 5:43:13I want to authenticate so I execute SSH
  6737. 5:43:16root at larar rea.com hit the enter and
  6738. 5:43:20now it asks me password but if I
  6739. 5:43:22Implement public key authentication it
  6740. 5:43:24will not ask me password and I will be
  6741. 5:43:26authenticated immediately now let's try
  6742. 5:43:29to authenticate with password and I'm
  6743. 5:43:32going to change this as
  6744. 5:43:34well cool now let's go into
  6745. 5:43:37user let's execute su- user and inside
  6746. 5:43:41user I'm going to navigate into SSH
  6747. 5:43:44folder and check what F files we have we
  6748. 5:43:48are interested inside authorized Keys
  6749. 5:43:51okay I'm going
  6750. 5:43:53to now open these authorized Keys which
  6751. 5:43:57is empty at the moment and this is what
  6752. 5:44:00I'm going to do next let's open another
  6753. 5:44:03gitbash server terminal which is my
  6754. 5:44:06local terminal
  6755. 5:44:07okay and I'm going to take my public key
  6756. 5:44:11from my home directory SSH ID whatever.
  6757. 5:44:16PP so this is my public key I'm going to
  6758. 5:44:19take this copy that and paste this
  6759. 5:44:24here yeah so we save this and now by
  6760. 5:44:29providing my personal public key to this
  6761. 5:44:33regular user inside authorized Keys file
  6762. 5:44:37this means that um that server now gives
  6763. 5:44:42me access to it without password and if
  6764. 5:44:46I exit right now two times and I want to
  6765. 5:44:50authenticate using SSH I'm going to use
  6766. 5:44:53SSH I'm going to use right now regular
  6767. 5:44:56user because I added that SSH key inside
  6768. 5:44:59regular user user at larar rea.com we
  6769. 5:45:04hit the
  6770. 5:45:05enter and voila we have been
  6771. 5:45:08authenticated for regular user I'm
  6772. 5:45:10already regular user okay and we have to
  6773. 5:45:14do something similar but we have to do
  6774. 5:45:17this now for GitHub Runner server and
  6775. 5:45:20that SSH key right here should be
  6776. 5:45:22private key because I was able to
  6777. 5:45:26authenticate uh with this public key the
  6778. 5:45:28only reason for that is that I actually
  6779. 5:45:32have public sorry I actually have
  6780. 5:45:35private key here so this is my private
  6781. 5:45:37key which is actually secret and I'm not
  6782. 5:45:39going to show this to you but this is my
  6783. 5:45:41private key and this is the public key
  6784. 5:45:44and when I executed SSH command SSH just
  6785. 5:45:48checked what was my private key used
  6786. 5:45:50that private key for the authentication
  6787. 5:45:53validated that private key with the
  6788. 5:45:55public key which I eded inside
  6789. 5:45:57authorized Keys file on the server and
  6790. 5:46:00they matched and thus I was able to
  6791. 5:46:03authenticate now I'm going to close this
  6792. 5:46:06and this is what we we are going to do
  6793. 5:46:08we already have public private Keys
  6794. 5:46:10generated right here so this is the
  6795. 5:46:12private key this is the public key so
  6796. 5:46:16what we need to do is just take this
  6797. 5:46:18private key and put it right
  6798. 5:46:23here now let's do this cut
  6799. 5:46:27ID this is the private key I'm going to
  6800. 5:46:30take
  6801. 5:46:33this and put it here
  6802. 5:46:40next I am going to take the this is the
  6803. 5:46:43private key which we put right here but
  6804. 5:46:45we need its corresponding public key its
  6805. 5:46:48corresponding public key is this so
  6806. 5:46:50we're going to take that public key cut
  6807. 5:46:58that and we're going to put that public
  6808. 5:47:01key right here inside authorized
  6809. 5:47:04keys cut actually we should use Nano
  6810. 5:47:08inside authorized
  6811. 5:47:10Keys
  6812. 5:47:12paste
  6813. 5:47:16oops uh save no I don't want to make
  6814. 5:47:20up uh I copied something else so this is
  6815. 5:47:25what we need to copy then we open this
  6816. 5:47:29and paste it and now we have two public
  6817. 5:47:33Keys added this is for my personal
  6818. 5:47:36computer and and this is for uh GitHub
  6819. 5:47:39Runner so I'm going to save and quit
  6820. 5:47:43also one thing to make this fully clear
  6821. 5:47:46is that we used the same public key to
  6822. 5:47:49add to the GitHub under deploy keys so
  6823. 5:47:54and that actually is not a bad idea so
  6824. 5:47:58we use the same private key here and the
  6825. 5:48:02same public key in two places so this
  6826. 5:48:05private key is right here on the server
  6827. 5:48:08and its corresponding public key is
  6828. 5:48:10added inside deploy Keys which means
  6829. 5:48:12that this server is able to communicate
  6830. 5:48:16to the following
  6831. 5:48:19project but we also have that SSH
  6832. 5:48:23key which is the following private key
  6833. 5:48:26and the public key added inside
  6834. 5:48:28authorized Keys which means that the
  6835. 5:48:30GitHub Runner server is able to
  6836. 5:48:33authenticate to This Server so this
  6837. 5:48:36private key is actually secret you
  6838. 5:48:37should not tell it to anyone um I'm
  6839. 5:48:40going to actually delete this after the
  6840. 5:48:42video but yeah if it's secret um so
  6841. 5:48:46that's why we have that put that in into
  6842. 5:48:48secret
  6843. 5:48:49variables okay now it's time to test our
  6844. 5:48:52workflows so I'm going to comment
  6845. 5:48:54everything actually I have only one
  6846. 5:48:56change add GitHub
  6847. 5:49:01work
  6848. 5:49:03workflows Okay click on comment
  6849. 5:49:07we're going to push
  6850. 5:49:09this on the
  6851. 5:49:11server and now let's
  6852. 5:49:14check inside
  6853. 5:49:17actions as we see the actions has was
  6854. 5:49:20started the GitHub workflow click on
  6855. 5:49:23this we're going to click on
  6856. 5:49:26build and now let's see so setting up
  6857. 5:49:29job has been done check out code has
  6858. 5:49:31been completed setup PHP was actually
  6859. 5:49:34also completed setup no JS completed and
  6860. 5:49:37it's following and doing
  6861. 5:49:40everything so that was run first on the
  6862. 5:49:43GitHub Runner
  6863. 5:49:44server no JS dependencies building
  6864. 5:49:48assets if building is failing for some
  6865. 5:49:51reason uh because of the typescript it
  6866. 5:49:53is the deploy will not
  6867. 5:49:55happen Okay building assets and here we
  6868. 5:49:59have this problem so run tests the tests
  6869. 5:50:02have been actually failed and
  6870. 5:50:05we uh we can see which test was actually
  6871. 5:50:08failed so this is the test that was
  6872. 5:50:11failed this was failed and we actually
  6873. 5:50:15because we haven't taken care of the
  6874. 5:50:17test I think we just need to comment out
  6875. 5:50:20this part but if you are actually
  6876. 5:50:23building the real application and if you
  6877. 5:50:24have tests up and running you should
  6878. 5:50:26obviously fix the tests so let's comment
  6879. 5:50:29out this
  6880. 5:50:32part remove
  6881. 5:50:35tests click on com
  6882. 5:50:37comit push that was failed the entire
  6883. 5:50:41job so now let's click on actions new
  6884. 5:50:44started with a comment message remove
  6885. 5:50:49tests and we are going to
  6886. 5:50:52wait now the job has been completed and
  6887. 5:50:55we're going to check the following
  6888. 5:50:58part look at this so install no JS
  6889. 5:51:01dependencies building assets that was
  6890. 5:51:04completed the tests were removed and now
  6891. 5:51:06this is the deploy PHP to server so we
  6892. 5:51:10just authenticated to the server and
  6893. 5:51:13then we we are already on Main Branch um
  6894. 5:51:16because we performed the checkout on
  6895. 5:51:18Main then pull happened and the
  6896. 5:51:22following thing was downloaded and then
  6897. 5:51:24we installed all the dependencies
  6898. 5:51:26everything was executed here composer
  6899. 5:51:28install mpm run
  6900. 5:51:31build and finally that was all related
  6901. 5:51:34to build and finally the cash has been
  6902. 5:51:37cleared uh and finally the inertia
  6903. 5:51:40server um stopped and because of the
  6904. 5:51:43inertia server stopped uh supervisor
  6905. 5:51:46catched that and automatically restarted
  6906. 5:51:48this so now if we check our project we
  6907. 5:51:51are going to see that the um server side
  6908. 5:51:54rendering is still working as it should
  6909. 5:52:00work
  6910. 5:52:02oops here we see that in four places
  6911. 5:52:05okay but everything um happened as it
  6912. 5:52:10should happen and we have fully up and
  6913. 5:52:13running project with um roles
  6914. 5:52:17permissions login registration
  6915. 5:52:20everything the only thing what I haven't
  6916. 5:52:21done is the production ready SMTP
  6917. 5:52:25credentials which you can just Google
  6918. 5:52:28how to take these and put this in the
  6919. 5:52:30project I think that's the um that's
  6920. 5:52:33very easy part but we have fully working
  6921. 5:52:35service rendered application up and
  6922. 5:52:37running and deployed on the server and
  6923. 5:52:40if you watch this video so far please
  6924. 5:52:42please hit the like button and subscribe
  6925. 5:52:45if you are not yet subscribed to the
  6926. 5:52:47Channel all right my friends that's it
  6927. 5:52:49for this video and I hope you learn
  6928. 5:52:51something new if you want more tutorials
  6929. 5:52:54like this please hit the like button and
  6930. 5:52:56subscribe because without your support I
  6931. 5:52:59can continue like this because uh the
  6932. 5:53:02videos the projects on which I spent one
  6933. 5:53:05month of work doesn't get that many
  6934. 5:53:07views or engagement that's probably my
  6935. 5:53:09fault if you are not interested in such
  6936. 5:53:12types of projects okay I have to just
  6937. 5:53:14switch to a different direction but if
  6938. 5:53:16you like it don't forget to hit the like
  6939. 5:53:19button and provide a nice comment as
  6940. 5:53:21well if you don't want to provide a nice
  6941. 5:53:23comment just leave a comment and tell me
  6942. 5:53:25what's wrong with the video because I
  6943. 5:53:27want to also improve and provide more
  6944. 5:53:30valuable content in the future if you
  6945. 5:53:32don't like such long videos feel free to
  6946. 5:53:34let me know about this as well if you
  6947. 5:53:36watch this till the end probably you'll
  6948. 5:53:39like long videos but anyway just give me
  6949. 5:53:42your feedback uh in the comment section
  6950. 5:53:44down below all right thanks for watching
  6951. 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.