YouTube2Text

Laravel Blog: Comments, Global Search, Deployment | Part 3 — Transcript

by The Codeholic · 20,803 words · 3,662 segments · language en · Watch on YouTube

Full transcript

  1. 0:00what's up everybody the coaches here and
  2. 0:02welcome to my channel this is the third
  3. 0:04part of series building laravel 10 blog
  4. 0:06website and in this video we're gonna
  5. 0:08build comment sections so we're going to
  6. 0:10implement the entire comment section
  7. 0:12such as reading comments editing
  8. 0:14deleting writing child comments replying
  9. 0:17comments and even have like a deep
  10. 0:19nested level of replying comments we're
  11. 0:22gonna also Implement Global search on
  12. 0:25the website on the blog website to
  13. 0:27search for articles by title and a
  14. 0:29description and finally in this video
  15. 0:32we're going to deploy the project on
  16. 0:34custom domain and production environment
  17. 0:36with SSL certificate as well as a choice
  18. 0:38of Hosting provider for this tutorial
  19. 0:40I'm going to use hostinger which is also
  20. 0:42kindly sponsoring this video
  21. 0:44I have been using customer services for
  22. 0:47about two years and I can honestly say
  23. 0:49that it's one of the best shared hosting
  24. 0:51providers out there they support
  25. 0:53different type of Hosting such as shared
  26. 0:55hosting Cloud hosting VPS hosting but in
  27. 0:58my opinion their shared hosting services
  28. 1:01are just the best okay let's have a look
  29. 1:04at the website in just three dollar
  30. 1:06price they include the following things
  31. 1:09so they have 100 websites they have free
  32. 1:12domain which by itself costs at least 10
  33. 1:15you have unlimited free SSL certificates
  34. 1:18you have a possibility for free email
  35. 1:21and not only one email multiple emails
  36. 1:24you have like unlimited databases and
  37. 1:27there are many many other things in this
  38. 1:30uh like a three dollar shared housing
  39. 1:32plan so if we just click let's click
  40. 1:36this is actually Four dollar which is a
  41. 1:39business web hosting which is the most
  42. 1:41popular one but if we just click A2 card
  43. 1:44here and use the coupon code the code
  44. 1:47holique you're going to get additional
  45. 1:5010 discount on all that so you can
  46. 1:53choose period like one month 12 months
  47. 1:5524 or 48 months the more time period you
  48. 1:57choose obviously saving will be much
  49. 2:00more and as you can see like this is a
  50. 2:03four-yard hosting provider like the most
  51. 2:06common one probably is one yard because
  52. 2:08the domain also renews in one year so if
  53. 2:12we just click on 12 months we're going
  54. 2:14to see that we just pay
  55. 2:1648 48 dollar which includes domain as
  56. 2:20well as one year hosting and again if
  57. 2:23you use coupon code the code holy crate
  58. 2:26here you're gonna get additional 10
  59. 2:28discount
  60. 2:31decide to deploy this project or any
  61. 2:33other project on shared hosting I really
  62. 2:35recommend hostinger whenever you sign up
  63. 2:37you will be redirected to hostinger
  64. 2:39Modern Age panel and then the deployment
  65. 2:42part will be continued from there which
  66. 2:44will be the last part of this particular
  67. 2:46section and thank you hostinger for
  68. 2:49sponsoring this video all right now
  69. 2:51let's focus on the video and start
  70. 2:53building comment section
  71. 2:54okay let's bring up the terminal and I'm
  72. 2:56going to generate comments comment model
  73. 2:59PHP art design make model
  74. 3:04comment
  75. 3:05let's specify migration as well
  76. 3:08now let's open migration create comments
  77. 3:12table
  78. 3:12okay what do we need here
  79. 3:15obviously we need a string which will be
  80. 3:18comment
  81. 3:19we can make this comment very large so
  82. 3:22we can specify it can be text or even
  83. 3:25maybe a long text let's do long text
  84. 3:29and the name will be actual comment
  85. 3:33okay we obviously need post ID so let's
  86. 3:37specify foreign ID
  87. 3:40post ID
  88. 3:42that cannot be null so
  89. 3:45we should not specify nullable but it
  90. 3:48should be constrained on posts I'm going
  91. 3:51to duplicate this and specify the user
  92. 3:54ID that cannot be also now it must be
  93. 3:57provided and then we have constraint so
  94. 4:00we have uh time when the comment was
  95. 4:03actually made the comment can be deleted
  96. 4:05or updated whenever comment is deleted
  97. 4:07like we can Implement soft deletes
  98. 4:11and we can make it to be uh actually
  99. 4:14saved in the database which is kind of
  100. 4:16good thing and we should probably even
  101. 4:18be doing this for uh posts and articles
  102. 4:20which I'm not going to do this at this
  103. 4:23stage but again a great challenge to add
  104. 4:27soft deletes to your posts and comments
  105. 4:30and categories as well so that whenever
  106. 4:31comment is deleted and someone is
  107. 4:34blaming someone else you you can check
  108. 4:36in the database that the actual comment
  109. 4:39was presented there okay so we have uh
  110. 4:42post ID a user ID what else we might
  111. 4:46need uncomment
  112. 4:48like I think this is enough for the
  113. 4:49beginning we can of course add
  114. 4:51additional columns if that becomes
  115. 4:53necessary but at the moment we will know
  116. 4:55who made a comment on which posts he
  117. 4:59made a comment at what time and what's
  118. 5:02the actual common text
  119. 5:04that basically describes the whole
  120. 5:07common thing okay now let's open comment
  121. 5:10model
  122. 5:12and a defeatable
  123. 5:15we need to define those three columns
  124. 5:21that's perfect
  125. 5:28okay now we can start working on the
  126. 5:31design side let's actually run this
  127. 5:33migration PHP Artisan migrate
  128. 5:36oops something's wrong PHP Artisan
  129. 5:39migrate let's have a look what's the
  130. 5:42problem
  131. 5:44host views
  132. 5:51create post views table okay I think I
  133. 5:54have
  134. 5:55um just messed up something
  135. 5:57in my migration create post views so the
  136. 6:00post reviews table actually exists in my
  137. 6:02case but this is not marked in
  138. 6:03migrations again I messed up between
  139. 6:06recording sections which is
  140. 6:09which is okay
  141. 6:12so this is the post fuse which I'm gonna
  142. 6:15put this rate
  143. 6:17right here
  144. 6:21okay
  145. 6:24that's not going to be case
  146. 6:26on your machine
  147. 6:28okay now create comments table was
  148. 6:30successfully applied
  149. 6:31perfect let's close migrations common
  150. 6:34stable was created now I'm going to do
  151. 6:36comments using Live Wire
  152. 6:41so let's define components for live y
  153. 6:46we need comment section
  154. 6:48at the very bottom somewhere right here
  155. 6:53after next and
  156. 6:55yeah below next so let's create Live
  157. 6:59Wire components PHP artisan make
  158. 7:03Live Wire and we need to call the
  159. 7:06component
  160. 7:08let's call this comments
  161. 7:12okay let's hit the enter
  162. 7:14okay comments component was created here
  163. 7:16we see the comments blade as well
  164. 7:20I want to also
  165. 7:22maybe Define comment item
  166. 7:26so let's execute that comment item
  167. 7:31here we go let's hit the enter okay that
  168. 7:34was also created
  169. 7:35now what I have in my mind is that right
  170. 7:39here I'm going to have Commons section
  171. 7:41inside which I'm going to iterate and
  172. 7:43render comment items
  173. 7:46and then we're going to have of course
  174. 7:48like reply
  175. 7:50um or leave a comment section and things
  176. 7:53like that
  177. 7:54so I think we need to create
  178. 7:58[Music]
  179. 7:58um
  180. 7:59comment create
  181. 8:02comment create component as well
  182. 8:06and let's start with simple steps I'm
  183. 8:08going to open comment
  184. 8:10comment
  185. 8:12create
  186. 8:14okay this uses the following component
  187. 8:17let's actually
  188. 8:19have a look in this component I'm going
  189. 8:21to just write
  190. 8:23texts
  191. 8:25comment create
  192. 8:28I'm going to also open Commons blade
  193. 8:32okay so here we are going to iterate and
  194. 8:37I'm going to open comment item as well
  195. 8:38so in the comments blade we are going to
  196. 8:41iterate
  197. 8:42iterate and render
  198. 8:45comment items and then we're going to
  199. 8:48have comment create so let's actually
  200. 8:52use
  201. 8:54Live Wire
  202. 8:56colon comment slash create
  203. 9:00okay and this comments component needs
  204. 9:03to be used in The View Post View
  205. 9:07so let's collapse everything and I think
  206. 9:10this is the previous and next buttons
  207. 9:12and below that we can use Live Wire
  208. 9:17colon
  209. 9:18comments
  210. 9:20and that's it in the comments obviously
  211. 9:22will need post component so we can
  212. 9:25provide that here as well
  213. 9:28okay so we save this reload the page and
  214. 9:31we see right here iterate and render
  215. 9:33comment items and then we have comment
  216. 9:35create this is in the set Center which I
  217. 9:39don't expected it to be in the center
  218. 9:42and maybe this is in the center because
  219. 9:46we have right here Flex column and item
  220. 9:49Center if we just remove this item
  221. 9:51Center
  222. 9:53I think we will not have and everything
  223. 9:55else will stay the same which is perfect
  224. 9:58now let's start working on the comment
  225. 10:01create
  226. 10:03so here we obviously need input
  227. 10:07then we need whenever we click inside
  228. 10:11the input we need to be able to write
  229. 10:13some sort of comment so let's start with
  230. 10:15the input and we're gonna of course add
  231. 10:17additional HTML we will need one button
  232. 10:20which will be to
  233. 10:22um
  234. 10:23submit maybe and another button
  235. 10:27which will be to cancel
  236. 10:30okay let's do like this so this let's
  237. 10:35provide some classes like um we need
  238. 10:38let me actually grab those classes from
  239. 10:43Talon CSS not to type them
  240. 10:45every time so this is a button
  241. 10:48yeah I want a normal button
  242. 11:01um okay I don't want to like expend too
  243. 11:04much time on typing uh tolerances
  244. 11:07classes
  245. 11:09so let me actually try to do this if I
  246. 11:13do it
  247. 11:14in a short time that's fine so
  248. 11:17ax3 I want let's give it a PG
  249. 11:23PG blue
  250. 11:24uh 400 and on Hover we need PG blue
  251. 11:30um maybe 600 or specify 500 here let's
  252. 11:35give these rounded as well and text
  253. 11:38White
  254. 11:40all right let's give this one
  255. 11:45um
  256. 11:46leave a comment
  257. 11:49okay perfect
  258. 11:50let's have a look so we see leave a
  259. 11:52comment we see submit and cancel
  260. 11:55all right so this leave a comment
  261. 11:57section needs to be in some div element
  262. 11:59so that it needs to be on the whole line
  263. 12:01we need to install input components
  264. 12:05actually there is this uh Tailwind
  265. 12:10components free components package
  266. 12:14telling the UI
  267. 12:16okay and if we go in the browse
  268. 12:18components
  269. 12:21and choose any of those components
  270. 12:23especially I'm interested in the forms
  271. 12:25because we need an input like contact
  272. 12:27Section for example
  273. 12:29so this is it and I'm going to go in the
  274. 12:31code I see that I need to install Talon
  275. 12:34CSS forms
  276. 12:35and I think I I don't have that
  277. 12:37installed so I'm going to bring up the
  278. 12:39terminal and execute npm install
  279. 12:43Talon CSS forms
  280. 12:45and I'm going to also open
  281. 12:49shift
  282. 12:52tailwind config.js and in plugins yeah I
  283. 12:57already had Talon CSS forms which is
  284. 13:01good
  285. 13:02and I'm going to grab the classes for
  286. 13:06that specific form like the first name
  287. 13:08for example let me actually grab this
  288. 13:10form
  289. 13:12and I'm going to put this right here
  290. 13:16let's format the code we have a huge
  291. 13:21huge CSS
  292. 13:24and let me try to
  293. 13:27wrap
  294. 13:30I want soft wraps to enable soft drops
  295. 13:38appearance
  296. 13:45I generally don't enable this part for
  297. 13:47tutorials that's um that's something
  298. 13:50necessary
  299. 13:51use soft wrap
  300. 13:56I want this to be enabled on probably
  301. 13:58every file
  302. 14:00soft crops
  303. 14:02yeah that's it okay now we see all the
  304. 14:05classes every time so that's fine so I
  305. 14:08save this and have a look so we have
  306. 14:10this input we can provide right here
  307. 14:12lace holder leave a comment and to have
  308. 14:17all this consistency I'm going to grab
  309. 14:20button
  310. 14:22let's talk buttons tiles from here as
  311. 14:25well let's
  312. 14:27talk so let's get this button and put
  313. 14:31this right here
  314. 14:35okay and instead of let's talk we'll
  315. 14:38give it a name submit
  316. 14:41I'm going to duplicate now these
  317. 14:44and instead of type submit
  318. 14:47I'm going to just remove that or maybe
  319. 14:50it should be a type pattern because by
  320. 14:52default it's already submit let's give
  321. 14:54it class cancel
  322. 14:58and we obviously need different styles
  323. 15:00right here so I'm going to remove
  324. 15:02probably
  325. 15:03like everything
  326. 15:04let's let's remove everything
  327. 15:07and have a look how this will look like
  328. 15:09I'm gonna also wrap everything in its
  329. 15:13own form because finally that is
  330. 15:15something that needs to be submitted
  331. 15:18all right
  332. 15:21okay that's great however the submit
  333. 15:24needs to be on a full width so w full
  334. 15:28block is something I'm going to remove
  335. 15:29we have submit and cancel
  336. 15:31which is perfect
  337. 15:35however even submittent cancel is not
  338. 15:38necessary to be displayed until you
  339. 15:40click inside leave a comment right so we
  340. 15:45can add an event for that using
  341. 15:48alpine.js to show submit and cancel
  342. 15:51buttons whenever user clicks inside to
  343. 15:54leave a comment so the submit and cancel
  344. 15:57we can put in its own div
  345. 16:01and then we give it a class
  346. 16:06well let's give it class hide I think
  347. 16:08let's see it or hidden
  348. 16:13okay they are hidden perfect and when I
  349. 16:17click inside then this should be visible
  350. 16:19so I'm gonna
  351. 16:20use alpine.js
  352. 16:23to run X init
  353. 16:26and here we have this object
  354. 16:28if I remember correctly I have actually
  355. 16:31of like four hours course uh full course
  356. 16:34about alpine.js but I don't actually use
  357. 16:37it very often that's why I I might not
  358. 16:39remember everything but in excellent we
  359. 16:42can specify what's going to be the state
  360. 16:45for this div element like
  361. 16:49um
  362. 16:50focused for example
  363. 16:52August equals false
  364. 16:56and then we can add this class based on
  365. 16:59the condition like class
  366. 17:03equals if log used then we provide here
  367. 17:08nothing if not focused then we provide
  368. 17:12it here
  369. 17:13hidden
  370. 17:17okay let's check this
  371. 17:24so we save this if it's not focused
  372. 17:29Focus false
  373. 17:32if it's focused yeah which this should
  374. 17:35not be visible
  375. 17:38I think in surfix in it there should be
  376. 17:41state
  377. 17:42focused false let's leave it like this
  378. 17:44and at the moment yeah we don't see the
  379. 17:48buttons If I set this focused true
  380. 17:52then we see those buttons perfect so we
  381. 17:54set this into focused false uh well that
  382. 17:59is the container for the input field I'm
  383. 18:00going to give it margin button 2.
  384. 18:03perfect
  385. 18:05and whenever we click inside so let's
  386. 18:08use
  387. 18:10uh click
  388. 18:14I'm going to set focused
  389. 18:18um
  390. 18:19pocket equals true however we need to
  391. 18:22handle
  392. 18:23polar case as well so
  393. 18:26we clicked
  394. 18:28buttons appear but then when you
  395. 18:32yeah that's that's actually fine so we
  396. 18:34we're about to start writing a comment
  397. 18:36but whenever we click cancel that should
  398. 18:39be changed so on cancel
  399. 18:42click we said focused equals false
  400. 18:49okay
  401. 18:51that's perfect
  402. 18:53that's perfect
  403. 18:55now this I'll leave a comment can even
  404. 18:57be changed into
  405. 18:59text area
  406. 19:01let's see
  407. 19:07let's remove this ID and name and type
  408. 19:11text and maybe autocomplete as well so
  409. 19:13everything except classes we have
  410. 19:16placeholder scroll down below
  411. 19:19hold on
  412. 19:20I did something wrong
  413. 19:22text area
  414. 19:27here we go
  415. 19:29so here we have this leave a comment and
  416. 19:32I'm going to specify here Colin rows
  417. 19:35equals one row
  418. 19:38if this is focused
  419. 19:42then we provide
  420. 19:44uh
  421. 19:46maybe like a six rows otherwise we
  422. 19:49provide just one
  423. 19:53okay when I click inside then this
  424. 19:55increases
  425. 19:57that's perfect
  426. 20:00okay six is maybe too much
  427. 20:03probably four
  428. 20:06now let's actually try to save comments
  429. 20:09in the database we type something lorem
  430. 20:11ipsum
  431. 20:13and when I hit submit we're going to
  432. 20:15actually submit the form
  433. 20:17on the form I'm going to add method to
  434. 20:21be post
  435. 20:23and it will also add action
  436. 20:25to be
  437. 20:28well
  438. 20:29do we need this action
  439. 20:32we might not need I'm going to use wire
  440. 20:36a clique and whenever this happens let's
  441. 20:40call the method create comment
  442. 20:46okay
  443. 20:49in the actual
  444. 20:51comment create component class I'm going
  445. 20:54to create I'm going to Define public
  446. 20:58ring
  447. 21:00comment as a text
  448. 21:02so and I'm going to use that comment
  449. 21:05as a two-way data binding on this text
  450. 21:09area so I'm going to use wire
  451. 21:11modal to be comment and we can also try
  452. 21:16to Output what is the comment here
  453. 21:21and whenever we can even remove this
  454. 21:24method post I believe or we can we can
  455. 21:27leave this uh let's see what's the
  456. 21:29actual comment
  457. 21:31here so
  458. 21:33let's click on this unable to call
  459. 21:35component method create comment not
  460. 21:37found that's fine let's open
  461. 21:40let's open command create and create
  462. 21:43that function
  463. 21:45create comment at the moment
  464. 21:48I'm just gonna dump into tie just maybe
  465. 21:52one okay I don't want to do anything at
  466. 21:55the moment let's just have a look
  467. 21:58reload the page here we have that I
  468. 22:00click inside
  469. 22:01and it actually calls this
  470. 22:05comment create
  471. 22:07why does
  472. 22:09why does it call it well
  473. 22:12um
  474. 22:14not to over complicate things
  475. 22:17I'm going to give it a click wire
  476. 22:19click equals create
  477. 22:24comment
  478. 22:27let's remove this type Summit even or
  479. 22:29maybe change it into type pattern or I'm
  480. 22:32going to completely even change these
  481. 22:35form into div that's we're using Live
  482. 22:38Wire we are not actually like um
  483. 22:41submitting the form in a traditional
  484. 22:43understanding so I'm going to remove the
  485. 22:46method and wire click from here so I
  486. 22:48save that
  487. 22:49and now let's have a look so test
  488. 22:54comment and as we type we see that the
  489. 22:56comment is actually updated using 280
  490. 22:59binding I click on submit and now I see
  491. 23:01this one that's perfect so the comment
  492. 23:03was actually actually created
  493. 23:06now we need to save that comment so
  494. 23:09let's use comment model create
  495. 23:12and provide comment
  496. 23:17that's going to be this comment we will
  497. 23:21need host underscore ID
  498. 23:25and we don't have access to post I think
  499. 23:28if we check viewblade we pass post to
  500. 23:31comments that comments is the component
  501. 23:35right here we actually have access to
  502. 23:38these comments do we have so let's check
  503. 23:41these comments
  504. 23:43component Livewire class
  505. 23:46and
  506. 23:47yeah we don't have this host here
  507. 23:51declared which can be available in the
  508. 23:54comments
  509. 23:56let me check up for downward so we
  510. 23:59Define public posts we need to do the
  511. 24:01same thing and then unmount we need to
  512. 24:03assign this to post so I'm going to do
  513. 24:05the same thing
  514. 24:08now this post is available in the
  515. 24:11comments plate and I can take these and
  516. 24:14pass it down to comment create
  517. 24:17like this I need to open comment create
  518. 24:21and do something similar
  519. 24:27okay in this post needs to be defined
  520. 24:30and now we have this post available here
  521. 24:33so I can use this
  522. 24:36post
  523. 24:37ID
  524. 24:39and then obviously we need user ID
  525. 24:43if the user is trying to create post but
  526. 24:47user doesn't exist we need to redirect
  527. 24:49to to the login page so I'm going to try
  528. 24:52to get out
  529. 24:56user
  530. 24:57and check if the user does not exist we
  531. 25:02return redirect
  532. 25:07redirect
  533. 25:09can we call this redirect okay
  534. 25:12roads or we can specify it
  535. 25:16log in here
  536. 25:17Maybe
  537. 25:20we need the URL so we can specify
  538. 25:21logging here so let's save this however
  539. 25:25if that exists we are gonna execute user
  540. 25:28ID
  541. 25:30now I'm going to open the browser
  542. 25:33we have some kind of syntax errors
  543. 25:37somewhere
  544. 25:41I don't see that let's reload the page
  545. 25:44okay that was fixed and at the moment
  546. 25:47I'm authorized however if I log out
  547. 25:50and then open
  548. 25:52one of the posts scroll down below type
  549. 25:55comment and then type submit I'm
  550. 25:59redirected to the login page and this is
  551. 26:01exactly what I wanted now I'm going to
  552. 26:03try to log in
  553. 26:04I'm going to click on the articles
  554. 26:08and let's also
  555. 26:12let's also have a look if the comment is
  556. 26:14created so comment equals comment create
  557. 26:17but let's dump and die
  558. 26:21this comment and have a look
  559. 26:24I'm going to close this
  560. 26:27test comment click on submit
  561. 26:32and I guess the comment is created so
  562. 26:34let's check the database
  563. 26:37we see comments table inside there
  564. 26:39there's one comment with the text
  565. 26:41comment awesome so we have just created
  566. 26:43comment now we need to update the view
  567. 26:48and start iterating and rendering
  568. 26:50comments so I'm going to click this
  569. 26:52submit comment a few times to create
  570. 26:54multiple comments with um
  571. 26:57with at the moment with the same text
  572. 26:59but that's fine
  573. 27:02okay now let's go and comment create
  574. 27:06I'm going to actually remove
  575. 27:10this comment
  576. 27:12I don't need that
  577. 27:14and let's go now in the comments
  578. 27:18actually let's go in the comments
  579. 27:20component
  580. 27:22and right here we are going to select
  581. 27:26all the comments active comments in pass
  582. 27:29it down to the comments and right here
  583. 27:31we need to iterate and then render each
  584. 27:34individual comment
  585. 27:35so we can do this in the render so
  586. 27:38comments equals comment
  587. 27:42where
  588. 27:45host ID
  589. 27:47equals to this post ID
  590. 27:53and we need to call get well probably we
  591. 27:57even need to call
  592. 28:00paginate because if there are too many
  593. 28:02comments
  594. 28:04not all of them should be displayed
  595. 28:08like okay let's start step by step I'm
  596. 28:11going to call get and I'm going to query
  597. 28:12all of them so we have all the comments
  598. 28:15and I'm going to pass it to
  599. 28:18comments
  600. 28:20blade file so right here I have comments
  601. 28:23now let's start iterating our comments
  602. 28:27is comment
  603. 28:30and then I'm going to use a live wire
  604. 28:33comment item component and pass it
  605. 28:38comment to be base comment
  606. 28:41now we need to open
  607. 28:43comment item component
  608. 28:46and we need mount
  609. 28:50here public function
  610. 28:53oblique function Mount and we are going
  611. 28:56to accept
  612. 28:58uh comment here
  613. 29:02let's save this in
  614. 29:04public
  615. 29:06comment
  616. 29:10like this
  617. 29:12comment equals even comment
  618. 29:16now this comment is already available in
  619. 29:18the comment item so now let's open
  620. 29:21comment item
  621. 29:23and here let's just output comment which
  622. 29:27is a model
  623. 29:29and second comment which is an actual
  624. 29:31column name
  625. 29:33so I save this now reload the page
  626. 29:35scroll down below and we see comment one
  627. 29:38comment two common three and so on so we
  628. 29:41have all the comments available
  629. 29:43so now I need some kind of inspiration
  630. 29:45what information I can display for each
  631. 29:49comment so comments section and let's go
  632. 29:53in the images
  633. 29:55okay let's click one of those like we
  634. 29:58need username user Avatar username the
  635. 30:02time when that happened
  636. 30:06we don't have upvote downward at the
  637. 30:08moment so we can skip that we have reply
  638. 30:12so I think that's it
  639. 30:13that's all what we can do and all all
  640. 30:16the templates will give us roughly the
  641. 30:19same type of structure
  642. 30:22so let's create one div
  643. 30:25uh which will have display of flex
  644. 30:29inside there 1D which will be for the
  645. 30:32authorized user Avatar something like
  646. 30:35this
  647. 30:36we don't actually have Avatar management
  648. 30:39but yeah we can leave this as it is
  649. 30:41right now so it's going to be a dam
  650. 30:43image whatever
  651. 30:45and the second will be an actual
  652. 30:49um comment text
  653. 30:52okay
  654. 30:54so this is Avatar then we have div
  655. 30:58inside the div the first
  656. 31:02div will be
  657. 31:05the username
  658. 31:07the comment user name author of this
  659. 31:11comment basically like John Smith let's
  660. 31:15type like this
  661. 31:17and inside there we're going to also
  662. 31:19have so we can make this like a link
  663. 31:22with a hashtag at the moment we don't
  664. 31:25have the user's own page so we can just
  665. 31:28type John Smith there and then we also
  666. 31:31need the time when the comment was
  667. 31:34actually made so let's use comment
  668. 31:38comment uh created it
  669. 31:42let's output like this and we can change
  670. 31:44this into
  671. 31:46relative format maybe later
  672. 31:51then down below we have
  673. 31:53div which contains the whole comment
  674. 31:57actual content
  675. 31:59like this
  676. 32:01okay and down below we can have reply
  677. 32:05button
  678. 32:07here let's create another div
  679. 32:10let's create a with href and reply
  680. 32:19okay
  681. 32:22that's good let's save this and have a
  682. 32:24look so I have John Smith
  683. 32:27uh the reply is
  684. 32:31in a wrong place
  685. 32:34this one has display Flex
  686. 32:39I see
  687. 32:41and this reply should be right here
  688. 32:46okay John Smith so this needs to have a
  689. 32:50different styles like text blue
  690. 32:54or what color do we use
  691. 32:57like in our comment create component we
  692. 33:01use
  693. 33:04Indigo 600 so we can use the same style
  694. 33:08in the comment item
  695. 33:12indigo 600.
  696. 33:15not ring but text indigo 600.
  697. 33:19okay we can even make font semi Bolt
  698. 33:28okay good we don't have Avatar at the
  699. 33:31moment which is which is okay we can
  700. 33:33leave this
  701. 33:35then we specify
  702. 33:38here as well replying is to have text
  703. 33:41Indigo 600
  704. 33:45we obviously need margin bottom three
  705. 33:50maybe even
  706. 33:52or
  707. 33:54as for the avatar
  708. 33:57we can grab the hero icon
  709. 34:01user at the moment
  710. 34:06get it
  711. 34:07and I'm going to put this here
  712. 34:10this is our icon
  713. 34:13and this div will have with a W 16 8
  714. 34:2116.
  715. 34:24let's give it also legs
  716. 34:27items Center
  717. 34:29justify Center and BG Gray 100.
  718. 34:36that's probably too much maybe reduce it
  719. 34:38into 12.
  720. 34:43PG grade 200 and give it rounded
  721. 34:46a rounded full
  722. 34:51okay and let's give this one get three
  723. 34:56okay here we have at the moment this is
  724. 34:58dummy Avatar but uh later of course this
  725. 35:01can be implemented we have space for
  726. 35:03that
  727. 35:04this reply let's give it text
  728. 35:08small
  729. 35:12perfect and this comment let's give it
  730. 35:16text Gray 700
  731. 35:22so it's a great comment I'm going to
  732. 35:24remove this and type lorem lorem ipsum
  733. 35:27to see just how big text look like and
  734. 35:30this is good
  735. 35:32this is good
  736. 35:35okay perfect let's return
  737. 35:40comment and obviously if the comment is
  738. 35:43made by Me by the user who is actually
  739. 35:46looking at this we need a delete and
  740. 35:49edit buttons as well so right here
  741. 35:53I can
  742. 35:55put two
  743. 35:57two more elements
  744. 36:00this will be delete
  745. 36:03this will be edit
  746. 36:06for edit excuse me
  747. 36:10edit for edit we can use like blue color
  748. 36:14for delete we can use red color
  749. 36:19okay good let's put
  750. 36:21uh let's put asterisk maybe here or some
  751. 36:25Dot
  752. 36:27oh no it's not good idea
  753. 36:34or we can just put two extra margins
  754. 36:38like margin left or margin right three
  755. 36:43okay all of them is created by me so
  756. 36:46that's why I I should see them but if
  757. 36:49the user is not me so basically let's
  758. 36:52use if
  759. 36:54comment
  760. 36:56user
  761. 36:59comment user ID if that is not the same
  762. 37:03as the authorized user ID like
  763. 37:06um
  764. 37:08I'm going to use auth facade ID
  765. 37:14if the ID is not the same
  766. 37:18now if it is the same as comment user ID
  767. 37:21then we display edit and delete
  768. 37:25and if let's format the code and now
  769. 37:29let's have a look so I see everything if
  770. 37:31I copy this and open in incognito mode
  771. 37:35I don't see edit and delete which is
  772. 37:39good now I want to display them
  773. 37:43these dates in a human readable format
  774. 37:46so I think carbon supports that so if I
  775. 37:50use carbon
  776. 37:55um
  777. 37:56well the comment created is actually
  778. 37:58already an instance of carbon isn't it
  779. 38:01so if I just call method
  780. 38:04here
  781. 38:05diff
  782. 38:08or humans I think this is the method
  783. 38:11name so if I call this
  784. 38:13and have a look here I see these 12
  785. 38:16minutes ago fantastic
  786. 38:20okay so I have that I think I should put
  787. 38:24this in a span and give it like gray
  788. 38:27color
  789. 38:28text Gray 500 maybe
  790. 38:35okay
  791. 38:37it's perfect that's perfect
  792. 38:40okay now the thing is that when I leave
  793. 38:42a comment test comment
  794. 38:47when I click submit
  795. 38:49uh I should be able to see this comments
  796. 38:52immediately
  797. 38:54uh probably at the top and even this
  798. 38:57section should be probably at the very
  799. 38:59top so
  800. 39:01let's take care of this
  801. 39:04in the comment section first I'm going
  802. 39:06to have the leave a comments box and
  803. 39:10then other comments so that this will be
  804. 39:13at the very top
  805. 39:14these create comment
  806. 39:18let's give this one
  807. 39:20margin button or something like this
  808. 39:25we have a extra white space
  809. 39:28and the thing is that whenever the
  810. 39:30comment is created we need to tell the
  811. 39:32parents to re-render its children
  812. 39:36so if I just reload the page
  813. 39:39these common test comment is at the very
  814. 39:41bottom also
  815. 39:43the comments needs to be sorted by
  816. 39:45descending so when I select comments
  817. 39:47right here we can specify order by disk
  818. 39:54created it
  819. 39:56save reload the page and we see my
  820. 39:59latest comment is at the very top again
  821. 40:01let's type a new comment here and click
  822. 40:06submit
  823. 40:07and if I reload the page I see new
  824. 40:09comment right here so I'm going to open
  825. 40:11this comment create and whenever the
  826. 40:13comment is created instead of damping I
  827. 40:16want to call I want to emit
  828. 40:19now aim it up tell the parent that
  829. 40:22comment created
  830. 40:26so this is the event and I can also pass
  831. 40:29a comment that was created
  832. 40:33not this comment but the actual comment
  833. 40:36that was created
  834. 40:38now I'm going to open comments class
  835. 40:41right here and I will need event
  836. 40:45listeners here
  837. 40:48I believe it's called event list let's
  838. 40:51create public array event listeners
  839. 41:01and right here I'm going to define the
  840. 41:04event name comment created and the
  841. 41:07actual function in this case let's call
  842. 41:11the function the same name comment
  843. 41:13created
  844. 41:14this should be probably listeners yeah
  845. 41:17and we can remove this and we can make
  846. 41:19this protected it should be protect it
  847. 41:21by default
  848. 41:22okay so we have render Mount and at the
  849. 41:25very bottom I'm going to add this
  850. 41:28function public function comment created
  851. 41:31and we're going to accept the comment
  852. 41:34right here
  853. 41:35and let me actually now die dump and die
  854. 41:39from here just one two three okay so if
  855. 41:41the code comes right here this means
  856. 41:43that our event Works successfully
  857. 41:47so I save this and let's have a look
  858. 41:52test comment
  859. 41:54click on submit okay we see one two
  860. 41:56three so our comments actually works and
  861. 41:59now this render how this render how we
  862. 42:04tell how we should tell the a lot of
  863. 42:06Live Wire to call this render method
  864. 42:09let's usually remove this because it
  865. 42:11might even do this automatically
  866. 42:14like a new comment one let's click
  867. 42:19submit
  868. 42:21and something happened
  869. 42:25okay let's leave new comment too
  870. 42:29okay nothing happened so what we can do
  871. 42:32is
  872. 42:35create here
  873. 42:37public
  874. 42:39comments which can be an array
  875. 42:42of comments like this
  876. 42:45so now in Mount we can select these
  877. 42:48comments
  878. 42:50these comments equals
  879. 42:53this
  880. 42:55okay so we select the comments and we
  881. 42:58don't need to pass those comments from
  882. 43:00here because they are public properties
  883. 43:02they will be available in the blade
  884. 43:04however whenever comment is created what
  885. 43:08we can do is get this comment which by
  886. 43:11the way should be an instance of comment
  887. 43:12and this
  888. 43:15comments equals we need to put this new
  889. 43:20comment
  890. 43:22right here
  891. 43:23and then we can of course
  892. 43:26provide other comments as well
  893. 43:31like this I'm sure like I hope this will
  894. 43:35work so let's see
  895. 43:37uh okay so this is a collection
  896. 43:42okay we can first remove this
  897. 43:46or maybe we can provide this collection
  898. 43:48so this is eloquent collection so we can
  899. 43:51provide comments needs to be a
  900. 43:55collection
  901. 43:57um
  902. 43:58database eloquent collection
  903. 44:01like this and now because this is a
  904. 44:04collection maybe this has like a merge
  905. 44:07or something like this or I can even use
  906. 44:10array merge
  907. 44:14or array concut
  908. 44:18let's use or emerge
  909. 44:21I'm going to provide my comment new
  910. 44:24comment and this
  911. 44:26comments
  912. 44:30I save that
  913. 44:32and let's see
  914. 44:35okay so we scroll down below new coming
  915. 44:38to now let's create new comment three
  916. 44:41click on submit
  917. 44:44array to string conversion
  918. 44:48where did that happen
  919. 44:53array to string conversion and we don't
  920. 44:56have
  921. 44:58to have the exact file
  922. 45:00where this happened
  923. 45:08I don't find that
  924. 45:12and probably
  925. 45:15something is wrong here so if we just
  926. 45:19run execute the same query when the
  927. 45:22comment is added
  928. 45:25like this
  929. 45:26and by the way
  930. 45:28um this 4 is too much maybe two will be
  931. 45:31good
  932. 45:33okay
  933. 45:34new comment
  934. 45:37or and click submit
  935. 45:40okay area to string conversion
  936. 45:43where does this happen
  937. 45:45let's check the comments component
  938. 45:55okay in this case we don't do anything
  939. 46:01if we comment this line
  940. 46:06new comment five
  941. 46:10okay we still get this
  942. 46:16not sure where it comes from
  943. 46:23so I think the actual problem is coming
  944. 46:25from the comment Creator we're passing
  945. 46:27here modal so if we just change this and
  946. 46:32pass comment ID instead of the model and
  947. 46:35if you go in the comment section and I'm
  948. 46:37going to accept integer right here ID
  949. 46:40then I can select the comment based on
  950. 46:43the ID but in this case I'm going to
  951. 46:45just select everything and have a look
  952. 46:47if that works a new comment
  953. 46:51uh six and click submit
  954. 46:54okay something happened
  955. 46:58okay we see new common six right here
  956. 47:00new comment
  957. 47:02seven
  958. 47:07okay where's new common seven
  959. 47:11it's slightly changes the ordering I
  960. 47:16think
  961. 47:20paste comments
  962. 47:26this appears at the top of this
  963. 47:34which looks like to be the first one
  964. 47:38okay if I try to get the comment
  965. 47:43comment where
  966. 47:49ID equals
  967. 47:51this one
  968. 47:53and get simply first
  969. 47:57then I can call array merge
  970. 48:01past the comment and this
  971. 48:06comments
  972. 48:09and we are going to have a look
  973. 48:11new comment eight click on submit
  974. 48:18okay
  975. 48:19here we need to put this in the
  976. 48:23array square brackets
  977. 48:26new comment nine click on submit
  978. 48:34okay I want to merge collection
  979. 48:39I'm going to look for these laravel
  980. 48:41merge collections
  981. 48:46sure there will be
  982. 48:48something let's search for merge
  983. 48:51you see that
  984. 48:53I can create
  985. 48:55or um I won't concat Maybe
  986. 48:58yes I won't concat so I'm going to
  987. 49:01create a collection and then concat with
  988. 49:03the previous one so here I have comment
  989. 49:06I'm going to call collect
  990. 49:10on
  991. 49:11comment
  992. 49:13and then
  993. 49:15on this
  994. 49:16call concat with these comments
  995. 49:24okay let's have a look
  996. 49:27new comment pane
  997. 49:30click on submit
  998. 49:33okay
  999. 49:34um can't assign collection to property
  1000. 49:36comments of type
  1001. 49:42well let's remove this type
  1002. 49:47new comment 11.
  1003. 49:52well it works but I don't know why why
  1004. 49:5611 record
  1005. 50:00is not anywhere here
  1006. 50:06we need to check
  1007. 50:09how many
  1008. 50:11records are there in the comments so in
  1009. 50:14the database at the moment we have 20
  1010. 50:16comments
  1011. 50:17if I just add like 12 click submit
  1012. 50:22we see 21.
  1013. 50:25the first one
  1014. 50:28I should have attributes the first one
  1015. 50:31is actually 12.
  1016. 50:41okay that's probably related to some
  1017. 50:44kind of indexing caching issues so
  1018. 50:48basically the collection is successfully
  1019. 50:50updated but on the front end it is not
  1020. 50:53updated successfully
  1021. 50:56so if I just try this once again
  1022. 51:00okay
  1023. 51:01there must be a solution for that now
  1024. 51:04live wire
  1025. 51:06Live Wire
  1026. 51:08um
  1027. 51:08Loop index something like this
  1028. 51:13um
  1029. 51:14Loop
  1030. 51:16index Loop
  1031. 51:21key something like this like there's
  1032. 51:24these problems in alpine.js if you don't
  1033. 51:28provide eight wire key to elements
  1034. 51:30inside Loops wire key it must be it a
  1035. 51:34search for wire key
  1036. 51:37here it goes so if we open this
  1037. 51:43comment item
  1038. 51:45and add wire
  1039. 51:48e here and it's going to be
  1040. 51:53comment
  1041. 51:55ID
  1042. 51:56we can even prefix like comments Dash
  1043. 51:59comment ID now we need to have a look
  1044. 52:02I'm adding 14
  1045. 52:06still not working
  1046. 52:11okay let's search for
  1047. 52:14maybe we need to do this note here
  1048. 52:18but in the comments
  1049. 52:23maybe here
  1050. 52:25wire key equals let's paste it
  1051. 52:32comment ID is this correct syntax
  1052. 52:37yeah I think so
  1053. 52:40okay let's check this one last time
  1054. 52:42hopefully it's gonna work and it worked
  1055. 52:45yeah that was the problem so now I can
  1056. 52:48add 16
  1057. 52:49it's
  1058. 52:51attempt to read property ID on array
  1059. 52:58okay what was that okay
  1060. 53:03comment ozere
  1061. 53:08okay that's range
  1062. 53:11why was that array I'll just double
  1063. 53:13check this 17 submit that worked
  1064. 53:18I try now 18
  1065. 53:21submit and we got this error
  1066. 53:24okay so let's actually print
  1067. 53:27what is
  1068. 53:30comment and I'm going to comment this
  1069. 53:31line
  1070. 53:34here we see
  1071. 53:3618. now let's print
  1072. 53:3919. it's there now let's print 20
  1073. 53:46something is wrong
  1074. 53:48I don't see 20 here
  1075. 53:56give me to one type of string array
  1076. 53:59given
  1077. 54:00so I think the problem is right here
  1078. 54:03when we convert these array of comments
  1079. 54:07into a collection and then concatenate
  1080. 54:09this with these comments so if we just
  1081. 54:12change this into probably a prepaid
  1082. 54:16method like we have these comments which
  1083. 54:21on which I'm going to call prepend pass
  1084. 54:25selected comment
  1085. 54:27and have a look
  1086. 54:29so I'm going to provide 30 here
  1087. 54:32that was added 31
  1088. 54:34that was added 32 and so on so that
  1089. 54:38works it successfully Works
  1090. 54:41um which is which is excellent now
  1091. 54:43whenever the comment is added I want to
  1092. 54:46remove the focus as well as the clear
  1093. 54:48the model so that should be slightly
  1094. 54:51easier in the comment create I want to
  1095. 54:58uh whenever we emit after VM it's let's
  1096. 55:00set this comment equals an empty string
  1097. 55:05and that will make this text area empty
  1098. 55:09however we're going to also set the
  1099. 55:12focus to be false
  1100. 55:16now we need to listen to that comment
  1101. 55:18created event on the component and
  1102. 55:21basically set the focus to be false so I
  1103. 55:24think we can do this using uh by
  1104. 55:27listening to that comment created event
  1105. 55:30right here so I'm going to use comment
  1106. 55:34or how should we do this like geeks on
  1107. 55:37comment created
  1108. 55:40I'm not sure if this is going to work
  1109. 55:42but we're going to double check and then
  1110. 55:45when this happens I'm going to set
  1111. 55:46focused
  1112. 55:48equals false
  1113. 55:52so we save that
  1114. 55:54and have a look
  1115. 55:56test one
  1116. 55:59okay the model it didn't work the model
  1117. 56:02got empty
  1118. 56:03but the focused one said maybe we need
  1119. 56:07to listen on a window
  1120. 56:11comment create is the name proper name
  1121. 56:15here we have this comment created now
  1122. 56:18let's check this once again
  1123. 56:20test two click on submit
  1124. 56:24that doesn't work
  1125. 56:32well I guess I can use wire
  1126. 56:35keyword here like I'm going to Define
  1127. 56:38init which will be called whenever the
  1128. 56:41component is initialized and we can type
  1129. 56:43constant log
  1130. 56:45init called
  1131. 56:48let's let's check this let's open the
  1132. 56:51browser I'm going to move this on the
  1133. 56:53right side
  1134. 56:55and we're seeing it called
  1135. 56:57and we can also access wire keyword
  1136. 57:03wire and then listen on the event like
  1137. 57:07comment created and whenever this
  1138. 57:10happens
  1139. 57:12we can call our callback function and
  1140. 57:14set this
  1141. 57:16focused equals false I guess
  1142. 57:21let's have a look
  1143. 57:23we don't see any error which is good
  1144. 57:27let's actually type console.log whenever
  1145. 57:30comment is created
  1146. 57:36and let's leave test three submit okay
  1147. 57:40here we go that worked so comment
  1148. 57:43created the cancel Summit buttons were
  1149. 57:45disappeared we see test three now let's
  1150. 57:48add test 4.
  1151. 57:51okay perfect
  1152. 57:53now let's open comment item and we are
  1153. 57:56always outputting John Smith right here
  1154. 57:58we need to access to the user right
  1155. 58:02that's going to be comment the comment
  1156. 58:05doesn't have relationship to the user so
  1157. 58:07we're going to open comment.php and
  1158. 58:10we're going to add
  1159. 58:12public function user here return this
  1160. 58:17belongs to
  1161. 58:22user
  1162. 58:24class and let's define the return type
  1163. 58:31I'm going to move this up right here so
  1164. 58:33now comment has access to user so
  1165. 58:36comment user
  1166. 58:39name let's see what this will print we
  1167. 58:42see admin so basically every comment is
  1168. 58:45at the moment made by admin
  1169. 58:48okay so that's good so far so good at
  1170. 58:51the moment we print all the comments we
  1171. 58:52can add pagination or load more later
  1172. 58:55but we can leave this right now
  1173. 58:57we're going to implement delete and edit
  1174. 59:00as well let's test this once again like
  1175. 59:02test five click on submit and that was
  1176. 59:05created perfect so we need to implement
  1177. 59:07now delete edit and reply on those
  1178. 59:10comments let's start with very simple
  1179. 59:12delete
  1180. 59:13here we have this delete button I'm
  1181. 59:15going to add wire click
  1182. 59:20delete
  1183. 59:22delete comment
  1184. 59:25now let's open comment item component
  1185. 59:30and let's create public function delete
  1186. 59:33comment
  1187. 59:34and here we have access to the comment
  1188. 59:38so we just need to execute these comment
  1189. 59:44equals not equals simply we're going to
  1190. 59:47call delete
  1191. 59:49but we need to also Aim It event to the
  1192. 59:52parent that comment was deleted in list
  1193. 59:55needs to be updated it needs to be
  1194. 59:57removed from the list
  1195. 1:00:00so let's call this
  1196. 1:00:04emit app
  1197. 1:00:06comment deleted
  1198. 1:00:08and we're going to pass this
  1199. 1:00:11comment
  1200. 1:00:13ID
  1201. 1:00:15well let's take the ID
  1202. 1:00:19equals this comment ID before I delete
  1203. 1:00:23and then I pass it
  1204. 1:00:28now let's open comments component
  1205. 1:00:34comments component
  1206. 1:00:37and here just like I have the comment
  1207. 1:00:40created I'm going to duplicate this
  1208. 1:00:41comment deleted
  1209. 1:00:43let's create this function comment
  1210. 1:00:46deleted we accept
  1211. 1:00:49ID here and we need to remove that
  1212. 1:00:52comment with this ID from the collection
  1213. 1:00:56of comments
  1214. 1:00:59okay let's have a look at the collection
  1215. 1:01:02methods like is there any remove
  1216. 1:01:07okay this removes an item from The
  1217. 1:01:10Collection by its key
  1218. 1:01:13okay can we call something like this
  1219. 1:01:17comments
  1220. 1:01:20pool and provide ID
  1221. 1:01:23now we cannot do this because key is an
  1222. 1:01:26index not ID
  1223. 1:01:28okay reject
  1224. 1:01:32filters collection
  1225. 1:01:35using the given closure the closure
  1226. 1:01:37should return true if the item should be
  1227. 1:01:39removed from the resulting collection so
  1228. 1:01:42we can use reject in this case
  1229. 1:01:47this
  1230. 1:01:49comments reject we get right here the
  1231. 1:01:53actual comment
  1232. 1:01:55it should not be an INT it's a comment
  1233. 1:01:57and we are checking if the comment
  1234. 1:02:01if the comment ID is the same
  1235. 1:02:06as the given ID which we are going to
  1236. 1:02:10use here
  1237. 1:02:12so then we are rejecting that comment so
  1238. 1:02:15finally we're going to have filtered
  1239. 1:02:17comments and this comments which has the
  1240. 1:02:20same ID will be removed from this
  1241. 1:02:22comments
  1242. 1:02:24comments collection so let's remove this
  1243. 1:02:26key and let's test this I'm going to
  1244. 1:02:30delete these tests four click right here
  1245. 1:02:32okay we need to prevent
  1246. 1:02:35uh when to prevent
  1247. 1:02:39default
  1248. 1:02:41click prevent
  1249. 1:02:44that should work
  1250. 1:02:48that was deleted by the way so let's
  1251. 1:02:50click delete on test three that was
  1252. 1:02:54deleted Test 2 date was deleted okay so
  1253. 1:02:58just like this we are deleting if you
  1254. 1:03:00want of course you can add additional
  1255. 1:03:03like live wire
  1256. 1:03:05or JavaScript alert right here are you
  1257. 1:03:08sure you want to delete that and if the
  1258. 1:03:10user proceeds then we can you can
  1259. 1:03:13actually proceed and delete that
  1260. 1:03:16okay so I'm Gonna Leave This as it is
  1261. 1:03:18now and let's click on let's Implement
  1262. 1:03:21editing of the comments so whenever we
  1263. 1:03:25click edit we want in the same place
  1264. 1:03:28probably right here the
  1265. 1:03:32inputs to be displayed so that user can
  1266. 1:03:34edit that and then submit and cancel
  1267. 1:03:36buttons will be right there as well
  1268. 1:03:40now let's start working on two edit
  1269. 1:03:43comments whenever we click edit button
  1270. 1:03:45it really jumps at the top because we
  1271. 1:03:47have hashtag right there deleting
  1272. 1:03:50is already implemented so let's open
  1273. 1:03:53post item blade and let's have a look so
  1274. 1:03:58this is post uh sorry we want comment
  1275. 1:04:02item
  1276. 1:04:04and at the very bottom we have this edit
  1277. 1:04:06button so just like we are listening to
  1278. 1:04:10the click of the delete button using
  1279. 1:04:12Live Wire I'm going to listen to click
  1280. 1:04:16and call prevent as well right here and
  1281. 1:04:19I'm going to call method start comment
  1282. 1:04:22edit
  1283. 1:04:24now let's open comment item class and at
  1284. 1:04:29the very top I'm going to define a
  1285. 1:04:30Boolean property
  1286. 1:04:32editing which by default will be false
  1287. 1:04:37okay and down below let's define the
  1288. 1:04:40function start a comment edit whenever
  1289. 1:04:43this method is called editing will
  1290. 1:04:45become true
  1291. 1:04:47right so in the comment item now we have
  1292. 1:04:50this editing flag available and this is
  1293. 1:04:53where actual text is outputted common
  1294. 1:04:56text but if we are in editing mode we
  1295. 1:04:59need to do it slightly differently like
  1296. 1:05:02if
  1297. 1:05:04if editing
  1298. 1:05:08then we need to do something else
  1299. 1:05:10in else case we render the comment again
  1300. 1:05:13and then we have end if
  1301. 1:05:17okay what do we need to do here so we
  1302. 1:05:19need to
  1303. 1:05:21we need to render the similar inputs
  1304. 1:05:24like we have here we can create new
  1305. 1:05:27input but I'm going to try to reuse an
  1306. 1:05:30existing comment create component if we
  1307. 1:05:33open now comment create which is uh
  1308. 1:05:36created at the moment for just creating
  1309. 1:05:40a comment
  1310. 1:05:41when to we can customize this a little
  1311. 1:05:44bit I'm going to also open comment
  1312. 1:05:48create class here all right now in
  1313. 1:05:51comment item I will try to use that
  1314. 1:05:54component Live Wire
  1315. 1:05:56comment slash create okay if we are in
  1316. 1:06:01editing mode we need to render this
  1317. 1:06:03input
  1318. 1:06:04okay now when I click edit we see this
  1319. 1:06:07input field we are in editing mode but
  1320. 1:06:10we have some extra work obviously first
  1321. 1:06:12we need to load the actual value which
  1322. 1:06:16is written right here inside this text
  1323. 1:06:18area
  1324. 1:06:21also we want to trigger like a click so
  1325. 1:06:24that submittent cancel buttons are
  1326. 1:06:26immediately visible whenever we click
  1327. 1:06:28this edit so how to do this in this
  1328. 1:06:31comment create we can in the mount we
  1329. 1:06:34can accept one additional argument which
  1330. 1:06:37will be the modal comment model so
  1331. 1:06:40basically if we are editing we can
  1332. 1:06:43accept this model I'm going to call this
  1333. 1:06:46um
  1334. 1:06:47let's call this comment model by default
  1335. 1:06:50it's going to be now so let's the
  1336. 1:06:52comment creation will not be broken and
  1337. 1:06:56then this
  1338. 1:06:58um okay I'm going to Define also modal
  1339. 1:07:01here public
  1340. 1:07:03comment
  1341. 1:07:05comment modal equals null and let's
  1342. 1:07:09specify question mark here as well so we
  1343. 1:07:12Define comment modal equals to received
  1344. 1:07:16comment model and we're going to also
  1345. 1:07:18check if the comment model has comment
  1346. 1:07:22inside there or if it is if it exists so
  1347. 1:07:26let's do like this
  1348. 1:07:27of this comment which is an actual text
  1349. 1:07:30which needs to be displayed in the text
  1350. 1:07:32area this text will equal if the comment
  1351. 1:07:36model exists then it's going to be
  1352. 1:07:38comment model comment
  1353. 1:07:40so if that exists we are editing and we
  1354. 1:07:44are taking from this model the comment
  1355. 1:07:47column data otherwise we take it empty
  1356. 1:07:51so if I say this already and reload the
  1357. 1:07:54page and click on this
  1358. 1:07:57um I expected to see
  1359. 1:08:00the comment or loaded right here I know
  1360. 1:08:03why I don't see because we don't pass a
  1361. 1:08:05comment model so let's specify comment
  1362. 1:08:07model from here and there's going to be
  1363. 1:08:10current model
  1364. 1:08:12so we're going to pass comment as a
  1365. 1:08:14model
  1366. 1:08:15then when we click edit we see 30 loaded
  1367. 1:08:19inside okay now whenever we click edit
  1368. 1:08:22we won't immediately submit and cancel
  1369. 1:08:24buttons to be visible okay how we are
  1370. 1:08:28going to do that in the comment create
  1371. 1:08:30we display those buttons If focused is
  1372. 1:08:34set to true so we probably need to
  1373. 1:08:38define a new variable like is edit
  1374. 1:08:42variable so if we are editing we want
  1375. 1:08:45those buttons to be always visible so if
  1376. 1:08:48we are in edit mode
  1377. 1:08:50the inside this comment create now we
  1378. 1:08:53have access to this comment model
  1379. 1:08:55okay and we it might be null or it might
  1380. 1:08:58be object so we need to check if comment
  1381. 1:09:01model exists we are going to Output true
  1382. 1:09:04in the JavaScript otherwise we're going
  1383. 1:09:07to Output false so pay attention
  1384. 1:09:10that I'm using right here true or false
  1385. 1:09:12as a string because this portion needs
  1386. 1:09:17to be replaced whatever we are
  1387. 1:09:18outputting true or false and if it needs
  1388. 1:09:21to be true simply this will be replaced
  1389. 1:09:23with true and this is exactly what I
  1390. 1:09:25want
  1391. 1:09:27so now whenever this is edit we if it's
  1392. 1:09:32either focused or edit let's do like
  1393. 1:09:34this if is edit or Focus then we display
  1394. 1:09:39it if it's edit or focused then the
  1395. 1:09:43number of rows will be two okay we do
  1396. 1:09:46like this now let's reload the page and
  1397. 1:09:49click edit and now we immediately see
  1398. 1:09:51buttons as well as this 30 number Okay
  1399. 1:09:56small thing on the submit I'm going to
  1400. 1:09:58give it margin write 3
  1401. 1:10:02to have a small margin between this
  1402. 1:10:04cancel and submit and also I want cursor
  1403. 1:10:08to be inside the text area whenever I
  1404. 1:10:11click edit
  1405. 1:10:12so I'm going to listen inside the init
  1406. 1:10:15basically this is triggered every time
  1407. 1:10:18the component is created I'm going to
  1408. 1:10:20check if this
  1409. 1:10:22is edit
  1410. 1:10:24then I'm going to call a focus method on
  1411. 1:10:27the text area but I'm going to specify
  1412. 1:10:30xref on the text area this is alpine.js
  1413. 1:10:33to basically Define a name for that
  1414. 1:10:38text area component let's give it input
  1415. 1:10:41and then these refs input Focus
  1416. 1:10:46will do the rest
  1417. 1:10:48so now click edit and we're focused
  1418. 1:10:52inside the text area and we can start
  1419. 1:10:53editing now whenever we click cancel we
  1420. 1:10:57need to hide everything so let's have a
  1421. 1:11:00look in the cancel button here we have
  1422. 1:11:02that so now whenever we click cancel
  1423. 1:11:05nothing happens let's check also
  1424. 1:11:08developer tools if we have some errors
  1425. 1:11:10we know it's about it immediately
  1426. 1:11:13focused equals four so we need to set is
  1427. 1:11:16edit
  1428. 1:11:19to be false as well
  1429. 1:11:22whenever we click cancel
  1430. 1:11:24okay now edit and cancel
  1431. 1:11:28and buttons disappear but we still see
  1432. 1:11:30these input and that happens because
  1433. 1:11:33comment item is still in editing mode
  1434. 1:11:38right so whenever we click this cancel
  1435. 1:11:42button
  1436. 1:11:44we need to also aim it events to the
  1437. 1:11:46parent so I'm going to call wire
  1438. 1:11:50aim it up and let's call this event
  1439. 1:11:53cancel editing so I'm telling the parent
  1440. 1:11:57component that hey I'm just canceling
  1441. 1:11:59the editing this happens from the
  1442. 1:12:01comment create component which is used
  1443. 1:12:04right here so this component will
  1444. 1:12:05trigger cancel editing and now inside
  1445. 1:12:09that component comment item component we
  1446. 1:12:12can listen to that event let's define
  1447. 1:12:15listeners right here
  1448. 1:12:17on cancel editing we can call a function
  1449. 1:12:19called cancel editing and at the very
  1450. 1:12:22bottom
  1451. 1:12:23we Define this cancel editing this
  1452. 1:12:27editing equals false
  1453. 1:12:30now let's have a look I click edit we
  1454. 1:12:34are in the editing mode I type some
  1455. 1:12:36characters then I click cancel
  1456. 1:12:39and let's have a look
  1457. 1:12:42or I didn't expect
  1458. 1:12:44this still to be visible let's reload
  1459. 1:12:47the page
  1460. 1:12:48type something click cancel and this is
  1461. 1:12:51exactly yeah so I just needed to reload
  1462. 1:12:53the page so click edit type something
  1463. 1:12:56click cancel and it goes back to its
  1464. 1:12:59original value
  1465. 1:13:01that's perfect but now let's handle
  1466. 1:13:03update whenever we click on submit
  1467. 1:13:06button what needs to be done that
  1468. 1:13:08happens in in the comment create
  1469. 1:13:10so now
  1470. 1:13:12the comment create comment will be
  1471. 1:13:14called and simply we need to check
  1472. 1:13:18if this comment model exists it means
  1473. 1:13:21that we are in edit mode
  1474. 1:13:24else
  1475. 1:13:25we are in create mode so the code what
  1476. 1:13:28we have here so far will go in else but
  1477. 1:13:32in in if we need to do the following so
  1478. 1:13:36this comment model
  1479. 1:13:39comment will be this comment and this
  1480. 1:13:44comment will be text area text then on
  1481. 1:13:47this
  1482. 1:13:48comment model I'm going to call Save
  1483. 1:13:51which will save changes in the database
  1484. 1:13:53I'm going to also set this
  1485. 1:13:57this
  1486. 1:13:58comment to be an empty string
  1487. 1:14:01and I will also tell the parent that
  1488. 1:14:04editing is basically finished or like we
  1489. 1:14:07are emitting comment created we need to
  1490. 1:14:10do something similar like comment
  1491. 1:14:11updated so this
  1492. 1:14:14Aim It Up
  1493. 1:14:17comment updated okay I'm not going to
  1494. 1:14:20pass any arguments that's going to be
  1495. 1:14:22enough we are doing this comment updated
  1496. 1:14:24from the comment create which is used
  1497. 1:14:27inside this comment item so in the
  1498. 1:14:30comment item I'm gonna listen to comment
  1499. 1:14:34updated
  1500. 1:14:37and whenever this happens
  1501. 1:14:39I'm going to Define new function
  1502. 1:14:41whenever this happens I'm going to set
  1503. 1:14:44editing to be false like this so I save
  1504. 1:14:49and reload click edit click cancel that
  1505. 1:14:53works magically and now let's give it
  1506. 1:14:55updated so I'm going to click submit and
  1507. 1:14:58that was update now if I reload the page
  1508. 1:15:01it is there it is updated it is perfect
  1509. 1:15:04okay so far so good however one extra
  1510. 1:15:08security step will be right here to
  1511. 1:15:13check if that specific model is owned by
  1512. 1:15:17current user
  1513. 1:15:20I'm going to do this right here if this
  1514. 1:15:23model exists and maybe
  1515. 1:15:28um by the way this if user exists we can
  1516. 1:15:31move this up
  1517. 1:15:33if user doesn't exist we redirect user
  1518. 1:15:36to log in now at this moment we know
  1519. 1:15:38that comment model exists and the user
  1520. 1:15:40exists so we're going to check
  1521. 1:15:42and this
  1522. 1:15:44comment model user ID if that equals or
  1523. 1:15:50let's do like this
  1524. 1:15:52inside the comment model
  1525. 1:15:54I'm going to write additional if
  1526. 1:15:56statement if the comment model user ID
  1527. 1:15:59does not equal it's something different
  1528. 1:16:02from the currently authorized user's ID
  1529. 1:16:06I'm going to throw new like forbidden
  1530. 1:16:09exception or
  1531. 1:16:11um
  1532. 1:16:13I can't throw Source I'm going to Simply
  1533. 1:16:16return Maybe
  1534. 1:16:17a response
  1535. 1:16:21and status code
  1536. 1:16:24403
  1537. 1:16:29I think in the response we can also
  1538. 1:16:31Define I'm going to return
  1539. 1:16:33you are not allowed to perform this
  1540. 1:16:38action
  1541. 1:16:39like this and the status code will be
  1542. 1:16:41403 Forbidden
  1543. 1:16:43so I can test this from the interface
  1544. 1:16:47unless I make a JavaScript Ajax request
  1545. 1:16:51and exactly this is what we are doing
  1546. 1:16:54preventing others from sending
  1547. 1:16:58incorrect inappropriate requests and we
  1548. 1:17:00need to do the same check by the way
  1549. 1:17:02when we are about to delete comment so
  1550. 1:17:07in the comment item
  1551. 1:17:10are right here
  1552. 1:17:12we need to check
  1553. 1:17:15if comment user ID is different from the
  1554. 1:17:20currently authorized user's ID so let's
  1555. 1:17:22get this user from here and by the way
  1556. 1:17:24here we also need to check if the user
  1557. 1:17:26doesn't exist in someone somehow makes a
  1558. 1:17:29delete request
  1559. 1:17:31it should not happen basically so if the
  1560. 1:17:35let's move this down as well
  1561. 1:17:40okay so first we check if the user
  1562. 1:17:43doesn't exist we were direct user to log
  1563. 1:17:44in then if the comment user ID is
  1564. 1:17:46different from the user ID then we
  1565. 1:17:48return the following response on delete
  1566. 1:17:50so extra security step now we have
  1567. 1:17:54deleting of commands which works
  1568. 1:17:56successfully new comment right here
  1569. 1:18:00here we go we can edit this comments
  1570. 1:18:04and it is edit now we need to take care
  1571. 1:18:07of replying comments
  1572. 1:18:10now let's start working on replying on
  1573. 1:18:13comments first of all we're going to
  1574. 1:18:15Define
  1575. 1:18:16pointy parent ID on the comments because
  1576. 1:18:19we haven't defined this
  1577. 1:18:21I'm going to create new migration
  1578. 1:18:25PHP artisan make migration add parent ID
  1579. 1:18:34on comments table
  1580. 1:18:38okay let's open now
  1581. 1:18:40add parent ID
  1582. 1:18:43on comments table
  1583. 1:18:45here we go
  1584. 1:18:47on
  1585. 1:18:54so we need to accept the schema
  1586. 1:18:58like
  1587. 1:19:02like we're doing
  1588. 1:19:05so I'm going to grab this
  1589. 1:19:09let's define own comments table we
  1590. 1:19:13Define
  1591. 1:19:15foreign ID
  1592. 1:19:18parent ID
  1593. 1:19:21and that is nullable
  1594. 1:19:23and that has constrained on comments
  1595. 1:19:28table
  1596. 1:19:29all right and we need to drop that ink
  1597. 1:19:34down as well
  1598. 1:19:36drop column parent ID
  1599. 1:19:39we haven't defined this show so that's
  1600. 1:19:42why we need that and now I'm going to
  1601. 1:19:44open also comment PHP model
  1602. 1:19:47and Define this parent ID right here so
  1603. 1:19:50at the moment we I decided to only allow
  1604. 1:19:53two level of comments so we're gonna
  1605. 1:19:56have like the root level comments in the
  1606. 1:19:59child we are not going to have
  1607. 1:20:00grandchildren of the parent and so on so
  1608. 1:20:03there will be only two level of comments
  1609. 1:20:05and in this case this parent ID will be
  1610. 1:20:07absolutely enough but generally if you
  1611. 1:20:10want to have a very nested
  1612. 1:20:13tree type of data you should probably
  1613. 1:20:16consider something like nested nested
  1614. 1:20:19set model or similar thing okay so in
  1615. 1:20:24this case that's going to be fine
  1616. 1:20:26so we have the parent ideally Supply
  1617. 1:20:28migration PHP Artisan migrate
  1618. 1:20:33here we go
  1619. 1:20:35and now let's open post item
  1620. 1:20:39uh sorry comment item plate and we need
  1621. 1:20:44to listen to this reply wire
  1622. 1:20:49click
  1623. 1:20:51prevent
  1624. 1:20:53start reply
  1625. 1:20:56and that's it start reply now let's open
  1626. 1:20:59comment
  1627. 1:21:01item class as well
  1628. 1:21:03and down below let's create public
  1629. 1:21:05function
  1630. 1:21:07start reply
  1631. 1:21:09okay let's define a flag like similar to
  1632. 1:21:13editing what we have
  1633. 1:21:15public Boolean
  1634. 1:21:18replying
  1635. 1:21:20equals by default this is false
  1636. 1:21:24but whenever we call start replying I'm
  1637. 1:21:28going to set this uh replying equals
  1638. 1:21:32true
  1639. 1:21:34all right now whenever user clicks that
  1640. 1:21:37we need to display
  1641. 1:21:40this type of
  1642. 1:21:41component
  1643. 1:21:43but as a child
  1644. 1:21:46of this component and we also later need
  1645. 1:21:49to handle the case rendering child child
  1646. 1:21:54comments but how do we need to do so I'm
  1647. 1:21:57going to grab these so we are adding
  1648. 1:21:59actually new
  1649. 1:22:01a new comment
  1650. 1:22:03so what I'm going to do down below
  1651. 1:22:06probably here I'm just going to paste
  1652. 1:22:08this and remove these comments this is
  1653. 1:22:10absolutely new comment
  1654. 1:22:12so let's have a look
  1655. 1:22:14let's have a look what happens
  1656. 1:22:16we see this probably not ideal place let
  1657. 1:22:21me have a look so this is the div
  1658. 1:22:24this is the image
  1659. 1:22:26and then this is okay we need to put
  1660. 1:22:28this at the very bottom right here
  1661. 1:22:33save it now let's have a look
  1662. 1:22:37not ideal again and now I'm gonna put
  1663. 1:22:42this
  1664. 1:22:43right here at the very bottom of this
  1665. 1:22:47div
  1666. 1:22:49that should be good
  1667. 1:22:52okay
  1668. 1:22:54so that's actually not bad we always see
  1669. 1:22:57these I'll leave a comments which should
  1670. 1:22:59have a different placeholder which we
  1671. 1:23:01can do no problem
  1672. 1:23:03whenever I click on this it's going to
  1673. 1:23:05expand it whenever I type something it's
  1674. 1:23:07going to save the only thing what we
  1675. 1:23:10should probably do that this input
  1676. 1:23:12should not be rendered unless we click
  1677. 1:23:14this reply
  1678. 1:23:16so what I'm going to do is
  1679. 1:23:19if
  1680. 1:23:21replying is true then we render
  1681. 1:23:27and if then we render this Live Wire
  1682. 1:23:30command create
  1683. 1:23:31now we don't see as soon as I click this
  1684. 1:23:34reply then I see this leave a comment
  1685. 1:23:37and also we should trigger like the
  1686. 1:23:40focus on that as well
  1687. 1:23:44okay let's go in the let's close the
  1688. 1:23:48migration and model
  1689. 1:23:51this one as well and let's open comment
  1690. 1:23:54create
  1691. 1:23:57and also comment slash create blade file
  1692. 1:24:03so the text area and the buttons is only
  1693. 1:24:05visible if it is in edit mode or if
  1694. 1:24:08focused is true
  1695. 1:24:12what if we
  1696. 1:24:13what if we set focused equals true
  1697. 1:24:18based on whether it's a reply or not
  1698. 1:24:23so
  1699. 1:24:24in the comment create
  1700. 1:24:28I'm going to
  1701. 1:24:33I'm going to define a flag let me think
  1702. 1:24:35I'm thinking so I'm going to define a
  1703. 1:24:38flag called
  1704. 1:24:39replying equals false by default
  1705. 1:24:44then I'm going to accept right here
  1706. 1:24:47Boolean variable replying
  1707. 1:24:51which by default equals false
  1708. 1:24:53and I'm going to set
  1709. 1:24:55this replying equals replying
  1710. 1:25:02now let me take this replying and right
  1711. 1:25:06here
  1712. 1:25:07I'm going to Define so if at the moment
  1713. 1:25:11user is replying
  1714. 1:25:14to some comment
  1715. 1:25:15then we set this to be true otherwise we
  1716. 1:25:19set this to false
  1717. 1:25:21so by default it's going to be false
  1718. 1:25:24when I click then this will appear
  1719. 1:25:27however if I click reply we need to pass
  1720. 1:25:31those replying flag
  1721. 1:25:34so from the comment item right here we
  1722. 1:25:37need to pass
  1723. 1:25:39replying equals true so this is actually
  1724. 1:25:42a reply
  1725. 1:25:45while replying is probably
  1726. 1:25:49not ideal name so I will call it reply
  1727. 1:25:54just reply
  1728. 1:25:56like this
  1729. 1:25:58rip
  1730. 1:26:00l y
  1731. 1:26:03here we go let's do this
  1732. 1:26:06okay perfect and from the comment item
  1733. 1:26:09I'm going to also specify reply true and
  1734. 1:26:12then in the comment create I'm going to
  1735. 1:26:15specify reply true okay let's check this
  1736. 1:26:19perfect I click on reply and look at
  1737. 1:26:22this so now we already have a submit and
  1738. 1:26:26cancel buttons visible so because this
  1739. 1:26:28Focus was already set to be true and
  1740. 1:26:33we can also do the same thing like we
  1741. 1:26:37are doing here if this is edit or
  1742. 1:26:42um
  1743. 1:26:42this is focused then we run a focus not
  1744. 1:26:48sure what this will do when we focus so
  1745. 1:26:52basically when we are focusing uh this
  1746. 1:26:54image is not code so that's perfect
  1747. 1:26:57that's perfect so whenever we click
  1748. 1:27:00reply then it's automatically focused
  1749. 1:27:04and now let's take care of saving the
  1750. 1:27:07comment
  1751. 1:27:08if it is reply also in the comment item
  1752. 1:27:11we have to provide a parent comment
  1753. 1:27:15right so in the comment create
  1754. 1:27:19we need
  1755. 1:27:21one additional
  1756. 1:27:23one additional variable
  1757. 1:27:26let's call this parent comment
  1758. 1:27:30equals
  1759. 1:27:32here in comment equals a null by default
  1760. 1:27:40okay
  1761. 1:27:43peer and comments equals null I'm going
  1762. 1:27:45to Define this peer and comment here as
  1763. 1:27:47well
  1764. 1:27:52and I'm also thinking that
  1765. 1:27:55maybe we don't even need this reply
  1766. 1:28:00because whenever we pass peer and
  1767. 1:28:01comment it automatically means that we
  1768. 1:28:04are replying to something because we
  1769. 1:28:05have parents
  1770. 1:28:07okay let me try to remove this reply so
  1771. 1:28:09I'm going to take these peer and comment
  1772. 1:28:11in this parent comments equals parent
  1773. 1:28:14comment so we don't need reply let's try
  1774. 1:28:17to remove it from here and from here as
  1775. 1:28:19well
  1776. 1:28:20I'm going to remove it from here as well
  1777. 1:28:22but instead I'm going to use
  1778. 1:28:24adherent comment so if Peer and comment
  1779. 1:28:27exists
  1780. 1:28:29then focused true otherwise false in the
  1781. 1:28:33comment item instead of passing reply
  1782. 1:28:35I'm going to pass parent
  1783. 1:28:38Dash comment equals
  1784. 1:28:42the current comment
  1785. 1:28:44which we can access from anywhere in
  1786. 1:28:47this component
  1787. 1:28:48now let's double check this so
  1788. 1:28:51everything works so far previously
  1789. 1:28:53as it was working previously now click
  1790. 1:28:56reply and we're in the focus mode which
  1791. 1:28:58is excellent now I type something and
  1792. 1:29:01whenever I click submit which is inside
  1793. 1:29:03the comment create
  1794. 1:29:06here
  1795. 1:29:07let's first take care of this creation
  1796. 1:29:10so here we need to check
  1797. 1:29:12basically I can do like this
  1798. 1:29:16hearing ID
  1799. 1:29:18equals these here in comments question
  1800. 1:29:22mark Arrow ID so if this parent comment
  1801. 1:29:25exists it's going to take its ID if it
  1802. 1:29:27doesn't exist it's going to provide
  1803. 1:29:30um
  1804. 1:29:31it's going to provide a null and then we
  1805. 1:29:35trigger comment create and I have
  1806. 1:29:37question now where this comment new
  1807. 1:29:39comment will appear
  1808. 1:29:41I think it will appear at the top right
  1809. 1:29:44here because we don't
  1810. 1:29:45we don't render it as a tree okay I'm
  1811. 1:29:49going to click let's just reload and
  1812. 1:29:51click reply and type something and click
  1813. 1:29:54submit
  1814. 1:29:56okay we have another
  1815. 1:29:57let's see
  1816. 1:30:01uh Integrity consumer okay compost ID
  1817. 1:30:03cannot okay post ID cannot be null we
  1818. 1:30:06don't provide post right so we have to
  1819. 1:30:09provide post here and that will be
  1820. 1:30:11comment
  1821. 1:30:13post
  1822. 1:30:15by the way comment I think doesn't have
  1823. 1:30:17relation to post so let's open comment
  1824. 1:30:19dot PHP
  1825. 1:30:22let's duplicate these
  1826. 1:30:26post belongs to post
  1827. 1:30:30okay this is perfect
  1828. 1:30:34now let's just rule the page click reply
  1829. 1:30:37something
  1830. 1:30:39and click submit and this is exactly
  1831. 1:30:42what I was expecting so the new comment
  1832. 1:30:43was created it appeared at the very top
  1833. 1:30:46this is something when to handle second
  1834. 1:30:48is that this leave a comment needs to be
  1835. 1:30:51hidden
  1836. 1:30:52so in the comment create
  1837. 1:30:55when the comment is actually created and
  1838. 1:30:59that comment create is called from the
  1839. 1:31:01comment item from here
  1840. 1:31:03so in the comment item
  1841. 1:31:06let's open comment item we have
  1842. 1:31:08listeners
  1843. 1:31:10editing and update so I'm going to
  1844. 1:31:13duplicate this line and add one more
  1845. 1:31:15listener which will be comment created
  1846. 1:31:18so if the comment created function is
  1847. 1:31:21called on the comment item it definitely
  1848. 1:31:25means that we are creating child comment
  1849. 1:31:28if comment created is triggered from
  1850. 1:31:30here
  1851. 1:31:31this component has nothing related to
  1852. 1:31:34comment item right but this component is
  1853. 1:31:38inside the comment Act now whenever
  1854. 1:31:41comment created is triggered and this
  1855. 1:31:43function is called in the comment item
  1856. 1:31:44we are sure that a child comment it was
  1857. 1:31:48just created
  1858. 1:31:49so what we need to do
  1859. 1:31:52is first set this replying to be false
  1860. 1:31:59let's do like this
  1861. 1:32:01and this will basically hide the
  1862. 1:32:05hide the input completely Let's test
  1863. 1:32:08this so far test click submit okay that
  1864. 1:32:11was hidden and now the parent component
  1865. 1:32:14which is a comments component needs to
  1866. 1:32:18handle rendering the comments properly
  1867. 1:32:21all right let's check comments table
  1868. 1:32:27and have a look we have parent ID on two
  1869. 1:32:31comments
  1870. 1:32:32excellent now let's open comments dot
  1871. 1:32:35PHP
  1872. 1:32:37here we are selecting the comments
  1873. 1:32:41on Mount
  1874. 1:32:43okay I'm going to extract this in its
  1875. 1:32:46own function called select comments
  1876. 1:32:51like this and we have the select
  1877. 1:32:53comments at the very very bottom
  1878. 1:32:57right here
  1879. 1:33:00okay and I'm gonna do
  1880. 1:33:03now the following so the comment
  1881. 1:33:07uh whenever we are iterating and
  1882. 1:33:09rendering comments we use couple of
  1883. 1:33:11things we use comment post so we need
  1884. 1:33:14with
  1885. 1:33:16post we are using also comment user so
  1886. 1:33:20we need user as well user single user
  1887. 1:33:24now let's open comment model and we also
  1888. 1:33:27need
  1889. 1:33:28child comments
  1890. 1:33:30so the comment basically has comments as
  1891. 1:33:34well and that will be has many
  1892. 1:33:38okay and how is it related so comment
  1893. 1:33:43class by the foreign key will be
  1894. 1:33:48by parent ID
  1895. 1:33:52I think that should be like this so
  1896. 1:33:54let's just remove this belongs tool it's
  1897. 1:33:56not accurate and let's just return
  1898. 1:33:59his menu
  1899. 1:34:02but we also need belongs to which will
  1900. 1:34:05be peer and comment
  1901. 1:34:07I'm not sure whether we need this or not
  1902. 1:34:09but let's just Define parent comment
  1903. 1:34:14and this is belongs to belongs
  1904. 1:34:20to
  1905. 1:34:23belongs to
  1906. 1:34:25yeah so it should be this will be
  1907. 1:34:28belongs to comment by the foreign key
  1908. 1:34:32okay not sure if this is 100 correct
  1909. 1:34:35let's see if this works otherwise I can
  1910. 1:34:38double check that so we have comments
  1911. 1:34:40and now in the comment item when we
  1912. 1:34:43iterate
  1913. 1:34:44okay right here I am going to print the
  1914. 1:34:49current comment
  1915. 1:34:51comments which will give me all the
  1916. 1:34:53children comments of the current comment
  1917. 1:34:56let's have a look empty array empty
  1918. 1:34:57array and here I have two comments then
  1919. 1:35:00always I have empty array and this is
  1920. 1:35:02perfect this is exactly what I expected
  1921. 1:35:04now I'm going to open comments dot blade
  1922. 1:35:09and I can simply grab this code and put
  1923. 1:35:12this right here
  1924. 1:35:15but change only these comments instead
  1925. 1:35:18of these comments it's going to be
  1926. 1:35:19comment
  1927. 1:35:21comments
  1928. 1:35:22and here also we can call this child
  1929. 1:35:27comment
  1930. 1:35:29all right now we're gonna pass these
  1931. 1:35:31child comment here and we're going to
  1932. 1:35:34also use child comment ID here
  1933. 1:35:36now let's have a look
  1934. 1:35:39I'm already so excited because we're
  1935. 1:35:42very close to final things so here we
  1936. 1:35:44have those comments
  1937. 1:35:46I think we need some kind of
  1938. 1:35:49uh like a margin padding things like
  1939. 1:35:53that so I'm gonna put everything in its
  1940. 1:35:56own div
  1941. 1:35:58and let me actually first check
  1942. 1:36:01um if comments
  1943. 1:36:05effects exists if that's not empty
  1944. 1:36:08basically then we call and if
  1945. 1:36:12and let's give this one margin top
  1946. 1:36:16four maybe
  1947. 1:36:21uh okay so we need to check if that's
  1948. 1:36:24not empty
  1949. 1:36:25I thought that whenever you check these
  1950. 1:36:28like in PHP I think when you check
  1951. 1:36:29common comments if this is an empty
  1952. 1:36:32array it's a falsible value and it will
  1953. 1:36:35not render this code but I think this is
  1954. 1:36:38rendering because for this there is no
  1955. 1:36:41comment actually but here we see this is
  1956. 1:36:44still the empty div so if not empty
  1957. 1:36:53then
  1958. 1:36:57okay e okay okay okay let's have a look
  1959. 1:37:00this is probably collection and that's
  1960. 1:37:02why it always satisfies so because this
  1961. 1:37:05is a collection it should probably have
  1962. 1:37:07like size Maybe
  1963. 1:37:10okay it doesn't have size let's check
  1964. 1:37:13size or length
  1965. 1:37:20okay
  1966. 1:37:22I want to get the length of the
  1967. 1:37:24collection or count maybe you should
  1968. 1:37:27probably have count
  1969. 1:37:32let's see
  1970. 1:37:34okay yes it has count
  1971. 1:37:36and now these comments are child
  1972. 1:37:39comments of these comments
  1973. 1:37:41perfect so if I click reply now this
  1974. 1:37:44appears right here
  1975. 1:37:46another comment is written
  1976. 1:37:50let's see click submit
  1977. 1:37:54that another comment
  1978. 1:37:57okay this is interesting another comment
  1979. 1:38:00goes right here and right here
  1980. 1:38:04that happens because
  1981. 1:38:08this let's first see why it happens
  1982. 1:38:13I'm going to open comments I think I
  1983. 1:38:15don't have these comments dot PHP
  1984. 1:38:18okay here here it goes no
  1985. 1:38:22comment created here it goes so
  1986. 1:38:24basically when the new comment is
  1987. 1:38:25created it is edited at the very top of
  1988. 1:38:27existing comments so that's why the new
  1989. 1:38:30comment went right there then that
  1990. 1:38:32caused re-rendering of this Live Wire
  1991. 1:38:35component and during render phase we get
  1992. 1:38:39the current comment comments and that's
  1993. 1:38:41why we see the same comment twice added
  1994. 1:38:44here and here as well
  1995. 1:38:46okay let me do minor thing first the
  1996. 1:38:50latest comment should be at the very top
  1997. 1:38:51always if I just reload the page I see
  1998. 1:38:54that this is at the very bottom so if I
  1999. 1:38:56open this comment and this has has many
  2000. 1:38:58now let's specify here order by disk
  2001. 1:39:03uh created it
  2002. 1:39:06underscore it
  2003. 1:39:08reload the page and we see the latest
  2004. 1:39:10comment at the very top
  2005. 1:39:12okay next is to handle the scenario when
  2006. 1:39:16that comment goes in a proper place
  2007. 1:39:21this is this is important
  2008. 1:39:24and that can be done
  2009. 1:39:27through a flag I believe so in the from
  2010. 1:39:31the comment create we emit these
  2011. 1:39:34comment created and we pass this comment
  2012. 1:39:37ID
  2013. 1:39:38in the comment comments PHP we'll listen
  2014. 1:39:43to that that select this comment
  2015. 1:39:46and here we're going to check if the
  2016. 1:39:49comment
  2017. 1:39:51here and ID if that does not exist
  2018. 1:39:55it means that this is a root level
  2019. 1:39:57comment and it needs to be added in this
  2020. 1:40:01array however if this has parent ID it's
  2021. 1:40:05a child comment on something else and we
  2022. 1:40:07should not do anything
  2023. 1:40:09however the Livewire component will be
  2024. 1:40:12re-rendered and then we will see
  2025. 1:40:16then we will see it properly
  2026. 1:40:19let's have a look
  2027. 1:40:21this another comment why it appears
  2028. 1:40:27um
  2029. 1:40:29okay give me a second
  2030. 1:40:32this test is here okay I see now we
  2031. 1:40:36render right here all child and parent
  2032. 1:40:39comments so we need to skip and remove
  2033. 1:40:41child comments so we have these select
  2034. 1:40:45comments and let's add here where
  2035. 1:40:50parent ID
  2036. 1:40:52we are null we are parent IDs now and I
  2037. 1:40:56want to specify comments as well inside
  2038. 1:40:59the with because I want to eagerly load
  2039. 1:41:02post user and comments for every comment
  2040. 1:41:07okay so far so good now let's try to add
  2041. 1:41:10a new comment new comments let's click
  2042. 1:41:14submit
  2043. 1:41:15here we go here we go excellent so new
  2044. 1:41:18comment was added right here let's click
  2045. 1:41:21reply on that which in turn
  2046. 1:41:24creates its own box inside there but I
  2047. 1:41:28think we can even we need to completely
  2048. 1:41:30probably disable that let's see we're
  2049. 1:41:34gonna check also I noticed that when I
  2050. 1:41:37click cancel it still stays in this uh
  2051. 1:41:41the leave a comment still stays let's
  2052. 1:41:43check how when to take care of this
  2053. 1:41:47so here we have this create comment
  2054. 1:41:49which is for
  2055. 1:41:51replying
  2056. 1:41:53and when we click cancel from inside
  2057. 1:41:59where is that comment create
  2058. 1:42:04okay cancel we call cancel editing
  2059. 1:42:09okay and in the comment item
  2060. 1:42:13we listen cancel editing and we set
  2061. 1:42:18editing equals false but we also need to
  2062. 1:42:22set
  2063. 1:42:24replying equals
  2064. 1:42:27replying equals false
  2065. 1:42:32uh let's see so I click reply here that
  2066. 1:42:36appears click cancel that disappears
  2067. 1:42:39here we need to probably completely
  2068. 1:42:41remove reply
  2069. 1:42:45let's check what happens something
  2070. 1:42:48click submit
  2071. 1:42:52okay what is this
  2072. 1:42:57just reload the page and we see this
  2073. 1:43:00nested comment and you know what that
  2074. 1:43:03works out of the box
  2075. 1:43:06that works out of the box well the
  2076. 1:43:09functionality is there and it's working
  2077. 1:43:11which is really good
  2078. 1:43:13however it's not going to be very very
  2079. 1:43:17optimal
  2080. 1:43:18uh like if you install the bug bar and
  2081. 1:43:21have a look it's going to do a lot of
  2082. 1:43:24requests
  2083. 1:43:26to the database
  2084. 1:43:29not sure if this is necessary or not and
  2085. 1:43:32I think we have this functionality and
  2086. 1:43:34we should probably spend a little bit
  2087. 1:43:36more time to optimize it to make a less
  2088. 1:43:38requests
  2089. 1:43:41but also it's we should probably also
  2090. 1:43:44have like pagination display only first
  2091. 1:43:4620 comments and then Implement load more
  2092. 1:43:49so there are a few things to do about
  2093. 1:43:51the functionality is there and it's
  2094. 1:43:54working
  2095. 1:43:56which is really good
  2096. 1:43:58I love it
  2097. 1:44:01yeah the the update works like a charm
  2098. 1:44:03so I'm going to click delete
  2099. 1:44:05and the delete didn't work
  2100. 1:44:08or maybe it worked but uh it wasn't
  2101. 1:44:10re-rendered yes
  2102. 1:44:12so if I click delete here it wasn't
  2103. 1:44:15re-rendered if I click delete here that
  2104. 1:44:19is removed okay I'm going to check
  2105. 1:44:21what's going on when we click delete in
  2106. 1:44:24the comment item
  2107. 1:44:28here we have this delete it aim its
  2108. 1:44:31comment deleted and we probably need to
  2109. 1:44:34listen to comment deleted
  2110. 1:44:40okay what do we do when this happens
  2111. 1:44:45we are listening this inside comments
  2112. 1:44:49and what do we do so we just filter the
  2113. 1:44:54array
  2114. 1:44:56so in this case
  2115. 1:45:02let's just hit delete that's actually
  2116. 1:45:04already deleted okay so when I click
  2117. 1:45:07delete right here
  2118. 1:45:10uh it filters out this list and we have
  2119. 1:45:12new comments
  2120. 1:45:14okay what do we need to do
  2121. 1:45:17is this
  2122. 1:45:21we are going to query the comment based
  2123. 1:45:25on the ID
  2124. 1:45:27and we are going to check
  2125. 1:45:31if
  2126. 1:45:33the comment
  2127. 1:45:38if the comment parent ID
  2128. 1:45:42exists if that doesn't exist then we
  2129. 1:45:45filter and extract just reject the
  2130. 1:45:50comment what was passed
  2131. 1:45:53okay but however if the parent ID is set
  2132. 1:45:57we shouldn't do this if I click delete
  2133. 1:45:59right here
  2134. 1:46:06let's see I'm going to click delete here
  2135. 1:46:11okay attempt to read
  2136. 1:46:16okay I see so it wasn't able to
  2137. 1:46:20uh-huh yeah the comment was deleted and
  2138. 1:46:24we passed ID right here we reject it but
  2139. 1:46:31um but if we just try to select the
  2140. 1:46:33comment that comment doesn't exist
  2141. 1:46:34because we just deleted that comment so
  2142. 1:46:36that was not correct what I did right
  2143. 1:46:39now instead we just can refresh the
  2144. 1:46:42whole comment section or just manually
  2145. 1:46:46remove that comment from the child
  2146. 1:46:49collection of that specific comment
  2147. 1:46:53that is tricky thing so if I just
  2148. 1:46:57revert this
  2149. 1:47:02here
  2150. 1:47:03and we can like keep tracking if the
  2151. 1:47:08comment is
  2152. 1:47:10if the comment was found and if that was
  2153. 1:47:13rejected if it wasn't rejected we will
  2154. 1:47:15assume that it is probably a child
  2155. 1:47:18comment of another comment right and
  2156. 1:47:22then we need to run this reject on a
  2157. 1:47:26child comments
  2158. 1:47:28which in my opinion can be done but it's
  2159. 1:47:32going to be a little bit too complex so
  2160. 1:47:35what I'm thinking right now is I will
  2161. 1:47:37simply execute these select comments
  2162. 1:47:40again
  2163. 1:47:42so now let's have a look we don't have
  2164. 1:47:45any child comments I just click delete
  2165. 1:47:47and now we see the list so now I'm going
  2166. 1:47:50to go ahead and delete those multiple
  2167. 1:47:53comments I don't want all of them okay
  2168. 1:47:56we have you know we have a lot of
  2169. 1:47:58actually
  2170. 1:48:03okay now let's Define child comment of
  2171. 1:48:06this
  2172. 1:48:07child comment one
  2173. 1:48:12let's click submit here we see the child
  2174. 1:48:14comment I reload the page it is there
  2175. 1:48:16I'm going to Define another child
  2176. 1:48:19comment
  2177. 1:48:20uh child comment two click submit we see
  2178. 1:48:24it right here now let's delete the child
  2179. 1:48:26comment too
  2180. 1:48:29well it was deleted I think
  2181. 1:48:33but
  2182. 1:48:35The View was not updated
  2183. 1:48:38click on delete again it was deleted but
  2184. 1:48:40the view was not updated
  2185. 1:48:43okay I'm gonna double check if the code
  2186. 1:48:45comes code execution comes right here
  2187. 1:48:49when the comment is deleted for child
  2188. 1:48:53like when when we delete a root level
  2189. 1:48:55comment definitely code comes right here
  2190. 1:48:57now let's define
  2191. 1:48:59child
  2192. 1:49:01comment one
  2193. 1:49:04click on submit
  2194. 1:49:07child comment two click on submit
  2195. 1:49:11and now I delete this and well the code
  2196. 1:49:17comes here and it's there and there no
  2197. 1:49:20there's no error that's just our dump in
  2198. 1:49:23the die
  2199. 1:49:26okay so these should update the comment
  2200. 1:49:29section it is reselecting the comments
  2201. 1:49:35however it still includes the new
  2202. 1:49:38comments or just a view does not update
  2203. 1:49:41properly
  2204. 1:49:45click on delete
  2205. 1:49:47okay it does not update The View
  2206. 1:49:50okay so what I think we can do here that
  2207. 1:49:54instead of calling this comment deleted
  2208. 1:49:57here we can call refresh which is a live
  2209. 1:50:02wire
  2210. 1:50:03keyword so call it so if I just remove
  2211. 1:50:06this comment deleted completely whenever
  2212. 1:50:10comment is deleted it's going to call
  2213. 1:50:11refresh refresh will obviously do the
  2214. 1:50:15entire like probably Mount as well which
  2215. 1:50:17will select comments and everything so
  2216. 1:50:20it should work
  2217. 1:50:21now let's Define child one
  2218. 1:50:25and let's Define child two submit now
  2219. 1:50:31I'm going to try to delete this
  2220. 1:50:34and it does not do
  2221. 1:50:37the refresh
  2222. 1:50:39is I expected
  2223. 1:50:44no it doesn't refresh
  2224. 1:50:47it does however
  2225. 1:50:50like even if I completely remove this
  2226. 1:50:52comment deleted
  2227. 1:50:55and add
  2228. 1:51:00comment one
  2229. 1:51:04comment two
  2230. 1:51:08comment three
  2231. 1:51:11okay I know I don't have I'm I don't
  2232. 1:51:14listen to delete and if I click on
  2233. 1:51:17delete now it doesn't do anything
  2234. 1:51:20okay so if I add this it's gonna do
  2235. 1:51:23re-refresh
  2236. 1:51:25or refresh so I click on delete and it's
  2237. 1:51:28going to do refresh if I create child
  2238. 1:51:31comment 1 child comment two then if I
  2239. 1:51:34just rule the page entirely and then
  2240. 1:51:36click delete it does not do this refresh
  2241. 1:51:42if I click delete again we're going to
  2242. 1:51:44have an error because that was actually
  2243. 1:51:46already deleted
  2244. 1:51:50hmm
  2245. 1:51:53this is actually strange
  2246. 1:51:59okay what I think maybe maybe eloquent
  2247. 1:52:04um saves all the child comments in its
  2248. 1:52:07own cache like when we select these
  2249. 1:52:10comments
  2250. 1:52:13on Mount basically and let's double
  2251. 1:52:16check by the way if Mount is called on
  2252. 1:52:19refresh
  2253. 1:52:21so I save these
  2254. 1:52:23and now I click delete on this
  2255. 1:52:28okay Mount is not called Mount is called
  2256. 1:52:32right here
  2257. 1:52:36okay I think Simple Solution here and I
  2258. 1:52:39think also correct solution here will be
  2259. 1:52:42to put these comments again in the
  2260. 1:52:45render and every time there's there's
  2261. 1:52:48comment created or deleted this render
  2262. 1:52:51method will be called and it's gonna
  2263. 1:52:53reselect everything and render them
  2264. 1:52:55properly okay I tried to create a kind
  2265. 1:52:58of optimal solution that whenever new
  2266. 1:53:00comment is created we just add this in
  2267. 1:53:02existing comments array and don't select
  2268. 1:53:05entire list of comments but I think uh
  2269. 1:53:09it's fine in in the future we might even
  2270. 1:53:11need to add pagination and display just
  2271. 1:53:1320 comments and then load more so
  2272. 1:53:15selecting 20 comment is not a big deal
  2273. 1:53:18so what I think now is I'm going to grab
  2274. 1:53:21this
  2275. 1:53:21and here I'm going to select the
  2276. 1:53:24comments in the vein I'm going to pass
  2277. 1:53:28these
  2278. 1:53:29comments here I'm going to remove these
  2279. 1:53:32comments array completely and whenever
  2280. 1:53:34comment is created uh I'm gonna call
  2281. 1:53:38also
  2282. 1:53:40refresh
  2283. 1:53:42like this
  2284. 1:53:43whenever comment is created your comment
  2285. 1:53:45is deleted it's going to call refresh
  2286. 1:53:47now let's check how this will work
  2287. 1:53:50reload the page
  2288. 1:53:53test comment
  2289. 1:53:56hit submit it is edit perfect
  2290. 1:54:00another comment
  2291. 1:54:02click submit it is edit right here
  2292. 1:54:04perfect now let's reply one click submit
  2293. 1:54:09it is here two submit it is here now
  2294. 1:54:13let's delete peer and comment first
  2295. 1:54:16that will still eat it another comment
  2296. 1:54:18delete it perfect now let's delete child
  2297. 1:54:20comment
  2298. 1:54:21now it still stays
  2299. 1:54:25come on
  2300. 1:54:29so I'm sure these render is actually
  2301. 1:54:31called so we can double check this
  2302. 1:54:36let's see render is called obviously
  2303. 1:54:39right here so I'm going to comment this
  2304. 1:54:40line
  2305. 1:54:42and reload the page
  2306. 1:54:44and let's add one and add two now I'm
  2307. 1:54:48going to uncomment this and if I delete
  2308. 1:54:51one comment then render is called
  2309. 1:54:56and that should not have this comment
  2310. 1:54:58anymore
  2311. 1:54:59so I'm gonna
  2312. 1:55:01dump
  2313. 1:55:04these comments
  2314. 1:55:06here more specifically I'm going to dump
  2315. 1:55:09the first comment from here
  2316. 1:55:12let's see
  2317. 1:55:17uh hold on
  2318. 1:55:21so I'm going to delete this
  2319. 1:55:25and then I'm going to dump these
  2320. 1:55:27comments and check what is its comments
  2321. 1:55:30property
  2322. 1:55:31so let's click delete here here we go it
  2323. 1:55:35has attributes
  2324. 1:55:37and
  2325. 1:55:39we are interested in
  2326. 1:55:41relations
  2327. 1:55:43comments
  2328. 1:55:45items
  2329. 1:55:47which is obviously
  2330. 1:55:51zero it doesn't have length
  2331. 1:55:54so then this renders the comments
  2332. 1:55:57section
  2333. 1:55:58let's open
  2334. 1:56:01uh comments section comments dot blade
  2335. 1:56:06then comment create and comment item if
  2336. 1:56:09we open now comment item
  2337. 1:56:12here we get the comment
  2338. 1:56:16comments count I'm going to print what
  2339. 1:56:19is the count CH those are the child
  2340. 1:56:23common count
  2341. 1:56:25and those are the actual child comments
  2342. 1:56:27I'm going to also print if there are
  2343. 1:56:30those child comments here
  2344. 1:56:33and maybe I need to
  2345. 1:56:36remove this
  2346. 1:56:39Let's test
  2347. 1:56:41zero child comments fine one there's one
  2348. 1:56:44child comment two there are two children
  2349. 1:56:47comments
  2350. 1:56:49okay these has
  2351. 1:56:51no this is just two okay so far so good
  2352. 1:56:54now I delete these comments
  2353. 1:56:59this is till 2 and this does not change
  2354. 1:57:05okay
  2355. 1:57:08I think it's
  2356. 1:57:09this is related to Live Wire not the
  2357. 1:57:14live wire but still arrival so let's
  2358. 1:57:16search for laravel
  2359. 1:57:19um
  2360. 1:57:21objects
  2361. 1:57:23is cached something like this
  2362. 1:57:30okay I want to basically re reselect the
  2363. 1:57:36laravel
  2364. 1:57:37component
  2365. 1:57:40let me actually make sure that this is
  2366. 1:57:43definitely a problem so that's why here
  2367. 1:57:45I have one comment
  2368. 1:57:47and before I hit the delete button here
  2369. 1:57:49I'm going to take this and print
  2370. 1:57:53comments eight zero
  2371. 1:57:57comments so these will be child comments
  2372. 1:58:01so I save that
  2373. 1:58:04and click on delete
  2374. 1:58:07now this gives me
  2375. 1:58:09collection with items empty
  2376. 1:58:14and I don't see anything there
  2377. 1:58:17which is correct right
  2378. 1:58:21but somehow
  2379. 1:58:25it is not correct
  2380. 1:58:29what about count
  2381. 1:58:31what are the child children common count
  2382. 1:58:34so I'm going to find one
  2383. 1:58:36and two
  2384. 1:58:38now let's delete this one child comment
  2385. 1:58:42count is one which is correct
  2386. 1:58:46reload the page
  2387. 1:58:50now there's one comment
  2388. 1:58:52I uncomment this line and click on
  2389. 1:58:55delete now there's zero comment however
  2390. 1:58:59if I proceed
  2391. 1:59:03if I proceed then it has
  2392. 1:59:09very very very very very strange
  2393. 1:59:14this is a comment
  2394. 1:59:20maybe the component is cached because
  2395. 1:59:24because of this ID
  2396. 1:59:26so the ID does not change
  2397. 1:59:29right
  2398. 1:59:31maybe that is cached and what if I print
  2399. 1:59:35right here comment
  2400. 1:59:40comments common comments okay let's
  2401. 1:59:42print that those are children comments
  2402. 1:59:48okay now there are zero trillion
  2403. 1:59:51comments I'm gonna need one
  2404. 1:59:52here we see one
  2405. 1:59:55let's add one more
  2406. 1:59:58okay here we see that
  2407. 2:00:01now I delete these
  2408. 2:00:04okay here it was changed but not here
  2409. 2:00:08and then I delete this now this cleared
  2410. 2:00:11up
  2411. 2:00:12pay attention
  2412. 2:00:14this still contains
  2413. 2:00:20because the comment ID
  2414. 2:00:23was not properly changed here here is
  2415. 2:00:26the problem
  2416. 2:00:28what if I specify right here e to be
  2417. 2:00:33comments
  2418. 2:00:36comment
  2419. 2:00:40hold on
  2420. 2:00:42comments count
  2421. 2:00:45so the key
  2422. 2:00:47of that specific component
  2423. 2:00:51will be comment the comment ID as well
  2424. 2:00:54as the number of comments this has so if
  2425. 2:00:59it increases or decreases it will force
  2426. 2:01:02the live wire to re-render that specific
  2427. 2:01:07component
  2428. 2:01:10well that's a clever idea but let's see
  2429. 2:01:13if that works in action so I reload the
  2430. 2:01:16page I hit one
  2431. 2:01:17I had two now I delete this and it
  2432. 2:01:22worked
  2433. 2:01:23and it worked
  2434. 2:01:28okay amazing
  2435. 2:01:30and if so far you're watching this and
  2436. 2:01:33you haven't clicked a like button I
  2437. 2:01:35think it's perfect time to pause the
  2438. 2:01:38video hit the like button I will be very
  2439. 2:01:40very thankful
  2440. 2:01:42to you
  2441. 2:01:43okay so now leaving comments as a
  2442. 2:01:46children comment editing that
  2443. 2:01:49deleting that comment
  2444. 2:01:51deleting every comment everything
  2445. 2:01:54basically works perfectly as it it is
  2446. 2:01:57supposed to work
  2447. 2:02:00now I'm going to Define one Global
  2448. 2:02:03search input field and then search
  2449. 2:02:05basically everywhere
  2450. 2:02:09um let's open
  2451. 2:02:11up Blade the main layout file
  2452. 2:02:17and I want to Define this below header
  2453. 2:02:21below top nav
  2454. 2:02:23probably right here inside the container
  2455. 2:02:26so if I just type input
  2456. 2:02:29and this is it
  2457. 2:02:31however I want this to be
  2458. 2:02:34now this has display Flex
  2459. 2:02:38and flex drop which I'm going to remove
  2460. 2:02:40if you don't mind
  2461. 2:02:43okay let's
  2462. 2:02:45that's okay
  2463. 2:02:47and this is the input field which
  2464. 2:02:52which I want to show on the full width
  2465. 2:02:56also the container with this too much
  2466. 2:02:59maybe
  2467. 2:03:00so I want to show this on a full width
  2468. 2:03:03so I'm going to get the input from
  2469. 2:03:08comment create
  2470. 2:03:10comment slash create here we have this
  2471. 2:03:14text area so I'm gonna
  2472. 2:03:16grab that and paste here
  2473. 2:03:19now let's adjust let's remove this fire
  2474. 2:03:22model and click
  2475. 2:03:24let's remove xref
  2476. 2:03:26I'm gonna change this into
  2477. 2:03:30input
  2478. 2:03:31and let's remove rows
  2479. 2:03:36um type
  2480. 2:03:37and hit enter
  2481. 2:03:41to search anything
  2482. 2:03:44so yeah something like this
  2483. 2:03:49okay here we see that it has
  2484. 2:03:53like
  2485. 2:03:55some weird
  2486. 2:03:57styles to be honest
  2487. 2:03:59if you zoom in a lot
  2488. 2:04:03it has two colors
  2489. 2:04:09why does it have those two colors
  2490. 2:04:13if I inspect that
  2491. 2:04:16and right click and focus
  2492. 2:04:20it has also
  2493. 2:04:23active
  2494. 2:04:24what's that
  2495. 2:04:32that's really really really strange
  2496. 2:04:37where does this Blick
  2497. 2:04:42something is coming from
  2498. 2:04:45okay what if I remove this ring gray 300
  2499. 2:04:50but if I remove all those classes
  2500. 2:04:53like everything
  2501. 2:04:56let's see
  2502. 2:04:58we have black
  2503. 2:05:04text Gray 900 fine
  2504. 2:05:08ring gray 300 and when we type inside
  2505. 2:05:14it's gonna have ring integral
  2506. 2:05:18as save this and we see this input
  2507. 2:05:21however again like it's strange
  2508. 2:05:25um I'm not gonna spend too much time on
  2509. 2:05:28this maybe I can remove all the Indigo
  2510. 2:05:31ring classes
  2511. 2:05:35that behaves really strangely for me
  2512. 2:05:40but I'm gonna leave it as it is
  2513. 2:05:44let's give it padding three and I'm
  2514. 2:05:46going to put this inside
  2515. 2:05:48padding three and now whenever I type
  2516. 2:05:52something and hit the enter
  2517. 2:05:55once the search to filter only those
  2518. 2:06:00articles which filter the uh which
  2519. 2:06:03satisfy the following filtering criteria
  2520. 2:06:05okay so let's Implement first
  2521. 2:06:08uh form so I'm going to create form
  2522. 2:06:12inside there we're going to have
  2523. 2:06:15um we don't need button I think but we
  2524. 2:06:18might need so I have a doubt that if you
  2525. 2:06:21don't have a button and you just try to
  2526. 2:06:23submit the form without button it's not
  2527. 2:06:25gonna work
  2528. 2:06:26let's give it method method should be
  2529. 2:06:29get
  2530. 2:06:30action can be current road
  2531. 2:06:33so we just specify
  2532. 2:06:36yeah we can leave this empty actually
  2533. 2:06:38action and now if I let's give this name
  2534. 2:06:43name just Q
  2535. 2:06:47and if I type something like JavaScript
  2536. 2:06:50and hit the enter it filters and we see
  2537. 2:06:53Q JavaScript
  2538. 2:06:55and now we need to
  2539. 2:06:58only match those
  2540. 2:07:00articles which has JavaScript right
  2541. 2:07:02there
  2542. 2:07:04okay but we also need in my opinion like
  2543. 2:07:07a dedicated search page so what I'm
  2544. 2:07:11going to do is open web.php
  2545. 2:07:15and let's define one additional root
  2546. 2:07:18here that's going to be search
  2547. 2:07:21the road will be searched
  2548. 2:07:25this will be search
  2549. 2:07:27so in this case I'm going to specify
  2550. 2:07:29roads
  2551. 2:07:31to be searched
  2552. 2:07:34perfect
  2553. 2:07:37and let's open this home or maybe like
  2554. 2:07:41another one which is by category
  2555. 2:07:45and I'm going to duplicate this
  2556. 2:07:47let's call this search we don't have
  2557. 2:07:50category
  2558. 2:07:51we have request here
  2559. 2:07:57and we're going to get
  2560. 2:07:59a q from request
  2561. 2:08:03um
  2562. 2:08:05get
  2563. 2:08:07Q
  2564. 2:08:10okay and now we need to filter
  2565. 2:08:14the posts which satisfy the following
  2566. 2:08:17criteria and we also need pagination I
  2567. 2:08:21think
  2568. 2:08:23so I'm going to get these posts
  2569. 2:08:32let's remove this join and where we need
  2570. 2:08:36active published order by published it
  2571. 2:08:40but the main thing is that we have to
  2572. 2:08:43specify where
  2573. 2:08:48title
  2574. 2:08:50like
  2575. 2:08:52our given
  2576. 2:08:55you so in this case
  2577. 2:08:59um it should be in
  2578. 2:09:03like this I believe title like this and
  2579. 2:09:07then we pass
  2580. 2:09:09posts
  2581. 2:09:11but I will want to pass this into
  2582. 2:09:14post not post index
  2583. 2:09:18on search for post Index this is it but
  2584. 2:09:21instead I want post search Maybe
  2585. 2:09:25so I'm gonna copy and paste this post
  2586. 2:09:27index and call this search
  2587. 2:09:32okay I'm gonna use
  2588. 2:09:35post search here
  2589. 2:09:38passing the posts
  2590. 2:09:40and we have these post links which
  2591. 2:09:43which is fine which will be the same
  2592. 2:09:45type of next and previous links as we
  2593. 2:09:46had before which is okay
  2594. 2:09:48so the this is a search page we can
  2595. 2:09:52specify like uh Log search meta titles
  2596. 2:09:55I'm going to remove this
  2597. 2:09:58you can specify if you want
  2598. 2:10:01and now we have those posts which I'm
  2599. 2:10:03not going to render
  2600. 2:10:06I'm going to render it slightly
  2601. 2:10:08differently maybe but let's first check
  2602. 2:10:11if the actual searching works like I'm
  2603. 2:10:14going to type JavaScript here hit the
  2604. 2:10:16enter
  2605. 2:10:17and I find variable category
  2606. 2:10:22okay where does it go
  2607. 2:10:28I deleted this from index I had to
  2608. 2:10:31delete this from
  2609. 2:10:32search
  2610. 2:10:36okay whatever is in the URL
  2611. 2:10:40I have to put this in this input field
  2612. 2:10:42as well
  2613. 2:10:44so in the up blade
  2614. 2:10:46I'm going to give this value
  2615. 2:10:50request
  2616. 2:10:54it
  2617. 2:10:55you
  2618. 2:10:58here we see JavaScript if I go on home
  2619. 2:11:00page I don't see anything here
  2620. 2:11:03type JavaScript hit the enter
  2621. 2:11:06and it filters only one post which is
  2622. 2:11:10awesome
  2623. 2:11:11however I'm going to change the
  2624. 2:11:13rendering as I mentioned so instead of
  2625. 2:11:15using post item here
  2626. 2:11:17I'm going to do it a very simple like H2
  2627. 2:11:20that's going to be post
  2628. 2:11:24that's going to be post title
  2629. 2:11:29div we're going to Output
  2630. 2:11:34host
  2631. 2:11:36short body Maybe
  2632. 2:11:39like this
  2633. 2:11:42okay this needs to be
  2634. 2:11:47this needs to be in the not not in the
  2635. 2:11:50center so maybe I can remove these items
  2636. 2:11:53Center not necessary
  2637. 2:11:56that's good and let's specify here
  2638. 2:12:00text blue 500 font pulled
  2639. 2:12:06text LG above small screen it's going to
  2640. 2:12:12be
  2641. 2:12:12text EXO
  2642. 2:12:17okay maybe margin button 2 as well
  2643. 2:12:22but whenever we click on this it needs
  2644. 2:12:25to open its inner page
  2645. 2:12:28so we need to Define
  2646. 2:12:32roads
  2647. 2:12:35or View
  2648. 2:12:37and provide an actual post
  2649. 2:12:42okay so far so good now let's search for
  2650. 2:12:46something like Alice and we see multiple
  2651. 2:12:50Alice let's
  2652. 2:12:53let's remove Flex completely and give
  2653. 2:12:56this margin bottom eight Maybe
  2654. 2:13:02this doesn't seem to be working no I
  2655. 2:13:05should not have specified it here I
  2656. 2:13:08should have wrapped everything in zone
  2657. 2:13:10div and give this one
  2658. 2:13:14class margin button 8.
  2659. 2:13:19we can even use HR
  2660. 2:13:25and completely remove these and give
  2661. 2:13:28this HR class
  2662. 2:13:31a margin vertical four maybe
  2663. 2:13:36that's that's good so now we have this
  2664. 2:13:41which is excellent
  2665. 2:13:43well
  2666. 2:13:45there might be like again I'm going to
  2667. 2:13:48give you a challenge
  2668. 2:13:51right now we see that Ali's keywords are
  2669. 2:13:54matched in many places
  2670. 2:13:57it's going to be awesome if you actually
  2671. 2:13:58highlight
  2672. 2:14:00all the matchings which are there
  2673. 2:14:03and make it like actually actually
  2674. 2:14:06yellow for example so we are about how
  2675. 2:14:10to Output the title here what we can do
  2676. 2:14:14is call Str replace
  2677. 2:14:18on this post title and search for
  2678. 2:14:24search for
  2679. 2:14:26the keyword actual keyword which which
  2680. 2:14:28will be
  2681. 2:14:29request
  2682. 2:14:33request
  2683. 2:14:36get Q
  2684. 2:14:40replace it with something else inside
  2685. 2:14:43here so in this case I'm just replacing
  2686. 2:14:45with the empty string and this should
  2687. 2:14:47remove all the Alice matchings and it
  2688. 2:14:49definitely removed from title but
  2689. 2:14:51instead of
  2690. 2:14:53replacing with empty string you should
  2691. 2:14:55replace it with something like span
  2692. 2:15:00I'm actually doing this but um I'm going
  2693. 2:15:02to give you additional challenge
  2694. 2:15:04right now
  2695. 2:15:06span class
  2696. 2:15:09we're gonna give it
  2697. 2:15:11a PG
  2698. 2:15:13yellow
  2699. 2:15:16400 something like this now let's see
  2700. 2:15:21okay we are going to Output these
  2701. 2:15:26is an HTML I don't remember how to do
  2702. 2:15:31this by heart so laravel output
  2703. 2:15:34HTML
  2704. 2:15:38this is how I should do this yeah
  2705. 2:15:46so I save this and look at this so now
  2706. 2:15:50this is all the matching 400 is maybe
  2707. 2:15:52too much 300
  2708. 2:15:55okay so here are the matchings you can
  2709. 2:15:58easily identify you can do something
  2710. 2:16:00similar in body as well but the point is
  2711. 2:16:04that
  2712. 2:16:05if there is matching in the body it
  2713. 2:16:08might not be in this short body it might
  2714. 2:16:11be in the long body if I open this and
  2715. 2:16:14search for
  2716. 2:16:15like this keyword begin to repeat it
  2717. 2:16:18okay I type this here
  2718. 2:16:21hit the enter
  2719. 2:16:22and it doesn't find anything because we
  2720. 2:16:26don't search actually in the body but we
  2721. 2:16:29have to do this so let's duplicate this
  2722. 2:16:31where or
  2723. 2:16:34where
  2724. 2:16:36I'm going to specify now body like the
  2725. 2:16:39given keyword
  2726. 2:16:40so now if I type the following text hit
  2727. 2:16:43the enter it finds few things but we
  2728. 2:16:47don't see anything in yellow simply
  2729. 2:16:49because
  2730. 2:16:50the matching is outside of this short
  2731. 2:16:52body okay as a challenge and it's pretty
  2732. 2:16:57um like interesting challenge
  2733. 2:16:59you can change what is actually output
  2734. 2:17:02is right here so at the moment we just
  2735. 2:17:05take first like 30 words
  2736. 2:17:08but based on an actual matching
  2737. 2:17:11it is somewhere right here try to Output
  2738. 2:17:14from previous sentence like from here
  2739. 2:17:18to whatever
  2740. 2:17:20here or here so take the highlighted
  2741. 2:17:24section and output that in the search
  2742. 2:17:27instead of the first few sentence first
  2743. 2:17:30few words whatever
  2744. 2:17:34I hope you get the idea and
  2745. 2:17:37yeah
  2746. 2:17:39so let's see if the search actually does
  2747. 2:17:42the job on other pages I want to reduce
  2748. 2:17:44the width of the search just like we
  2749. 2:17:46have this on home page so I'm going to
  2750. 2:17:48open the home and you'll have the max W4
  2751. 2:17:52Excel I'm going to do the same thing
  2752. 2:17:54let's give this Max W and let's give it
  2753. 2:17:58a m x
  2754. 2:18:00Auto
  2755. 2:18:03save reload
  2756. 2:18:05this is how I want that
  2757. 2:18:07and I'm going to type
  2758. 2:18:10again something
  2759. 2:18:12that binds and it is clickable
  2760. 2:18:16okay
  2761. 2:18:18by the way why this is not found are we
  2762. 2:18:22searched for in non-active
  2763. 2:18:29okay yes so this or we're basically is
  2764. 2:18:34or wear for everything else
  2765. 2:18:36so we need
  2766. 2:18:39those two
  2767. 2:18:42those two to be inside
  2768. 2:18:45well I'm going to do like this
  2769. 2:18:48we're
  2770. 2:18:52function we get query
  2771. 2:18:57and then I add like this
  2772. 2:19:05and we need to use the
  2773. 2:19:08queue here
  2774. 2:19:10so where title is like this or what is
  2775. 2:19:14this so now we should not see
  2776. 2:19:18so many well we see so many if I click
  2777. 2:19:22that works click that works
  2778. 2:19:25I guess all of them works so we have
  2779. 2:19:28successfully implemented
  2780. 2:19:31our search and we also have
  2781. 2:19:34those pagination buttons as well
  2782. 2:19:38if I go in the larval page
  2783. 2:19:42I'm looking at the laravel articles I
  2784. 2:19:44can't even start typing from here and
  2785. 2:19:46search for something else which
  2786. 2:19:50should actually filter
  2787. 2:19:54based on the category and then based on
  2788. 2:19:56the keyword as well
  2789. 2:20:00so this is something also to consider so
  2790. 2:20:03if I click on if I'm on a view page
  2791. 2:20:07I probably should not see that
  2792. 2:20:10or if we assume that this is a global
  2793. 2:20:12search
  2794. 2:20:15which by the way I don't like where it
  2795. 2:20:17is right now so I'm thinking maybe I
  2796. 2:20:20need to grab that
  2797. 2:20:21nice form
  2798. 2:20:23and put these
  2799. 2:20:27put these
  2800. 2:20:29hmm
  2801. 2:20:31maybe here
  2802. 2:20:40what if we'll leave it here
  2803. 2:20:45let's give it a Class A font normal
  2804. 2:20:50or medium
  2805. 2:20:56okay I think
  2806. 2:20:58um like I want it to be there
  2807. 2:21:01inside the teeth to be on the right side
  2808. 2:21:04let's give this one
  2809. 2:21:06Flex a line items Center
  2810. 2:21:13now let's search for JavaScript and
  2811. 2:21:15every time now this is this makes more
  2812. 2:21:17sense every time whenever we type
  2813. 2:21:19something here it is in the header and
  2814. 2:21:21that will always redirect us to the
  2815. 2:21:23search page even if you are on laravel
  2816. 2:21:26if even if you are searching for a PHP
  2817. 2:21:28or whatever you type something again and
  2818. 2:21:32you are redirected to the search page so
  2819. 2:21:36that's a global global search on your
  2820. 2:21:39website
  2821. 2:21:47however when you
  2822. 2:21:49click and then go back it's preserved
  2823. 2:21:53okay fine delete functionality works
  2824. 2:21:57now let's deploy our project on
  2825. 2:21:59production environment with custom
  2826. 2:22:01domain when you sign up on hostinger and
  2827. 2:22:04then login you will be redirected to the
  2828. 2:22:06age panel from here we can claim our
  2829. 2:22:09free domain
  2830. 2:22:10you're going to see the following
  2831. 2:22:12section if you signed up with premium
  2832. 2:22:13shared hosting then click this claim
  2833. 2:22:16domain and then right here we need to
  2834. 2:22:18provide our domain name so in this case
  2835. 2:22:20this is going to be like a my personal
  2836. 2:22:22blog type of website so I'm going to
  2837. 2:22:26choose like the code
  2838. 2:22:28holique.net this is I'm sure this is
  2839. 2:22:31going to be free so let's check
  2840. 2:22:32availability so here we go the domain is
  2841. 2:22:35available the codeholic.net that's
  2842. 2:22:37perfect domain for me I already own
  2843. 2:22:39codholic.com by the way if you want to
  2844. 2:22:41check that feel free to check you can
  2845. 2:22:43find laravel e-commerce course right
  2846. 2:22:45there
  2847. 2:22:46now I'm going to click claim domain
  2848. 2:22:49choose your domain carefully because
  2849. 2:22:51like you aren't going to be able to
  2850. 2:22:53change it easily then right here if
  2851. 2:22:55you're doing this very first time you
  2852. 2:22:56have to provide your profile information
  2853. 2:22:58such as your address and email and
  2854. 2:23:01things like that I already have a
  2855. 2:23:03profile existing profile so I'm going to
  2856. 2:23:05just click finish registration
  2857. 2:23:08now it will ask me a few more steps I'm
  2858. 2:23:10going to click continue and here we go
  2859. 2:23:13my domain is already available so I'm
  2860. 2:23:15going to just copy this and open new tab
  2861. 2:23:18hit the enter and you should see the
  2862. 2:23:20following page the code.net happy to see
  2863. 2:23:23your domain with hostinger since we
  2864. 2:23:25claimed our domain now we need to set up
  2865. 2:23:27our web hosting I'm going to click on
  2866. 2:23:30the home logo and then I'm going to
  2867. 2:23:32choose this premium web hosting let's
  2868. 2:23:34click setup start now
  2869. 2:23:37I'm going to skip basically everything I
  2870. 2:23:39want to create everything from scratch
  2871. 2:23:42create new websites so I'm going to
  2872. 2:23:44click skip right here as well so here I
  2873. 2:23:46have option to choose a domain and in
  2874. 2:23:49this case I'm going to choose the
  2875. 2:23:50codeholic.net and I'm going to click
  2876. 2:23:53select now I need to choose a location
  2877. 2:23:55and you can choose a one location from
  2878. 2:23:59like which is probably close to you and
  2879. 2:24:02then I'm going to click finish setup now
  2880. 2:24:04let's scroll down below you will need to
  2881. 2:24:07wait couple of seconds or maybe two
  2882. 2:24:09minutes until the whole process is done
  2883. 2:24:11SSL is going to be installed as well
  2884. 2:24:13automatically and the web server will be
  2885. 2:24:15configured for your domain now I'm going
  2886. 2:24:18to click this Wii U website and it's
  2887. 2:24:20going to open our domain however it is
  2888. 2:24:23still not under SSL so it might take a
  2889. 2:24:26few seconds or minutes
  2890. 2:24:28to make this SSL actually working
  2891. 2:24:31however we can click this manage site
  2892. 2:24:34and check what's the SSL status status
  2893. 2:24:37the very moment this is the control
  2894. 2:24:39panel from which you can manage your
  2895. 2:24:42domain and anything basically related to
  2896. 2:24:45The Domain from here in the search I can
  2897. 2:24:47search for SSL and we can see what's
  2898. 2:24:50this current status of this SSL
  2899. 2:24:53and right now it is in the installing
  2900. 2:24:55process you're going to wait for like a
  2901. 2:24:57two or three minutes until this is fully
  2902. 2:24:59installed if it is failed then you will
  2903. 2:25:01have an action to retry installing that
  2904. 2:25:04sometimes it fails on the first try but
  2905. 2:25:07then it installs without any problem and
  2906. 2:25:09I already got a notification that it was
  2907. 2:25:11successfully installed so if I open my
  2908. 2:25:13domain and just reload I see now my
  2909. 2:25:17domain is under SSL now if we go in this
  2910. 2:25:20control panel right here we have much
  2911. 2:25:22more options I really recommend to check
  2912. 2:25:25that if we're gonna use hot singer's
  2913. 2:25:26premium shared Housing Services because
  2914. 2:25:28they offer huge configuration options
  2915. 2:25:30like what I'm interested right now is to
  2916. 2:25:33switch PHP version to the latest one I'm
  2917. 2:25:36going to click PHP configuration right
  2918. 2:25:38here and then I have couple of options
  2919. 2:25:40and I'm going to choose PHP 8.1 and I'm
  2920. 2:25:44going to click update
  2921. 2:25:46I'm going to confirm now we have
  2922. 2:25:48switched PHP version to 8.1 and now we
  2923. 2:25:52can already log into this server using
  2924. 2:25:54SSH and we can clone our project in
  2925. 2:25:58search I'm going to type SSH click SSH
  2926. 2:26:01access
  2927. 2:26:02here we have the details for our SSH
  2928. 2:26:05server first of all pay attention that
  2929. 2:26:07SSH status is inactive so we need to
  2930. 2:26:10click enable right here then this is the
  2931. 2:26:13IP port username and we need to set
  2932. 2:26:15password I recommend to set very secure
  2933. 2:26:17password
  2934. 2:26:19let's set something
  2935. 2:26:21okay I'm going to click change my stage
  2936. 2:26:25password was saved it is even
  2937. 2:26:27recommended to use public private key
  2938. 2:26:31authentication when connecting to a
  2939. 2:26:34search server so if you know what is
  2940. 2:26:36that and if you have public key
  2941. 2:26:38generated I really encourage you to
  2942. 2:26:40click add SSH key right here provide
  2943. 2:26:42your public key click and add SSH key
  2944. 2:26:45and then you will be authorized to the
  2945. 2:26:47server through SSH now I'm going to copy
  2946. 2:26:50the following command
  2947. 2:26:51and I'm going to open Powershell
  2948. 2:26:56Windows Powershell
  2949. 2:26:58and I'm going to paste the comment right
  2950. 2:27:00here Windows Powershell by default
  2951. 2:27:02supports SSH it's also a sh client if
  2952. 2:27:05you are on Mac or on Linux probably your
  2953. 2:27:08terminal will also support SSH so right
  2954. 2:27:12here I'm trying to execute SSH Common
  2955. 2:27:14with Port this is the username and this
  2956. 2:27:16is the IP let's click enter
  2957. 2:27:20we have to type yes here
  2958. 2:27:22and I'm going to provide now my password
  2959. 2:27:29probably I made a mistake
  2960. 2:27:33okay here's my pass um here's my SSH
  2961. 2:27:36server so I'm inside the server now
  2962. 2:27:39let's let me actually zoom in this
  2963. 2:27:41slightly if I go in the properties and
  2964. 2:27:45font and let's increase that perfect now
  2965. 2:27:49let's enlarge this on full screen and
  2966. 2:27:52now let's have a look
  2967. 2:27:54ls-le so this is it so the the whole
  2968. 2:27:58project what you see in the browser is
  2969. 2:28:00at the moment under public HTML folder
  2970. 2:28:03and that public HTML folder is a
  2971. 2:28:06symbolic link from the following path
  2972. 2:28:09and that path is domains the code
  2973. 2:28:12holic.net public HTML so it's a little
  2974. 2:28:15bit hard to read this until you
  2975. 2:28:18highlight that but that's the actual
  2976. 2:28:20path where the
  2977. 2:28:22HTML what is rendered right here right
  2978. 2:28:27here is used so if I go right here and
  2979. 2:28:31I'm going to delete this the
  2980. 2:28:33codeholic.net completely so let's go
  2981. 2:28:36inside domains folder using CD and I'm
  2982. 2:28:40going to execute
  2983. 2:28:41rm-rf
  2984. 2:28:43the codeholic.net so I completely delete
  2985. 2:28:46this folder and right now
  2986. 2:28:50if I go back
  2987. 2:28:52I have this public HTML which references
  2988. 2:28:55to a broken non-existing folder so that
  2989. 2:28:59public HTML should also be removed and
  2990. 2:29:03now
  2991. 2:29:05and now there is no public HTML if I go
  2992. 2:29:08under domains
  2993. 2:29:11there is nothing as well and if I check
  2994. 2:29:14in the browser
  2995. 2:29:16our website is actually broken okay now
  2996. 2:29:19we need to clone our project let's click
  2997. 2:29:22this code and I'm going to clone this
  2998. 2:29:24through SSH click right here
  2999. 2:29:27let's clear up everything and I'm going
  3000. 2:29:29to clone this
  3001. 2:29:31in a folder called the exact same name
  3002. 2:29:35whatever is your domain okay whatever
  3003. 2:29:37the folder previously existed you're
  3004. 2:29:39going to create the exact same folder
  3005. 2:29:42the code holic.net
  3006. 2:29:46let's hit the enter
  3007. 2:29:48okay that was cloned and if we check
  3008. 2:29:51right now we see the code holy.net right
  3009. 2:29:53here if we go inside the code holy.net
  3010. 2:29:56and type ls-l-a we're going to see all
  3011. 2:30:00the files and folders which are in our
  3012. 2:30:02project now what we need to do is to
  3013. 2:30:05create a symbolic link of public HTML
  3014. 2:30:09which references to these public folder
  3015. 2:30:13all right so I'm going to go back
  3016. 2:30:17to directory so I'm going to go
  3017. 2:30:19basically in my home folder where I
  3018. 2:30:22previously had public HTML and I'm going
  3019. 2:30:25to create reference Ln dash s I'm going
  3020. 2:30:28to create
  3021. 2:30:30um
  3022. 2:30:31domains
  3023. 2:30:32the code holy.net public that is the
  3024. 2:30:36folder
  3025. 2:30:37which I on which I want to create a
  3026. 2:30:40symbolic link called public HTML
  3027. 2:30:44okay let's hit the enter now if I type
  3028. 2:30:47ls-l-a-ic public HTML which references
  3029. 2:30:50to these public folder that public
  3030. 2:30:53folder which is under the code.net is a
  3031. 2:30:56public folder of a lateral project right
  3032. 2:31:00now let's go inside domains
  3033. 2:31:04like hotels.net and we're going to run
  3034. 2:31:07composer install however whenever we
  3035. 2:31:10type composer dash dash version
  3036. 2:31:13we see that this one shows where is it
  3037. 2:31:16version 1.10 and it also prints a lot of
  3038. 2:31:20earnings that's because
  3039. 2:31:22composer version is kind of outdated
  3040. 2:31:25it's deprecated and for lateral
  3041. 2:31:28especially we should be using composer
  3042. 2:31:31version 2. we can't simply use composer
  3043. 2:31:34version one so in the Google I'm going
  3044. 2:31:36to type composer version 2. let's click
  3045. 2:31:41download composer latest right here then
  3046. 2:31:45we're going to copy the following four
  3047. 2:31:47lines
  3048. 2:31:48and paste them right here so it's going
  3049. 2:31:51to basically execute those lines uh one
  3050. 2:31:54after another let's hit enter finally
  3051. 2:31:56and then now in our folder we will see
  3052. 2:32:00composer far that composer far basically
  3053. 2:32:04is the latest version for composer now
  3054. 2:32:07whenever we want to run any composer
  3055. 2:32:10command instead of typing composer like
  3056. 2:32:13this we're going to type composer excuse
  3057. 2:32:17me PHP composer dot far so that
  3058. 2:32:21references a composer and if I type
  3059. 2:32:24version we see version
  3060. 2:32:272.5.15 so now we can execute PHP
  3061. 2:32:31composer far install and let's wait so
  3062. 2:32:35it's going to download all the
  3063. 2:32:36dependencies our project needs and then
  3064. 2:32:39install them locally
  3065. 2:32:42okay that was done now let's generate
  3066. 2:32:44key PHP artisan
  3067. 2:32:48key generate a insi let's
  3068. 2:32:53I think I made some kind of mistake PHP
  3069. 2:32:56Artisan key generator station PSI
  3070. 2:33:00okay so yeah we don't have enable it
  3071. 2:33:03needs to put this in EN so we basically
  3072. 2:33:06need to First create dot en file so
  3073. 2:33:08let's run copy command and I want to
  3074. 2:33:11copy end of example into dot enf okay
  3075. 2:33:15after that we can already execute PHP
  3076. 2:33:18art design key generate and the key set
  3077. 2:33:21successfully which is awesome now let's
  3078. 2:33:23create storage link PHP Artisan storage
  3079. 2:33:27column link let's see the enter storage
  3080. 2:33:30link connected
  3081. 2:33:32and I think we are good we obviously
  3082. 2:33:36need to connect to the database but
  3083. 2:33:38before we do that let's check how our
  3084. 2:33:41domain looks like okay so we have this
  3085. 2:33:44problem again and this happens because
  3086. 2:33:47we also need to have public HTML folder
  3087. 2:33:50in our domain name like in the
  3088. 2:33:54decode.net at the moment we don't have
  3089. 2:33:57public HTML right so let's just create
  3090. 2:34:00Ln
  3091. 2:34:03is public folder needs to be linked into
  3092. 2:34:07public HTML let's hit the enter okay now
  3093. 2:34:11if we check we see public HTML which is
  3094. 2:34:14a symbolic link into public folder and
  3095. 2:34:17now if we check this
  3096. 2:34:19here we go so this is larval error and
  3097. 2:34:22that comes because we don't have
  3098. 2:34:23connection to the database we don't have
  3099. 2:34:25a proper connection and we don't we
  3100. 2:34:28don't have anything related to database
  3101. 2:34:30done yet so let's go in the our hosting
  3102. 2:34:34provider into hostinger and let's
  3103. 2:34:37type database right here let's click
  3104. 2:34:40this is the database we can click page
  3105. 2:34:43my admin or probably we should click
  3106. 2:34:45management and we should create new
  3107. 2:34:47database let's call this laravel 10
  3108. 2:34:51underscore block we have to provide
  3109. 2:34:54username as well and pay attention that
  3110. 2:34:57this is going to be the prefix for your
  3111. 2:34:58database name as well as for username so
  3112. 2:35:01that's the laravel 10 block as for the
  3113. 2:35:04password let's generate some password
  3114. 2:35:06this one and I'm going to copy that and
  3115. 2:35:10let's click create
  3116. 2:35:12awesome now let's go into SSH terminal
  3117. 2:35:17and we are going to edit dot en file
  3118. 2:35:23okay let's scroll down below and here's
  3119. 2:35:25our connection because we are developing
  3120. 2:35:28through sale connection is actually
  3121. 2:35:30MySQL we are going to change this into
  3122. 2:35:33localhost
  3123. 2:35:37um excuse me connection is the driver so
  3124. 2:35:41that should be MySQL but the second
  3125. 2:35:43MySQL which is DB host that needs to be
  3126. 2:35:46changed into localhost Port stays the
  3127. 2:35:50same the database uh well basically we
  3128. 2:35:54created database this is going to be our
  3129. 2:35:57database but because I have password
  3130. 2:35:59already copied first I'm going to delete
  3131. 2:36:02the password and paste the password here
  3132. 2:36:05okay then let's get the username we
  3133. 2:36:09should have it right here as the user
  3134. 2:36:12and I'm gonna paste here and that is
  3135. 2:36:16database let's copy that and paste
  3136. 2:36:20oops right here
  3137. 2:36:24awesome
  3138. 2:36:26awesome let's move up and let's change
  3139. 2:36:29up URL as well and that will be the
  3140. 2:36:35codeholic.net let's specify https as
  3141. 2:36:39well because we have now SSL certificate
  3142. 2:36:41we can change the app name and let's
  3143. 2:36:43call this
  3144. 2:36:45laravel blog but we need to put this in
  3145. 2:36:49double quotations because we used space
  3146. 2:36:51inside the app name
  3147. 2:36:54awesome we can switch this en into
  3148. 2:36:57production but let's make everything
  3149. 2:37:00working
  3150. 2:37:02so save and we're going to execute now
  3151. 2:37:07PHP Artisan migrate
  3152. 2:37:11let's hit enter okay so the connection
  3153. 2:37:13to the database was successfully done
  3154. 2:37:15and migrations have been applied now if
  3155. 2:37:18we check in the browser
  3156. 2:37:20we should see okay what do we see
  3157. 2:37:26post title is not in group by
  3158. 2:37:30all right so that error basically
  3159. 2:37:34happens due to mySQL configuration
  3160. 2:37:37our sale our MySQL configuration which
  3161. 2:37:41was running inside the sale was slightly
  3162. 2:37:44different from the MySQL configuration
  3163. 2:37:47which is on hostinger environment so we
  3164. 2:37:50need to take care of this
  3165. 2:37:53if we just read the error so that
  3166. 2:37:55happens because we are selecting post
  3167. 2:37:58title and we don't have that mentioned
  3168. 2:38:01in the group by again we can change
  3169. 2:38:03MySQL configuration in our hostinger I'm
  3170. 2:38:06not sure if that's possible by the way
  3171. 2:38:08but if that's possible one option is to
  3172. 2:38:11change that second option is to slightly
  3173. 2:38:13modify our query and add this is our
  3174. 2:38:18select
  3175. 2:38:19right here and add Group by post title
  3176. 2:38:24and maybe a few other fields as well
  3177. 2:38:27okay
  3178. 2:38:29I can add post title on my local local
  3179. 2:38:35environment into phpstorm but there
  3180. 2:38:38might be other fields also which might
  3181. 2:38:40be necessary to be added in the group by
  3182. 2:38:42that's why I'm gonna do this directly on
  3183. 2:38:47the server okay I'm going to edit this
  3184. 2:38:49and do it right here we are selecting
  3185. 2:38:52the following Fields like everything
  3186. 2:38:55basically from Posts so if we go into
  3187. 2:38:59phpmyadmin
  3188. 2:39:01and click this enter phpmyadmin we will
  3189. 2:39:04be connected into our deployed projects
  3190. 2:39:08database
  3191. 2:39:13here we can click on posts and see what
  3192. 2:39:16fields we have right right here
  3193. 2:39:20now let's go in our terminal SSH
  3194. 2:39:24terminal and I'm going to edit
  3195. 2:39:27into app
  3196. 2:39:30controllers we need uppercase C
  3197. 2:39:33TRL
  3198. 2:39:35um excuse me up http
  3199. 2:39:39controllers and the error coming from is
  3200. 2:39:44host controller so let's open post
  3201. 2:39:48controller okay we use the veeam so I'm
  3202. 2:39:51going to hit I and let's actually do
  3203. 2:39:54this because I'm doing this right now uh
  3204. 2:39:58on the through the sh client simply
  3205. 2:40:00because I don't know if it might throw
  3206. 2:40:03an error on another field that's why I
  3207. 2:40:06prefer to do this right here but I
  3208. 2:40:08actually cannot read
  3209. 2:40:10what's that
  3210. 2:40:12the color is so blue I cannot read that
  3211. 2:40:21okay can I change the background color
  3212. 2:40:26yeah let's make it gray
  3213. 2:40:29or like blackish something like this
  3214. 2:40:33okay
  3215. 2:40:36yeah that's I think better so we at
  3216. 2:40:38least we can read everything maybe we
  3217. 2:40:41can make it
  3218. 2:40:42more dark
  3219. 2:40:48yeah I think Ray was better so let's go
  3220. 2:40:50in colors I'm going to change this into
  3221. 2:40:53gray all right so here's my cursor
  3222. 2:40:58here is my cursor so
  3223. 2:41:03let's have a look
  3224. 2:41:08this is the place I don't see the cursor
  3225. 2:41:11so I should probably do this in PH store
  3226. 2:41:15so here I have opened my project and
  3227. 2:41:18let's open post controller
  3228. 2:41:24scroll down below and the error
  3229. 2:41:26basically coming from popular posts
  3230. 2:41:29again we can check this in the browser
  3231. 2:41:31yeah the popular post this is the
  3232. 2:41:33problem so right here we are selecting
  3233. 2:41:35everything from pose but we are only
  3234. 2:41:38using Group by posts ID so I think we
  3235. 2:41:43need to specify right here all the
  3236. 2:41:46fields which which is part of the post
  3237. 2:41:50table all the posts columns so let's
  3238. 2:41:54click on structure and I'm gonna
  3239. 2:41:57now let me have to open the database
  3240. 2:42:00posts
  3241. 2:42:02here we have all the columns and I'm
  3242. 2:42:04gonna
  3243. 2:42:04copy simply all of them
  3244. 2:42:08like this
  3245. 2:42:14here we go I'm going to paste all of
  3246. 2:42:17them then use multi-cursor features and
  3247. 2:42:21type hosts and dots whatever is the
  3248. 2:42:24field and then we have comma now we have
  3249. 2:42:29ID twice I'm going to remove once so now
  3250. 2:42:31I'm grouping based on the all Fields
  3251. 2:42:33because those are all fields which are
  3252. 2:42:36used right here
  3253. 2:42:37fingers crossed it should not be
  3254. 2:42:40complaining it shouldn't complain
  3255. 2:42:42anymore so let's comment this
  3256. 2:42:46um weeks Group by issue let's comment
  3257. 2:42:51everything
  3258. 2:42:53now let's push that and now let's open
  3259. 2:42:56Powershell let's
  3260. 2:42:59quit from here
  3261. 2:43:02don't save anything and quit from here
  3262. 2:43:04and we are inside the project right so
  3263. 2:43:08I'm gonna run git
  3264. 2:43:10all to get the latest changes and here
  3265. 2:43:13we see post controller was updated now
  3266. 2:43:16if I check in my browser reload the page
  3267. 2:43:20we don't see this error but we see the
  3268. 2:43:23same error on recommended posts so let's
  3269. 2:43:26open again post controller
  3270. 2:43:29let's grab those maybe the entire group
  3271. 2:43:33by
  3272. 2:43:34scroll down below and here we have that
  3273. 2:43:37we're selecting everything from Pro
  3274. 2:43:39posts byte grouping only post ID
  3275. 2:43:42the entire group by can be replaced with
  3276. 2:43:44this one format code to have something
  3277. 2:43:47similar
  3278. 2:43:48um
  3279. 2:43:49Group by categories ID
  3280. 2:43:54select categories I think it will
  3281. 2:43:56complain
  3282. 2:43:58right here as well
  3283. 2:44:01yeah it will complain but I want to see
  3284. 2:44:03that okay fixed Group by issue for
  3285. 2:44:07we fixed that for recommended posts
  3286. 2:44:10here we go
  3287. 2:44:12so let's commit
  3288. 2:44:16push
  3289. 2:44:18open Powershell run gitpool that was
  3290. 2:44:21updated reload in the browser
  3291. 2:44:25and we see yeah I was right we see now
  3292. 2:44:28on categories so on categories let's
  3293. 2:44:31scroll down below how many fields do we
  3294. 2:44:33have inside categories let's grab all
  3295. 2:44:36those fields they are not that many
  3296. 2:44:41and here
  3297. 2:44:43paste all of them
  3298. 2:44:47categories dot column name
  3299. 2:44:52here we go fix Group by issue for
  3300. 2:44:56categories
  3301. 2:44:58it should the the commitment should be
  3302. 2:45:00more descriptive to be honest so I just
  3303. 2:45:02I'm just trying to hurry up a little bit
  3304. 2:45:04and to waste your time but the ideal
  3305. 2:45:08comment message should be
  3306. 2:45:11fix Group by issue
  3307. 2:45:15for
  3308. 2:45:17in selecting
  3309. 2:45:20categories or home page
  3310. 2:45:23like this and the same type of comment
  3311. 2:45:26message you should use for the other two
  3312. 2:45:29things like right here and right here
  3313. 2:45:32now I'm going to comment this
  3314. 2:45:35I'm going to push that
  3315. 2:45:38open Powershell run git pull that was
  3316. 2:45:42updated reloading the browser
  3317. 2:45:46okay we have another error the same type
  3318. 2:45:50of error coming from App layout
  3319. 2:45:56up layout
  3320. 2:45:58okay now it's getting
  3321. 2:46:00um
  3322. 2:46:01awkward
  3323. 2:46:03let's fix that but now I'm thinking if
  3324. 2:46:06it is possible to change MySQL
  3325. 2:46:08configuration options
  3326. 2:46:12typically on management
  3327. 2:46:14I think we we don't have that
  3328. 2:46:16possibility so that's a option which is
  3329. 2:46:18called Full Group by full Group by
  3330. 2:46:21option
  3331. 2:46:22and that is activated as it looks like
  3332. 2:46:25so now let's go in up layout
  3333. 2:46:30up
  3334. 2:46:32layout
  3335. 2:46:36and what do we do
  3336. 2:46:40we select categories title but Group by
  3337. 2:46:42only ID we Select Title slug in others
  3338. 2:46:47but we Group by ID
  3339. 2:46:49if we have a look in the error we need
  3340. 2:46:52to include title and slack so I'm going
  3341. 2:46:55to get these two columns
  3342. 2:46:58and paste them right here
  3343. 2:47:01now let's give it a comment message fix
  3344. 2:47:04Group by issue by selecting
  3345. 2:47:07in
  3346. 2:47:09app layout
  3347. 2:47:11let's do like this
  3348. 2:47:13comment and push
  3349. 2:47:16now let's again run git pull that was
  3350. 2:47:18updated to have another error
  3351. 2:47:22we do have something
  3352. 2:47:24okay let's have a look because we don't
  3353. 2:47:26have data there's an error that error is
  3354. 2:47:29coming from up modules so in the
  3355. 2:47:32Constructor of post item
  3356. 2:47:34right here it expects to pass post
  3357. 2:47:37button now it's actually given
  3358. 2:47:40and from where does this happen
  3359. 2:47:44let's check
  3360. 2:47:46how is it possible that post item is
  3361. 2:47:49triggered
  3362. 2:47:54post item is rendered but there is
  3363. 2:47:57actually no post to it
  3364. 2:48:00that's interesting so where does this
  3365. 2:48:03error is coming from let's check this
  3366. 2:48:05coming from home blade
  3367. 2:48:07here we go
  3368. 2:48:09obviously latest post does not exist all
  3369. 2:48:13right let's open home.play generally
  3370. 2:48:16from my experience when you build your
  3371. 2:48:19application everything works fine
  3372. 2:48:21everything is smooth and you're happy
  3373. 2:48:23with that as soon as you tell your
  3374. 2:48:25friend hey I finished working on on the
  3375. 2:48:27application can you clone that and have
  3376. 2:48:29a look and when the friend clones that
  3377. 2:48:32and runs on an empty data then problems
  3378. 2:48:35really happen so it's recommended always
  3379. 2:48:37to test your application before you
  3380. 2:48:40deploy it on production or give tell it
  3381. 2:48:43to your friend test your application on
  3382. 2:48:46empty data on a fresh new installation
  3383. 2:48:48that happened a lot to me in the past
  3384. 2:48:52and it happened right now as well so
  3385. 2:48:54we're going to check simply if the
  3386. 2:48:57latest post exists we are going to
  3387. 2:49:00render that component
  3388. 2:49:05all right
  3389. 2:49:06again
  3390. 2:49:07now let's give it a comment message
  3391. 2:49:10add security check
  3392. 2:49:14if latest post exists before rendering
  3393. 2:49:23okay
  3394. 2:49:25now we push that
  3395. 2:49:28we pull that
  3396. 2:49:30and what's the next error
  3397. 2:49:32the next error is something which
  3398. 2:49:36um I really expected so this is the only
  3399. 2:49:38error I actually expected so far so that
  3400. 2:49:41happens because we don't have that
  3401. 2:49:44manifest we don't have assets actual
  3402. 2:49:46assets if we are doing this on a
  3403. 2:49:48development environment we can run npm
  3404. 2:49:51run Dev but we if we are doing this on
  3405. 2:49:53production we need to run npm run build
  3406. 2:49:56so this can be done in two ways
  3407. 2:49:59first is to run that on the server right
  3408. 2:50:03here and we can run npm run build but
  3409. 2:50:06that's not going to work because npm
  3410. 2:50:08comment is not available on hostinger's
  3411. 2:50:11shared hosting if you don't believe me
  3412. 2:50:12you can hit right here and you you will
  3413. 2:50:14see that
  3414. 2:50:15now we are going to do this in a
  3415. 2:50:18slightly different way so we are now run
  3416. 2:50:20npm run build well actually we need to
  3417. 2:50:24First go inside the container
  3418. 2:50:28a window being sailed up
  3419. 2:50:34let's open a new terminal vendor bin
  3420. 2:50:38sale Bash
  3421. 2:50:40we are in the container and now let's
  3422. 2:50:42run npm run build
  3423. 2:50:47okay
  3424. 2:50:48that will create the following files
  3425. 2:50:52build manifest Json build assets up CSS
  3426. 2:50:55and build assets app.js but
  3427. 2:50:59those files are actually ignored we
  3428. 2:51:02don't see these in uncommitted changes
  3429. 2:51:05if we check git ignore we are going to
  3430. 2:51:08see that
  3431. 2:51:10public build so everything from the
  3432. 2:51:12public build is ignored and that's
  3433. 2:51:15actually good practice because they are
  3434. 2:51:16generated files and when you deploy that
  3435. 2:51:18somewhere you should run npm run build
  3436. 2:51:22right there but because our environment
  3437. 2:51:24doesn't support npm at the moment so we
  3438. 2:51:27can remove that and that's also fine I
  3439. 2:51:30have been using this approach for many
  3440. 2:51:32years previously
  3441. 2:51:33the only thing that might happen
  3442. 2:51:37because you are commenting build files
  3443. 2:51:40is that if you are working with a team
  3444. 2:51:42you might have conflicts when you build
  3445. 2:51:46something and your colleague will build
  3446. 2:51:48something there will be conflict in
  3447. 2:51:50app.js in app CSS but
  3448. 2:51:52to fix those errors are very easy you
  3449. 2:51:55just need to
  3450. 2:51:57take either your version or your
  3451. 2:52:00colleague's version and then run npm run
  3452. 2:52:03build once again because
  3453. 2:52:05it's going to be finally generated from
  3454. 2:52:07your source files
  3455. 2:52:08all right so now in the uncommitted
  3456. 2:52:11changes we see those files so we're
  3457. 2:52:13gonna commit that
  3458. 2:52:15add
  3459. 2:52:16build folder
  3460. 2:52:19let's Commit This
  3461. 2:52:23let's push this
  3462. 2:52:26let's pull it
  3463. 2:52:28on our server
  3464. 2:52:30and let's check in the browser what is
  3465. 2:52:33the next error okay we don't have next
  3466. 2:52:35error anymore which is awesome if we
  3467. 2:52:39check right now database and if we check
  3468. 2:52:41specifically users
  3469. 2:52:44I think we don't have any users so let's
  3470. 2:52:46try to create one I'm going to check
  3471. 2:52:49what code I have inside database Cedar
  3472. 2:52:52here we create the user and we assign
  3473. 2:52:55role to that that's perfect now let's
  3474. 2:52:58open a search terminal and execute PHP
  3475. 2:53:00artisan
  3476. 2:53:02and DB colon seat let's hit the enter
  3477. 2:53:05setting database perfect that was
  3478. 2:53:08finished it will reload the users table
  3479. 2:53:10we see there is admin user now I can
  3480. 2:53:14access to
  3481. 2:53:16admin
  3482. 2:53:18let's check we probably have some errors
  3483. 2:53:21in admin as well what's the password
  3484. 2:53:25is the password
  3485. 2:53:27remember me click sign in
  3486. 2:53:30let's check it
  3487. 2:53:32okay so dashboard is good let's click on
  3488. 2:53:35categories that's good let's click on
  3489. 2:53:37post that's good text switches so it
  3490. 2:53:40looks like everything is working so I'm
  3491. 2:53:42going to create now test category
  3492. 2:53:43JavaScript
  3493. 2:53:46let's click on create
  3494. 2:53:49let's create
  3495. 2:53:51test post
  3496. 2:53:54let's make it active
  3497. 2:53:57to display it on the website
  3498. 2:54:00body okay let's give it some test
  3499. 2:54:03create that was created and
  3500. 2:54:08and let's actually assign it a category
  3501. 2:54:12of
  3502. 2:54:14JavaScript and I'm going to also test
  3503. 2:54:17what's going to be the
  3504. 2:54:20if image upload successfully works so
  3505. 2:54:23I'm going to choose one image right here
  3506. 2:54:26it's floating upload completed
  3507. 2:54:30click save changes that was saved if I
  3508. 2:54:33click on posts I see thumbnail right
  3509. 2:54:35here and that's awesome I click
  3510. 2:54:38open the new tab and we see this new
  3511. 2:54:40post
  3512. 2:54:41okay so it looks like everything is
  3513. 2:54:44working we have this in popular posts we
  3514. 2:54:46have this uh here as well we have this
  3515. 2:54:49tag category here we have the number of
  3516. 2:54:53minutes in one word we click it opens
  3517. 2:54:57the inner page and here we have another
  3518. 2:54:59problem on inside there that comes from
  3519. 2:55:02sidebar View and blade component sidebar
  3520. 2:55:07let's check now
  3521. 2:55:08sidebar
  3522. 2:55:13this is the select we are selecting
  3523. 2:55:15categories title and slug but we are
  3524. 2:55:18only group buying using ID so let's use
  3525. 2:55:21title and slug as well
  3526. 2:55:24now I'm going to choose comment message
  3527. 2:55:27fix Group by issue in
  3528. 2:55:31sidebar
  3529. 2:55:33click commit
  3530. 2:55:37now let's push that
  3531. 2:55:40foreign
  3532. 2:55:44pulled actually git pull
  3533. 2:55:48and now reload
  3534. 2:55:51okay here we go the sidebar however
  3535. 2:55:56does not
  3536. 2:55:58is not on the right side
  3537. 2:56:01which is kind of strange if we check
  3538. 2:56:04this on localhost
  3539. 2:56:10okay
  3540. 2:56:12um recently I had a Docker problem so I
  3541. 2:56:15locally deleted everything
  3542. 2:56:19in my local installation
  3543. 2:56:22that's why I don't have post table
  3544. 2:56:27okay I run migrations locally and
  3545. 2:56:29created the exact same post locally and
  3546. 2:56:32we have the same problem locally as well
  3547. 2:56:33so we probably messed up something if we
  3548. 2:56:36click we're going to open view dot blade
  3549. 2:56:39PHP and we are gonna have a look
  3550. 2:56:43this is the article
  3551. 2:56:46we have a sidebar
  3552. 2:56:48so the layout
  3553. 2:56:51doesn't have display Flex
  3554. 2:56:55okay let's search for what is up dot
  3555. 2:56:59blade dot PHP yeah we I think we remove
  3556. 2:57:04display Flex from this container and
  3557. 2:57:07that's why we have this problem no big
  3558. 2:57:09deal I think we need to wrap this in a
  3559. 2:57:12div and give this div
  3560. 2:57:15Flex
  3561. 2:57:17if I save these we need to obviously
  3562. 2:57:19have run npm run Dev at the moment and
  3563. 2:57:23then we're going to run npm run build
  3564. 2:57:26reload the page
  3565. 2:57:28and here we go so we see all categories
  3566. 2:57:30on the right side clicking on JavaScript
  3567. 2:57:32will filter that properly
  3568. 2:57:36okay awesome and if we create text
  3569. 2:57:38widget obviously it's going to appear
  3570. 2:57:40right here now let's run npm run build
  3571. 2:57:44because we need latest version of CSS we
  3572. 2:57:47made some changes here
  3573. 2:57:49it might be updated or it might not even
  3574. 2:57:52be updated
  3575. 2:57:54here we see that it is actually updated
  3576. 2:57:55up CSS so we are going to fix and
  3577. 2:57:59comment now all of them
  3578. 2:58:02here we go
  3579. 2:58:05okay
  3580. 2:58:06fix sidebar CSS issue
  3581. 2:58:11we commit that
  3582. 2:58:13we push that
  3583. 2:58:17we pull that on the server
  3584. 2:58:20and we open
  3585. 2:58:24we open the production environment we
  3586. 2:58:27load that and we see sidebar on the
  3587. 2:58:29right side
  3588. 2:58:31if we just search for something like
  3589. 2:58:34test
  3590. 2:58:36it doesn't find the eight fines right
  3591. 2:58:39there if we find Test 2
  3592. 2:58:42it doesn't find there so search actually
  3593. 2:58:45also works perfectly
  3594. 2:58:48about us page is it at the moment empty
  3595. 2:58:54okay one last thing which I'm going to
  3596. 2:58:56mention is
  3597. 2:58:58login and registration especially
  3598. 2:59:00registration and password reset so we
  3599. 2:59:03don't have proper SMTP credentials so if
  3600. 2:59:08we open Dot en file and if we scroll
  3601. 2:59:12down below
  3602. 2:59:15here we see that the mailer is an SMTP
  3603. 2:59:18and host is male pit so that was good
  3604. 2:59:21for local development but on production
  3605. 2:59:23this is not going to work so you have to
  3606. 2:59:27use some kind of production ready SMTP
  3607. 2:59:29for that such as Gmail or maybe Office
  3608. 2:59:33365
  3609. 2:59:35maybe mail gun you can use mail gun as
  3610. 2:59:38well and few others there are a few
  3611. 2:59:40others as well but the main idea is that
  3612. 2:59:43you need some kind of real SMTP to
  3613. 2:59:47validate
  3614. 2:59:49to send emails from your domain like in
  3615. 2:59:52my case it's going to be probably no
  3616. 2:59:54reply at the codeholic.com there are
  3617. 2:59:57many providers you just need to figure
  3618. 2:59:59out which one you want one of them is
  3619. 3:00:01Gmail second is AWS SES and there are
  3620. 3:00:05tons of others
  3621. 3:00:07all right so the hostinger actually also
  3622. 3:00:11gives you possibility to create email so
  3623. 3:00:14if we
  3624. 3:00:16click on emails right here from our
  3625. 3:00:19domain like I already have many emails
  3626. 3:00:22if we check the domain we just took
  3627. 3:00:27where is that
  3628. 3:00:29uh nicole.net we haven't set up any kind
  3629. 3:00:33of email we can click manage right here
  3630. 3:00:35and take a domain but be aware that it
  3631. 3:00:41is not intended for massive email
  3632. 3:00:44sending
  3633. 3:00:45if you don't expect to have like high
  3634. 3:00:48load on your website and a lot of
  3635. 3:00:49registrations I think you can use that
  3636. 3:00:53it's a good no problem if you're going
  3637. 3:00:55to have uh like a lot of registrations
  3638. 3:00:58this is not intended for that and also
  3639. 3:01:00don't use it for sending emails to
  3640. 3:01:04non-existing addresses because that's
  3641. 3:01:07gonna probably suspend your email
  3642. 3:01:09account
  3643. 3:01:10which is going to be not really good
  3644. 3:01:13all right so we deployed our pro project
  3645. 3:01:15on production environment with custom
  3646. 3:01:18domain Excel certificate MySQL and
  3647. 3:01:21everything works perfectly alright my
  3648. 3:01:23friends this is for this video and I
  3649. 3:01:25appreciate your time and thanks for
  3650. 3:01:27watching if you like the video please
  3651. 3:01:28leave Thumbs Up And subscribe to the
  3652. 3:01:31channel if you are not yet because I
  3653. 3:01:32plan much more content on variable and
  3654. 3:01:35PHP if you like this video maybe you
  3655. 3:01:37want to check another video in which I
  3656. 3:01:39talk about 10 PHP projects which you
  3657. 3:01:42should definitely build as a PHP
  3658. 3:01:44developer and that can definitely
  3659. 3:01:46improve your PHP skills you can find
  3660. 3:01:48this video right here thanks for
  3661. 3:01:50watching and I will see you in the next
  3662. 3:01:51one

About this transcript

This page contains the full transcript of Laravel Blog: Comments, Global Search, Deployment | Part 3 by The Codeholic, generated from the public captions YouTube serves with the video. The transcript has 20,803 words across 3,662 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.