YouTube2Text

Laravel 10 Blog with Filament Admin Panel | Part 1 — Transcript

by The Codeholic · 22,271 words · 3,653 segments · language en · Watch on YouTube

Full transcript

  1. 0:00I have built fully functional blog with
  2. 0:02the larval 10 in tolerance CSS the block
  3. 0:04has admin panel from which you can
  4. 0:07manage content of your website here's
  5. 0:09how I did it install and set up Lateral
  6. 0:11with crl and Docker install filament PHP
  7. 0:14as an admin template integrate free blog
  8. 0:17template in lateral query posts and
  9. 0:19output on the website with pagination
  10. 0:21create and use text widgets to manage
  11. 0:23any content on the website add and use
  12. 0:25meta fields for search engine
  13. 0:27optimization let's immediately have a
  14. 0:29look at the demo of the project
  15. 0:31on the home page we output a latest
  16. 0:34posts the post has image title
  17. 0:36description and the text we also have
  18. 0:39pagination we can go to the next Pages
  19. 0:41if we want when you open the post in
  20. 0:43your page you're gonna see the post
  21. 0:45image categories title and the whole
  22. 0:48description of the post and right here
  23. 0:51we also have next and previous patterns
  24. 0:53and based on that you can navigate
  25. 0:55between the next or previous posts on
  26. 0:58the right side we see all categories and
  27. 1:00also how many posts there are in this
  28. 1:03specific category in the navigation we
  29. 1:05have the home page top three categories
  30. 1:08and about us page if we open URL
  31. 1:11localhost slash admin and then enter
  32. 1:13username and password we are in the
  33. 1:15admin panel right here we can create
  34. 1:17categories and modify or delete we can
  35. 1:20also update posts and text wages text
  36. 1:23widgets are just key value pairs where
  37. 1:25we can output certain things on the
  38. 1:27website like for example the header text
  39. 1:29is output using a text widgets and also
  40. 1:33this About Us section is outputted using
  41. 1:35text widgets if we open the post section
  42. 1:38and click the very first post right here
  43. 1:40we can change the title and based on the
  44. 1:42title slag is automatically generated we
  45. 1:45can change the image assign or remove
  46. 1:47categories and of course adjust the
  47. 1:50description of the post and finally we
  48. 1:52can specify meta title in description
  49. 1:54mark this post is active or not and
  50. 1:57specify publish date if the post is not
  51. 2:00active or published date is not
  52. 2:02specified or if the published date is in
  53. 2:04the future the post will not appear on
  54. 2:07the website I want to give away my
  55. 2:09laravel e-commerce course there are two
  56. 2:11things required to participate in this
  57. 2:13giveaway you must be subscribed to the
  58. 2:15channel and you must leave a comment
  59. 2:17down below under this video and use the
  60. 2:21code holique in your comment I will
  61. 2:23choose 10 random people as winners and
  62. 2:26contact them and give my larval
  63. 2:28e-commerce course for free I'm going to
  64. 2:29also announce the winners on my Twitter
  65. 2:31if you want you can follow me on Twitter
  66. 2:33but it is not actually mandatory all
  67. 2:36right thank you very much for watching
  68. 2:37this video so far I really appreciate
  69. 2:40every single viewer of this video and
  70. 2:42now let's start building the project now
  71. 2:45let's start building our project this
  72. 2:48particular project I'm going to develop
  73. 2:50fully on Docker if you don't know what
  74. 2:52is Docker or how to set up it on your
  75. 2:54operating system first I recommend to
  76. 2:56check the docker tutorials I will try to
  77. 2:58use Docker more and more on this channel
  78. 3:01when building the projects because I
  79. 3:03think Docker is an essential tool
  80. 3:06nowadays for every uh every full stake
  81. 3:09developer or even back-end developer so
  82. 3:11Docker makes things very very easy and
  83. 3:15very very safe okay now we're gonna use
  84. 3:18in this project filament PHP which is a
  85. 3:21toolkit for laravel Artisans which is
  86. 3:24tall it's a talent alpine.js laravel and
  87. 3:27Live Wire that's pretty awesome kit in
  88. 3:31my opinion right here you can check the
  89. 3:33admin panel demo as well but we're going
  90. 3:35to actually install this in our laravel
  91. 3:3710 project and configure it and create
  92. 3:40admin panel with this tall kit if you
  93. 3:43want to see the final version of The
  94. 3:45Source Code you can check this on my
  95. 3:47GitHub the code holy slash laravel 10
  96. 3:50block and finally we're going to use the
  97. 3:52following template that's a very very
  98. 3:54minimalistic blog template we're going
  99. 3:56to have only categories and a listing of
  100. 3:59the blocks and then in your page of the
  101. 4:01blog we aren't going to have a
  102. 4:03Authentication
  103. 4:05or authorization system users would just
  104. 4:08be able to browse the blog website and
  105. 4:11just have a look at the Articles and
  106. 4:13read or filter by category okay so this
  107. 4:17is the overview now we can already start
  108. 4:20building our project I'm going to close
  109. 4:22uh actually let's leave this because
  110. 4:23we're going to need this I'm going to
  111. 4:25close my GitHub and we will need this
  112. 4:27also because we're gonna check the
  113. 4:29documentation for the filament PHP from
  114. 4:32time to time now let's open marvel.com
  115. 4:35and go to the documentation and we're
  116. 4:37going to set up the project with the
  117. 4:39docker as I mentioned so I'm going to
  118. 4:41click getting started on Windows scroll
  119. 4:43down below right here we have the
  120. 4:44following command we need to run this in
  121. 4:46our Linux terminal okay again if you are
  122. 4:49Mac OS or Linux user you just need to
  123. 4:51run this in your terminal probably you
  124. 4:54will already have crl command available
  125. 4:56if not then you just need to install crl
  126. 4:59on Windows when you set up wso2 with the
  127. 5:02Linux operating system in my tutorial I
  128. 5:05set up with Ubuntu then you're good to
  129. 5:07go you will have this URL right there
  130. 5:09okay now let's open
  131. 5:12Ubuntu here it is
  132. 5:15and I'm gonna go inside www folder and
  133. 5:21I'm going to call
  134. 5:22um
  135. 5:23well actually we need to paste this crl
  136. 5:25comment right here
  137. 5:29right click and let's give it proper
  138. 5:32name example app is not the proper name
  139. 5:34we're going to call this laravel
  140. 5:3710 new
  141. 5:39uh well larval 10 blog Dash new okay
  142. 5:43because I already have a lot of 10 blog
  143. 5:45so I'm going to call this laravel 10
  144. 5:46block new let's hit the enter this will
  145. 5:49take a lot of time basically if you are
  146. 5:52running these a very first time on your
  147. 5:54operating system it will download a lot
  148. 5:57of things uh it will clone clone the
  149. 5:59laravel project locally and then it will
  150. 6:02also download the docker images and set
  151. 6:05them up and execute them okay so I'm
  152. 6:07going to pause the recording and get
  153. 6:09back when this is done it downloaded all
  154. 6:11the images and at this stage we have to
  155. 6:13provide our operating system uh root
  156. 6:16password I'm going to provide my root
  157. 6:19password for Ubuntu
  158. 6:22hit the enter and here it is so it
  159. 6:25successfully installed our project and
  160. 6:27we need to navigate into the folder and
  161. 6:30then execute vendor bin sale app
  162. 6:34okay so let's navigate into laravel
  163. 6:38obtain blog Dash new and then well
  164. 6:43actually I can execute this vendor bin
  165. 6:45sale up from here but first i'm going to
  166. 6:47open this in my editor or ID I'm going
  167. 6:50to use phpstorm and basically let's type
  168. 6:55explorer.xa and Dot so I'm basically
  169. 6:58trying to open right now the current
  170. 7:02folder with the Windows Explorer here it
  171. 7:06was opened on my second screen this is
  172. 7:09it and I'm going to go inside www here I
  173. 7:12have all the projects and this is it so
  174. 7:15level 10 blog new right click on this
  175. 7:18and open folder is PHP show and approach
  176. 7:20it
  177. 7:21okay so it's gonna open in a second
  178. 7:26if it asks you whether you want to trust
  179. 7:29that folder and project you just need to
  180. 7:31click trust it and here it is so the
  181. 7:34project was opened in from now on I'm
  182. 7:37not gonna use this Ubuntu terminal
  183. 7:39instead I'm going to use PHP storms
  184. 7:42integrated terminal and we have to start
  185. 7:46the project using sales so now it's
  186. 7:48indexing it will take a couple of
  187. 7:49seconds but we can actually already
  188. 7:51start the project we don't need to wait
  189. 7:54vendor Bean
  190. 7:58sale app
  191. 8:00okay so sales is basically a
  192. 8:02containerization mechanism built on top
  193. 8:05of the docker it's a specially created
  194. 8:08for laravel and it makes a working with
  195. 8:12Docker very easy okay we just run uh
  196. 8:15sale app I'm going to open second
  197. 8:16terminal and now uh we're gonna go
  198. 8:20inside the container inside the main
  199. 8:22laravel container and then every Artisan
  200. 8:27command needs to be run from that
  201. 8:30container
  202. 8:31all right so we're going to execute
  203. 8:33vendor Bean sale Bash
  204. 8:37and now
  205. 8:39we are inside that container and now
  206. 8:42here we have PHP latest version PHP 8.2
  207. 8:46and we have Artisan command and
  208. 8:48everything right here so we are in the
  209. 8:50HTML folder which has all the files of
  210. 8:53the live okay so this HTML is mapped to
  211. 8:56the current directory so so far so good
  212. 9:00and we have this application up and
  213. 9:02running right here
  214. 9:04now let's install filament PHP let's go
  215. 9:07in the filamentphp.com and scroll down
  216. 9:10below I want to find the documentation
  217. 9:12page right here we see the instruction
  218. 9:14how we're going to include that in the
  219. 9:16admin panel an example how that actually
  220. 9:18looks like and in my opinion this looks
  221. 9:21amazing and let's go in the
  222. 9:23documentation right here so down below
  223. 9:24you can also find other packages form
  224. 9:27Builder and table Builder but we're
  225. 9:29going to also explore them inside the
  226. 9:31admin panel documentation which actually
  227. 9:33actually includes other packages as well
  228. 9:36so here is the documentation
  229. 9:38and let's click on the installation
  230. 9:42because the requirements are there we
  231. 9:44have the latest version of PHP because
  232. 9:46we are doing this on Docker we have
  233. 9:48everything ladies like the latest
  234. 9:50version of laravel PHP and MySQL as well
  235. 9:54okay uh it's it's amazing I really love
  236. 9:57working with Docker because you don't
  237. 9:59really care what version of PHP you have
  238. 10:02on your operating system when you are
  239. 10:04developing on Docker you don't even need
  240. 10:07to have PHP installed locally on your
  241. 10:09operating system which is in my opinion
  242. 10:11amazing okay let's open now PHP storm
  243. 10:14and we're going to run all the commands
  244. 10:15as I mentioned from here so installation
  245. 10:17very easy very first step is to require
  246. 10:20filament PHP so I'm going to copy that
  247. 10:22and paste right here hit the enter it's
  248. 10:25gonna install it then we're gonna open
  249. 10:28composer Json and put this in the post
  250. 10:31update CMD so I'm just going to copy
  251. 10:33that
  252. 10:34and let's open composer Json and let's
  253. 10:39search for post update CMD by the way
  254. 10:42the filament PHP was installed I'm going
  255. 10:44to collapse this terminal and open
  256. 10:46whenever I need that
  257. 10:48okay oops we don't need double
  258. 10:51quotations
  259. 10:55okay we need it like this okay filament
  260. 10:58PHP was was uh fully installed
  261. 11:02let's check the documentation again and
  262. 11:04we have added this in the post update
  263. 11:07CMD as well and now we need to create
  264. 11:10new filament user before we do this if
  265. 11:13we open now localhost slash admin that's
  266. 11:17going to open filament PHP login page
  267. 11:19okay but at the moment we don't have any
  268. 11:22users so we won't be able to log in
  269. 11:24Click right here we don't even have the
  270. 11:26users table that's that's interesting we
  271. 11:29need to run migrations
  272. 11:32let's open
  273. 11:33um again terminal and let's execute PHP
  274. 11:37Artisan
  275. 11:38migrate in the enter okay so for so good
  276. 11:42now let's if we just click right here
  277. 11:46the user doesn't exist okay now let's
  278. 11:48execute PHP artisan make
  279. 11:53filament Dash user hit the enter let's
  280. 11:57provide the name let's provide
  281. 12:00email
  282. 12:03hit the enter okay right here I'm going
  283. 12:05to type yes but for some reason it shows
  284. 12:08an error okay so now the user is already
  285. 12:11created and if I hit sign in with the
  286. 12:14user and password
  287. 12:15I'm inside the filament admin panel okay
  288. 12:19now we can start working and developing
  289. 12:22from here but first I think we need to
  290. 12:25generate migrations and models before we
  291. 12:27generate migrations and models let's
  292. 12:29create a storage link because we're
  293. 12:32gonna upload images and we will need
  294. 12:34storage to be properly linked I'm going
  295. 12:37to execute PHP Artisan storage column
  296. 12:41Link in the enter and the link has been
  297. 12:44created now let's create two main models
  298. 12:47one will be article so PHP
  299. 12:51not article but category PHP artisan
  300. 12:55make model
  301. 12:58category and I'm going to specify Dash M
  302. 13:01as well because I will need migration
  303. 13:02for this as well let's hit the enter it
  304. 13:05was generated and the second will be
  305. 13:08host a model with its migration it was
  306. 13:12generated as well and I will also need
  307. 13:15category post which will be Junction
  308. 13:18table between posts and categories
  309. 13:20because one category will belong to
  310. 13:24multiple posts and one post might have
  311. 13:27multiple categories posts and categories
  312. 13:29will have many to many relationship I'm
  313. 13:32going to execute PHP artisan make model
  314. 13:34category
  315. 13:37category post okay and the immigration
  316. 13:41was created excuse me migration was
  317. 13:44created
  318. 13:45okay and so we have that
  319. 13:48and now I think we just need to open the
  320. 13:51migration files and just write them so
  321. 13:52let's go in the database migrations
  322. 13:56and create categories table
  323. 14:00here it is
  324. 14:02okay so what Fields do we need right
  325. 14:04here
  326. 14:05for categories I'm going to make it very
  327. 14:07simple and I will just add two columns
  328. 14:09both of them will be string one will be
  329. 14:12title let's give it large length and the
  330. 14:15second will be Slack
  331. 14:18okay as easy as that now let's open
  332. 14:21second which is host table this is the
  333. 14:24main table so we will need much more
  334. 14:26Fields right here let's define
  335. 14:29table
  336. 14:31we will need string
  337. 14:35which will be title with the same length
  338. 14:39we will need slag
  339. 14:44we will need thumbnail as well
  340. 14:48which will be the main image or the post
  341. 14:50and we can make thumbnail as nullable
  342. 14:53it's not actually required we will need
  343. 14:56body
  344. 14:58which should be long text
  345. 15:03and body needs to be required so we just
  346. 15:06remove this nullable we will also need
  347. 15:09a one Boolean column which should be
  348. 15:13active
  349. 15:16and we will need date time column
  350. 15:21oops date time which should be published
  351. 15:27it when the article when the post should
  352. 15:31be published and become available on the
  353. 15:33website
  354. 15:34and probably the last one will be the
  355. 15:37foreign key to the user so that should
  356. 15:39be foreign ID 4 we have to specify user
  357. 15:44model right here
  358. 15:46class and the field name will be
  359. 15:51user ID
  360. 15:53later in this course we can also add
  361. 15:55meta fields for search engine
  362. 15:56optimization to post table SEO is key
  363. 15:59for every website you want your website
  364. 16:01to be discovered by Google especially
  365. 16:03your blog website you want your posts to
  366. 16:06be found whenever people search for
  367. 16:08something that's why you should try to
  368. 16:10do your best and Implement best SEO on
  369. 16:12your website speaking about SEO if you
  370. 16:15want to know how search engines work
  371. 16:17check introduction to search engines
  372. 16:19course at brilliant.org who is kindly
  373. 16:22sponsoring this video brilliant.org is
  374. 16:24the best way to learn your desired
  375. 16:26topics interactively the search engines
  376. 16:28course at brilliant.org will give you an
  377. 16:31excellent understanding how search
  378. 16:32engines work how indices are implemented
  379. 16:35or how to implement your own search they
  380. 16:37have courses around math computer
  381. 16:39science algorithm fundamentals data
  382. 16:42science neural networks and much much
  383. 16:44more their lessons are super engaging
  384. 16:46and interactive I love their algorithm
  385. 16:49fundamentals course that's a great
  386. 16:51introduction to very popular and useful
  387. 16:53algorithms such as binary search or
  388. 16:56sorting of arrays in this course you
  389. 16:58will also learn what is Big O notation
  390. 17:00which is to measure the time complexity
  391. 17:03of your code to try everything
  392. 17:05brilliant.org offers 30 days free trial
  393. 17:08visit brilliant.org the code holy or
  394. 17:11click the link in the video description
  395. 17:13first 200 users will get 20 off on their
  396. 17:17annual subscription the price is very
  397. 17:20affordable so I really recommend to
  398. 17:22check brilliant.org the code holic and
  399. 17:25start learning interactively today
  400. 17:28okay so we have that generated and I
  401. 17:32think we need to create also a junction
  402. 17:36table so let's open now create category
  403. 17:40posts this should be called in a
  404. 17:43singular form because that is how it is
  405. 17:47recommended on the level actually now
  406. 17:49I'm going to open a lot of documentation
  407. 17:51page because I always say that whenever
  408. 17:53you create projects you should have the
  409. 17:55documentation always open next to you
  410. 17:58and you should always try to stick with
  411. 18:00the documentation because in this case
  412. 18:02uh you will constantly checking the
  413. 18:05documentation learning constantly as
  414. 18:07well as preserving best practices
  415. 18:09because in the documentation you will
  416. 18:11often find highlighted section for some
  417. 18:13best practices okay now let's search for
  418. 18:16many too many
  419. 18:18right here mean to manual
  420. 18:21relationships here we have that table
  421. 18:24structure and this is exactly what I was
  422. 18:27talking about so we have users or roles
  423. 18:29and role user okay so roll user table is
  424. 18:33in a singular form
  425. 18:35okay and then here's also an example of
  426. 18:38the modal structure and everything so we
  427. 18:40need to call our
  428. 18:43table category post and we will need a
  429. 18:47foreign IDs to categories as well as to
  430. 18:52posts so table
  431. 18:54fouring ID
  432. 18:57that should be
  433. 18:59category ID
  434. 19:04references on ID
  435. 19:08on table categories okay and we have to
  436. 19:13specify as well on delete to be cast 8.
  437. 19:17whenever category is deleted I want a
  438. 19:21category post records to be deleted as
  439. 19:24well
  440. 19:25okay and then we will need post ID here
  441. 19:30that references ID on table posts and on
  442. 19:34delete we need Cascade as well whenever
  443. 19:36post is deleted that Junction table
  444. 19:39records should also be deleted
  445. 19:42okay so we have migrations migrations
  446. 19:45ready and now let's execute PHP Artisan
  447. 19:49migrate
  448. 19:50hit enter okay we probably have some
  449. 19:53kind of error
  450. 19:57published it now okay so first we'll
  451. 20:00successfully run second was failed let's
  452. 20:03check one mistake I have
  453. 20:06date times that should be daytime should
  454. 20:09not be date times
  455. 20:11okay let's
  456. 20:13clear the console and execute
  457. 20:17and here we go so that was actually
  458. 20:19successfully migrated now we have tables
  459. 20:22created and now let's open category
  460. 20:26category dot PHP so I want to open
  461. 20:29category model and I'm gonna add right
  462. 20:32here fillable
  463. 20:34so we have title and slack and we're
  464. 20:38gonna add this inside fillable let's
  465. 20:41copy this and now let's open
  466. 20:44post.php model
  467. 20:49paste this right here so we have a title
  468. 20:52slug we will need thumbnail
  469. 20:56everything basically every column so I'm
  470. 20:58going to open a post table and copy
  471. 21:02those including user ID and
  472. 21:06maybe I'm going to delete this paste
  473. 21:09everything create multi-cursor
  474. 21:12and do like this
  475. 21:14here we go so inside fillable I have all
  476. 21:17the post fields
  477. 21:19okay and I'm going to Define also
  478. 21:21relations from category to post and vice
  479. 21:25versa and inside post we also need
  480. 21:27relation to users so let's create a
  481. 21:31public function user
  482. 21:34we are going to return
  483. 21:37this belongs to user
  484. 21:43is that app models user
  485. 21:47yes it is okay so this belongs to user
  486. 21:50and let's define the return type as well
  487. 21:53so that is the relations belong to and I
  488. 21:57generally don't like so long on
  489. 22:00namespaces inside the return type so I'm
  490. 22:03going to just move this up so we will
  491. 22:06have use right here
  492. 22:07okay and now let's define
  493. 22:11um let's define categories
  494. 22:13so post has categories we're going to
  495. 22:15return these
  496. 22:18belongs
  497. 22:20belongs to many
  498. 22:24and here I'm going to specify category
  499. 22:27class
  500. 22:29okay and let's specify return type here
  501. 22:32as well
  502. 22:34okay so post belongs to many categories
  503. 22:39and we need to do this inversed inside
  504. 22:42category so I'm going to go in the
  505. 22:44categories so let's create right here
  506. 22:47post function return this
  507. 22:52um
  508. 22:53this belongs to many
  509. 22:57host
  510. 22:59like this
  511. 23:01okay and let's specify
  512. 23:05return type as well
  513. 23:07okay so we have our models and
  514. 23:12migrations I think fully ready okay now
  515. 23:16let me close everything and I'm going to
  516. 23:18open our browser
  517. 23:20open the website let's move this as a
  518. 23:23very first Tab and we're going to
  519. 23:24generate crud for categories and for
  520. 23:28posts and those cards are called
  521. 23:30resources
  522. 23:32if we go in the filament PHP scroll down
  523. 23:34below right here after uh the user
  524. 23:37generated right here we have the section
  525. 23:39link to the section building resources
  526. 23:41or or on the left side we have this
  527. 23:45resources section and getting started
  528. 23:47okay so we need to create resource and
  529. 23:52when we create resource it generates the
  530. 23:54following files a resource and Pages as
  531. 23:57well for create edit and list we can
  532. 24:00also generate a view page for each
  533. 24:03resource well actually I think best will
  534. 24:05be if I generate and then explore that
  535. 24:07so
  536. 24:09I'm going to execute PHP artisan make
  537. 24:13filament Dash resource let's specify
  538. 24:16category but I'm not going to hit enter
  539. 24:19so if we have a look in the filament
  540. 24:22documentation
  541. 24:23we can generate two types of resources
  542. 24:27one is normal resource and second is
  543. 24:30simple resource when we generate simple
  544. 24:32resource it doesn't have dedicated Pages
  545. 24:35for create and update instead it uses
  546. 24:38models so categories is more like a
  547. 24:41simple resource we don't need dedicated
  548. 24:43Pages for category view or edit it can
  549. 24:46be just module because we have only one
  550. 24:48Field title and the slug is
  551. 24:50automatically generated from the title
  552. 24:52okay so for categories we need simple
  553. 24:55four posts we need full version but we
  554. 24:59if we want to generate forms in the
  555. 25:02tables as well then we need to install
  556. 25:04talktrain debug package which will read
  557. 25:07the schema and based on the schema it
  558. 25:10will generate those those form fields
  559. 25:15and tables as well okay that's pretty
  560. 25:17interesting so let's actually first Inc
  561. 25:19include Doctrine and debal if that's not
  562. 25:22included in composer Json and by default
  563. 25:25I think it's not included so let's just
  564. 25:27execute composer require Doctrine debel
  565. 25:31because we just need this for
  566. 25:33development only we have to specify Dev
  567. 25:36right here that's an old error don't pay
  568. 25:40attention to that
  569. 25:42okay so here it was installed and now
  570. 25:46let's execute the following command but
  571. 25:50first four categories
  572. 25:52I'm going to specify right here
  573. 25:55category and we're going to specify as
  574. 25:58well dash dash simple flag and generate
  575. 26:02okay in this dish generate will create
  576. 26:04form and table components as well so
  577. 26:07let's hit the enter
  578. 26:09and now let's check admin panel reload
  579. 26:13the page and it automatically detected
  580. 26:16and used that categories right here okay
  581. 26:18so if I click the categories we don't
  582. 26:21have any categories at the moment but we
  583. 26:23have full credit functionality I'm going
  584. 26:25to click new category and call this test
  585. 26:28for example well slug is not at the
  586. 26:31moment automatically generated this is
  587. 26:33something we need to take care of but if
  588. 26:36I just click create I have the
  589. 26:38validation error I just type test right
  590. 26:40here as well and click create okay and
  591. 26:44we see the record is added we can click
  592. 26:47edit
  593. 26:48change we can click delete okay and this
  594. 26:51is full fully functional uh crot already
  595. 26:55which is amazing just executing a single
  596. 26:57line let's do the same thing now for
  597. 26:59posts but we don't want simple we want
  598. 27:03full version and we have to specify
  599. 27:06instead of simple let's specify view as
  600. 27:08well because we want dedicated view page
  601. 27:11as well for the Post okay so
  602. 27:15let's hit the enter so the post resource
  603. 27:18was generated and if I just reload the
  604. 27:21page posts are available right here new
  605. 27:23post and we will have all the fields
  606. 27:25like titles like thumbnail body and
  607. 27:28everything is right here okay and we
  608. 27:30have the user which is uh at the moment
  609. 27:33drop down but we don't need this right
  610. 27:35here because we're gonna assign
  611. 27:37authorized authenticated users
  612. 27:40okay so now let's check what has been
  613. 27:42actually generated go in the app let's
  614. 27:45call UPS everything go in the app
  615. 27:47filament and right here we have
  616. 27:49resources and two main resources
  617. 27:52category resource and post resource and
  618. 27:55there are also folders with the same
  619. 27:58name four pages for simple we have
  620. 28:01manage categories which is responsible
  621. 28:03this one is responsible for managing the
  622. 28:06categories and we have dedicated Pages
  623. 28:09create edit list in The View
  624. 28:12all right mostly we are going to work
  625. 28:16inside resources classes okay so now
  626. 28:19let's open category resource and we're
  627. 28:22gonna have a look so we have two Fields
  628. 28:24right here title and slack they are text
  629. 28:27inputs both of them are required and
  630. 28:30they also have max length right here and
  631. 28:32down below we have the table title slot
  632. 28:35create updated at those fields and we
  633. 28:38have actions as well edit and delete and
  634. 28:42we have bulk actions which is delete
  635. 28:44okay it's pretty awesome
  636. 28:47now let's have a look in the post
  637. 28:49resource
  638. 28:51so we have much more Fields right here
  639. 28:53title slack all of them not all of them
  640. 28:56but most of them are text Fields this
  641. 29:00one is toggle it's actually switch and
  642. 29:03the doctrine Depot detected that that
  643. 29:06was a Boolean and it generated switch
  644. 29:09the filament generated switch for that
  645. 29:11and we have daytime picker as well right
  646. 29:14here we can pick the exact time when we
  647. 29:16want this post to be published on the
  648. 29:19website and we have select which has
  649. 29:21relationship to the user and right here
  650. 29:24we specify which
  651. 29:26which column I want to be displayed
  652. 29:29right here that's pretty configurable
  653. 29:31and really awesome the filament PHP and
  654. 29:33it's also pretty popular if you check
  655. 29:35their GitHub you will find like a few
  656. 29:37thousand stars I think 5 000 Stars right
  657. 29:40there it's pretty good and that's why
  658. 29:42it's it's it has so many stars right
  659. 29:45here I change this field into email just
  660. 29:46to demonstrate that we can change the
  661. 29:49relationship column name and just like
  662. 29:51these is now there is email available
  663. 29:53but as I mentioned we don't need this
  664. 29:55user ID right here so we can completely
  665. 29:58remove it but before I clean up this a
  666. 30:01little bit I want to First Implement
  667. 30:03generating slags from the title which is
  668. 30:06pretty interesting so right here we have
  669. 30:08the columns and down below we have this
  670. 30:10actions for posts we have only View and
  671. 30:13a detections by the way let's add right
  672. 30:16here delete action as well and we have a
  673. 30:20bulk daily detection as well so now if I
  674. 30:24go in the posts and if I just create new
  675. 30:27test post
  676. 30:29let's fill on the required fields
  677. 30:37Okay click create it was created
  678. 30:39whenever it is created we still stay on
  679. 30:42the same page this is something which is
  680. 30:45configurable so we can do that if we
  681. 30:47don't like and here's the post and we
  682. 30:50just added delete action right here by
  683. 30:52adding the following line that delete
  684. 30:55button is available if we just remove
  685. 30:57that line we won't see that delete
  686. 30:59button if we want to delete the post
  687. 31:02when to go in the edit and then click
  688. 31:04delete but I think it's really
  689. 31:06convenient to have this delete right
  690. 31:08here especially it doesn't delete
  691. 31:10automatically but it asks this nice
  692. 31:12confirmation
  693. 31:13okay I think we we don't need that so we
  694. 31:16can delete this now let's open category
  695. 31:19resource and go under title text input
  696. 31:23field and we have to add uh right here a
  697. 31:26few few things to uh generate slag based
  698. 31:30on title and we need to listen to the
  699. 31:33event after State updated and that's
  700. 31:38obviously accepts callback
  701. 31:41because that's an event it accepts
  702. 31:42callback so we have right here closure
  703. 31:47set and we accept state as well
  704. 31:51okay so we can import that closure it's
  705. 31:55a standard class and then I'm going to
  706. 31:58call set which is uh closure the set and
  707. 32:03pass the field name in this case we
  708. 32:05passed slag and that slug should be at
  709. 32:09like a title converted into slack so in
  710. 32:13this case state will be title so I just
  711. 32:16need to use Str
  712. 32:18helper to call slag on that and specify
  713. 32:23state
  714. 32:24so whenever the state is updated for the
  715. 32:27title uh
  716. 32:29alpine.js Live Wire more specifically
  717. 32:32Live Wire will generate slag and update
  718. 32:37that so if I save this now and click go
  719. 32:40in the categories and click new category
  720. 32:42and just type right here lorem
  721. 32:45ipsum
  722. 32:47uh okay it does not work because I
  723. 32:51missed that we have to specify reactive
  724. 32:53so this field is reactive okay this is
  725. 32:56something without that it it doesn't
  726. 32:58work now let's reload the page
  727. 33:01and that should be lorem
  728. 33:05okay so and the slack was automatically
  729. 33:08generated okay you can change the slack
  730. 33:11if you don't like and click create uh
  731. 33:15and when you change this login then if
  732. 33:17you decide to change the title into
  733. 33:19something else then slack will be
  734. 33:22regenerated okay just click create right
  735. 33:25here and we need to copy this
  736. 33:29functionality into post Resource as well
  737. 33:33so let's put this right here
  738. 33:38okay we have two commas
  739. 33:42and we need to import closure
  740. 33:45okay now let's go in the posts click new
  741. 33:49post and lorem
  742. 33:51ipsum and this lag is actually generated
  743. 33:54so perfect now let's adjust the columns
  744. 33:58of the tables for categories and posts
  745. 34:00as well as the form input Fields let's
  746. 34:03open phpstorm and go in the table method
  747. 34:06and we have title slog created at and
  748. 34:09updated it I think we don't need slug in
  749. 34:12this table and maybe created it as well
  750. 34:14only title and updated it will be enough
  751. 34:17if I just reload the page we see only
  752. 34:19those two fields so we can also move
  753. 34:23these categories into a different
  754. 34:25section at the moment dashboard
  755. 34:28categories and posts are all in the same
  756. 34:30section but we can actually change this
  757. 34:33if we open this category resource and I
  758. 34:37believe right here we have this property
  759. 34:40called navigation group and then we just
  760. 34:43specify the text for example content I'm
  761. 34:46going to save this and if I reload the
  762. 34:49page we see that categories are now
  763. 34:51under content section in this
  764. 34:53collapsible section by the way
  765. 34:55we can also change the icon right here
  766. 34:59the filament PHP uses a hero icons but
  767. 35:03version one okay so if we just type in
  768. 35:06the Google Hero
  769. 35:08icons and I really love those icons it's
  770. 35:11very easy to get started and use that
  771. 35:13you just need to copy SVG in HTML files
  772. 35:16in this case we need only names but this
  773. 35:19is version two okay we need to go to the
  774. 35:22version one
  775. 35:24here it is and then any name right here
  776. 35:28can be used
  777. 35:30after heroicon Dash o instead of
  778. 35:34collection we can type for example
  779. 35:36academic cap and just like this we can
  780. 35:38use any icons available right here which
  781. 35:41is awesome and we're going to actually
  782. 35:42change the icon but for the posts
  783. 35:46let's open post resource and let's
  784. 35:49change this icon into something like
  785. 35:52let's search for document Maybe
  786. 35:56now we have multiple document variations
  787. 36:01let's use document text I'm going to get
  788. 36:04this name
  789. 36:05and paste this right here and now let's
  790. 36:08use navigation group as well to be the
  791. 36:12same content so we need uh categories
  792. 36:15and posts both to be under content
  793. 36:19section
  794. 36:20here we go and the icon was also changed
  795. 36:23for posts
  796. 36:25now let's open posts and click new post
  797. 36:28I'm going to work now on this form and
  798. 36:31adjust the layout change the thumbnail
  799. 36:34to being a file upload field remove
  800. 36:38these users basically all the work that
  801. 36:40is necessary right here and it will also
  802. 36:42open the filament documentation and what
  803. 36:45we need is layouts so let's scroll up
  804. 36:48click on search and we can search for
  805. 36:51layouts
  806. 36:53I really like the way how filament PHP
  807. 36:57gives you possibility to uh
  808. 37:00configure your layouts okay so if you
  809. 37:03have a look you we have those columns I
  810. 37:09think this is for the tables but I want
  811. 37:11for forms
  812. 37:14okay I want layouts for forms
  813. 37:19okay it comes from the okay let's have a
  814. 37:23look
  815. 37:25layout
  816. 37:28yeah that's it
  817. 37:31here we go so basically all the form is
  818. 37:35rendered in this category resource right
  819. 37:37here under form schema method okay so we
  820. 37:40have those fields we can group them we
  821. 37:43can reorder them we can split them at
  822. 37:47the moment it is already split into two
  823. 37:50columns because by default it is
  824. 37:52implemented like this but we can
  825. 37:54actually combine this or we can wrap
  826. 37:57everything into a card so I'm gonna
  827. 37:59actually use card at the moment so
  828. 38:02inside the form we need to use card
  829. 38:05component that is filament components
  830. 38:07card make and we have to pass
  831. 38:11make and then we need schema
  832. 38:16we pass an array and we can put
  833. 38:19everything inside the schema so I'm
  834. 38:21going to actually take everything from
  835. 38:22here and put this inside the card and
  836. 38:25let's format the code okay now have
  837. 38:27everything in the card if I save this
  838. 38:29and reload the page we see everything
  839. 38:31now is inside the card and I really like
  840. 38:34this approach that's that's in my
  841. 38:36opinion better
  842. 38:38and I want
  843. 38:40the for example slug to be on the right
  844. 38:44side of the title okay in the thumbnail
  845. 38:46and body and everything to be like like
  846. 38:48they are at the moment okay so I'm gonna
  847. 38:51go and make changes right here I'm going
  848. 38:56to actually use a section component I
  849. 38:59believe it is section
  850. 39:01let's actually go in the documentation
  851. 39:05and search for
  852. 39:07section
  853. 39:11also has heading maybe we don't want
  854. 39:16heading it's called probably something
  855. 39:18else so we have possibility to generate
  856. 39:21Wizards or tabs or field sets
  857. 39:26I think what I need is either grid
  858. 39:30yeah I think we need grid so I'm going
  859. 39:33to get the grid
  860. 39:34paste but I won't
  861. 39:38The r2b2 Columns okay and actually if I
  862. 39:42just delete and autocomplete grid okay
  863. 39:44here we go so I'm going to call make
  864. 39:46with two columns and then I'm going to
  865. 39:49call
  866. 39:51schema on that
  867. 39:53and put title in slug in site
  868. 39:59okay
  869. 40:01so now we have
  870. 40:03form inside the form we have single card
  871. 40:06like this inside card we have one grid
  872. 40:12and then we have Fields okay if I save
  873. 40:15this in now have a look
  874. 40:18now I see title and slog next to each
  875. 40:21other okay this is exactly how I want it
  876. 40:23so if I start typing now this log is
  877. 40:26still populated now let's change this
  878. 40:28thumbnail into file upload so I'm going
  879. 40:31to use now file upload and we don't need
  880. 40:35max length and
  881. 40:38let's have a look here it is
  882. 40:40and we can have a look in the how many
  883. 40:43ends did I set okay
  884. 40:47let's search for fields
  885. 40:53I want to show you all field options
  886. 40:56what we have
  887. 40:58here it is under four Builder section I
  888. 41:01really like the documentation it's a
  889. 41:03very well organized
  890. 41:05uh we are are a where's that
  891. 41:10here it is so field getting started okay
  892. 41:13this is where we are at the moment and
  893. 41:15we have uh many different types
  894. 41:18like text input select checkbox toggle a
  895. 41:21radio file upload reach tags reach
  896. 41:24editor which is we can also use and
  897. 41:26repeater and Builder and uh here here's
  898. 41:30everything basically what it supports
  899. 41:32and you can also have create your own
  900. 41:35custom custom fields which is pretty
  901. 41:38cool
  902. 41:39okay I'm going to change these thumbnail
  903. 41:41into file upload I already did that I'm
  904. 41:43going to change this into reach editor
  905. 41:45that should be toggled and I'm going to
  906. 41:49remove the user but I'm going to change
  907. 41:51this into categories okay so
  908. 41:54relationship goes into categories
  909. 41:57and the title should be the column name
  910. 42:01should be title because categories has
  911. 42:05title column so we're gonna display
  912. 42:07title right here
  913. 42:09and this should be categories
  914. 42:13like this
  915. 42:15okay and that is required now that's
  916. 42:18actually not required you can skip
  917. 42:20categories on the post or or let's let's
  918. 42:25make it required why why you should
  919. 42:27create a post without categories not
  920. 42:30sure now let's reload the page we have
  921. 42:33an error
  922. 42:34belongs to many get owner key and name I
  923. 42:40think that should be
  924. 42:42it should be category ID
  925. 42:48no
  926. 42:49let's specify right here multiple
  927. 42:53we we need this to be multiple maybe
  928. 42:55that's that's the point yeah
  929. 42:58that's it so now inside categories when
  930. 43:02we start typing something it
  931. 43:05autocompletes at the moment I think we
  932. 43:07don't have anything in the categories so
  933. 43:09I want to actually delete this and
  934. 43:11create few actual categories like
  935. 43:13JavaScript
  936. 43:16let's create
  937. 43:18PHP
  938. 43:22let's create
  939. 43:24alarm l
  940. 43:26I think three will be now
  941. 43:28or testing
  942. 43:30new form
  943. 43:31and I start typing and it searches and
  944. 43:35duties so we can specify now multiple
  945. 43:37categories to our post and that looks
  946. 43:41pretty cool
  947. 43:42so I want to re change the layout again
  948. 43:44and this is also Rich Text pay attention
  949. 43:46but I want to change the layout and I
  950. 43:49want like a thumbnail in categories to
  951. 43:53be on the right side of this form so
  952. 43:56here we have this card and I'm going to
  953. 43:59create
  954. 44:00well we can create another card or we
  955. 44:03can create a greed
  956. 44:06and that greed uh can be splitted into
  957. 44:11how should I do this so let's make this
  958. 44:14form
  959. 44:15to have like a column length columns 12
  960. 44:19columns okay so the form now has 12
  961. 44:22columns this card which is the main card
  962. 44:25let's give it
  963. 44:27let's give it calls Pawn column spawn to
  964. 44:31have eight
  965. 44:33and I'm going to create now the same
  966. 44:35type of card second card now
  967. 44:40and that will have comma is missing here
  968. 44:43and this will have
  969. 44:46call spawn four
  970. 44:49okay and I'm going to take thumbnail
  971. 44:54and categories
  972. 44:58inside the sidebar so I format the code
  973. 45:02save everything reload the page and this
  974. 45:05is exactly what I wanted so we see right
  975. 45:07here horizontal scroll because my
  976. 45:09browser zoomed in uh a lot actually
  977. 45:13because I'm like generally zooming when
  978. 45:16I when I'm developing something it's it
  979. 45:18was even zoomed out but like on a normal
  980. 45:21screen it will look like this okay you
  981. 45:24can adjust the layout as much as you
  982. 45:26need if I click browse and choose some
  983. 45:29type of image let's choose this one then
  984. 45:32it is uploaded successfully and if I
  985. 45:36choose now
  986. 45:37let's save this actually let's make
  987. 45:39record so
  988. 45:41um
  989. 45:42I have this Auto completed why
  990. 45:44JavaScript is weird and lorem ipsum
  991. 45:49okay let's create click create this
  992. 45:51field is required but that should not be
  993. 45:53required so I I should
  994. 45:57have made it optional in migrations
  995. 46:02I'm going to specify this right now
  996. 46:05create record
  997. 46:06user ID doesn't have default value okay
  998. 46:09so now we need to set the user when the
  999. 46:13record is about to be created
  1000. 46:16let's open again filament documentation
  1001. 46:19and let's search for
  1002. 46:22creating records
  1003. 46:26creating records
  1004. 46:28and customizing Data before saving this
  1005. 46:31is exactly what we want and we can
  1006. 46:35create we should create the following
  1007. 46:37function I'm going to actually copy this
  1008. 46:38function and go under
  1009. 46:42post resource and create post okay so
  1010. 46:46that is
  1011. 46:47which should have the following method
  1012. 46:50and if I save this now
  1013. 46:53and just close this and hit create again
  1014. 46:58hit create again
  1015. 47:01okay I think
  1016. 47:04because this is required
  1017. 47:07but I actually populate this okay so
  1018. 47:10that was created
  1019. 47:11that was created
  1020. 47:14okay here it is so we have user zura we
  1021. 47:17have created update that basically
  1022. 47:19everything except the thumbnail because
  1023. 47:21the thumbnail needs to be an image okay
  1024. 47:24and I think because we have this is the
  1025. 47:26view Page by the way when we click on
  1026. 47:28the record this is view page I click
  1027. 47:30edit we are in the edit page the image
  1028. 47:32is not properly saved let's choose the
  1029. 47:37image again
  1030. 47:39let's make detective by the way
  1031. 47:42and let's click save changes okay that
  1032. 47:44was saved
  1033. 47:46okay now we have the thumbnail
  1034. 47:49okay perfect now let's
  1035. 47:52let's modify this table because I think
  1036. 47:54we did everything uh pretty
  1037. 47:58well in the uh article post creation
  1038. 48:02page
  1039. 48:03now let's adjust this let's go in the
  1040. 48:06post resource scroll down below I don't
  1041. 48:09want slog
  1042. 48:11I don't want body and
  1043. 48:15do I need username no I think I don't
  1044. 48:19need the username
  1045. 48:21however I'm going to comment this out
  1046. 48:23don't remove and I'm going to remove
  1047. 48:25also uh created it I will leave these
  1048. 48:27published it so I save this and I'm
  1049. 48:30going to make this also to be image
  1050. 48:32column
  1051. 48:33and the active
  1052. 48:35is icon column which is good
  1053. 48:39so I just reload the page let's move
  1054. 48:41this thumbnail as a very first so we
  1055. 48:45have a thumbnail we have titles status
  1056. 48:48published it and updated it
  1057. 48:52okay and just like this we have
  1058. 48:56customized our crud whenever we click on
  1059. 49:01the recording it is selected we have
  1060. 49:03possibility to delete because that is
  1061. 49:05added in the bulk edit bulk actions
  1062. 49:09that's awesome
  1063. 49:15if you are enjoying this video so far
  1064. 49:17make sure you hit the like button
  1065. 49:19thank you
  1066. 49:23now I'm going to create one more post
  1067. 49:25and then we can move on the front end
  1068. 49:27that is lorem
  1069. 49:29ipsum post and I'll specify right here
  1070. 49:34oops to be PHP
  1071. 49:38I'm not going to make it active also I'm
  1072. 49:41not going to choose published it let's
  1073. 49:44type test right here and click create
  1074. 49:47okay we just need to adjust this I'm
  1075. 49:49going to go in the post resource and in
  1076. 49:52the form I'm going to remove required on
  1077. 49:56the publish date however if it is
  1078. 49:59required on the database level we are
  1079. 50:01going to have problems so
  1080. 50:04uh let's just reload the page
  1081. 50:07let's specify Laura ipsum
  1082. 50:11and click create
  1083. 50:12okay category is required so we have to
  1084. 50:16specify it
  1085. 50:17this is required we have to specify it
  1086. 50:20and click create
  1087. 50:23okay publish that can be now that's
  1088. 50:25exactly what I was thinking so actually
  1089. 50:28I prefer to open now my existing
  1090. 50:31migration which is for categories
  1091. 50:37unfortunately I have to
  1092. 50:40like I can create new migration and
  1093. 50:43change the column but I think it will be
  1094. 50:46more relevant to just uh make these
  1095. 50:52nullable right here but in this case I
  1096. 50:56have to drop last two migrations and
  1097. 50:59recreate them so PHP Artisan uh migrate
  1098. 51:06I'll roll back
  1099. 51:09Dash Dash step equals two it will roll
  1100. 51:14back
  1101. 51:16let me create roll back
  1102. 51:19okay is there any kind of error
  1103. 51:23Canon drop table pause referenced by
  1104. 51:26Foreign key constraint
  1105. 51:33Okay so
  1106. 51:37hold on
  1107. 51:40right here I am dropping category posts
  1108. 51:45but that should be category post
  1109. 51:48this is the problem
  1110. 51:51okay so this was problem because when
  1111. 51:55this group migration rollback was run it
  1112. 51:59tried to drop the category posts and
  1113. 52:03then when the second migration was run
  1114. 52:04it tried to draw posts but that post was
  1115. 52:08still referencing to the category post
  1116. 52:10table
  1117. 52:11so let's execute these
  1118. 52:17okay we have problem again
  1119. 52:25drop table if exist pose that references
  1120. 52:29to category post ID foreign okay white
  1121. 52:33is that
  1122. 52:34problem actually
  1123. 52:42so first category post needs to be
  1124. 52:44dropped right so I execute
  1125. 52:48step one
  1126. 52:54I think that was already dropped if we
  1127. 52:58check migrations
  1128. 53:05if we check migrations that's
  1129. 53:07interesting what's going to be the
  1130. 53:09status right there I'm going to use now
  1131. 53:11phpstorms database tool and you can use
  1132. 53:15basically any database client like MySQL
  1133. 53:18workbench for example to connect to the
  1134. 53:20database which is running under Docker
  1135. 53:23so the host is localhost this is the
  1136. 53:26default Port the user will be sale and
  1137. 53:30password is just password
  1138. 53:33literally password
  1139. 53:36like this
  1140. 53:38okay let's test the connection
  1141. 53:40yep it works
  1142. 53:43let me choose the schema
  1143. 53:46schema needs to be
  1144. 53:50okay what's key Mouse do we have
  1145. 53:53there are four schemas laravel 10 block
  1146. 53:56new this is what I want to choose and
  1147. 53:59check now migrations
  1148. 54:02let's have a look what's the latest
  1149. 54:04migration there let's create posts table
  1150. 54:07and it it is trying to drop posts
  1151. 54:14but I think it cannot drop because there
  1152. 54:17are records in the posts
  1153. 54:20okay that is very very edge case because
  1154. 54:23I just uh forgot to add the nullable in
  1155. 54:26the published it so it doesn't work to
  1156. 54:29spend too much time on this I'm going to
  1157. 54:30go in the posts and just delete that and
  1158. 54:34hopefully now I can roll back
  1159. 54:39one
  1160. 54:40no actually it does not roll back why
  1161. 54:43because probably because the table is
  1162. 54:46not dropped category post is not dropped
  1163. 54:48exactly exactly so the previous
  1164. 54:50migration that migration was rolled back
  1165. 54:54because right here it was written
  1166. 54:58right here it was written drop if exists
  1167. 55:01category posts that did not exist the
  1168. 55:05category post table that was not dropped
  1169. 55:09and but this record was removed from the
  1170. 55:13migrations table is successfully rolled
  1171. 55:16back
  1172. 55:18that's that's it so I can manually
  1173. 55:20delete category post
  1174. 55:22okay
  1175. 55:24and now I can roll back
  1176. 55:27yes and now I can run PHP art design me
  1177. 55:31great okay those two migrations will be
  1178. 55:34reapplied now if I check the database I
  1179. 55:37will see category post right here
  1180. 55:39and again I'm going to check uh post
  1181. 55:43table and I will see published it is not
  1182. 55:46required anymore okay it doesn't have
  1183. 55:49that Green Dot next to it which
  1184. 55:52indicates that it is required or not now
  1185. 55:55I'm going to go under hose and I'm going
  1186. 55:58to create
  1187. 55:59why JavaScript is weird again let's
  1188. 56:02choose this keyboard which is not
  1189. 56:04relevant but like we are testing at the
  1190. 56:06moment
  1191. 56:08here it is
  1192. 56:09and let's specify test here and click
  1193. 56:13create okay that was created we haven't
  1194. 56:17specified published yet because we just
  1195. 56:19created our post we don't want it to be
  1196. 56:21published at the moment okay that's the
  1197. 56:24whole idea let's create second post
  1198. 56:26lorem ipsum test
  1199. 56:29let's specify
  1200. 56:31now Mouse
  1201. 56:34and test again right here
  1202. 56:37right here we have possibility to
  1203. 56:40specify headings and subheadings and
  1204. 56:42lists and images as well as the code
  1205. 56:45block which is pretty cool
  1206. 56:48okay let's choose now this to be laravel
  1207. 56:54and click create
  1208. 56:56okay so we have successfully created two
  1209. 57:00posts
  1210. 57:03and I think now we can move on the front
  1211. 57:05and side okay now let's open front end
  1212. 57:08I'm gonna just uh
  1213. 57:10let's duplicate this probably and remove
  1214. 57:13it so this is the front-end side and
  1215. 57:16this is our blog template which we want
  1216. 57:19to
  1217. 57:20either download or grab content so you
  1218. 57:25click this get template it opens the
  1219. 57:27GitHub link and then we have two html's
  1220. 57:29plugin posts I'm going to click on blog
  1221. 57:32and right here we have the whole HTML it
  1222. 57:35uses alpine.js and Talon CSS
  1223. 57:39okay and we need to adjust them
  1224. 57:44okay I'm gonna click on row and get
  1225. 57:47entire HTML
  1226. 57:49okay now let's open
  1227. 57:52uh phpstorm and go let's collapse
  1228. 57:56everything and go under resources and
  1229. 57:59Views at the moment we have only welcome
  1230. 58:01blade which has the layout as well as
  1231. 58:03the content we don't need that uh to be
  1232. 58:07like this I want to create layout
  1233. 58:09so I'm going to create now component
  1234. 58:13PHP artisan make
  1235. 58:16component let's call this up layout
  1236. 58:21hit the enter okay app layout component
  1237. 58:23was created so if we go in under app
  1238. 58:26view components up layout it has right
  1239. 58:30here view named which is under
  1240. 58:33components app layout well I'm going to
  1241. 58:36change these to be layouts
  1242. 58:39up just like this
  1243. 58:42so now if I go in the resources views
  1244. 58:46right here we have components and then
  1245. 58:48app layout I'm going to rename the
  1246. 58:51components folder called this layouts
  1247. 58:53and I'm going to rename this app layout
  1248. 58:56and just call
  1249. 58:57up
  1250. 58:59so that the view name exactly matches
  1251. 59:02now the component layout and I'm going
  1252. 59:06to open now layout which is empty almost
  1253. 59:09empty now it's empty and I'm going to
  1254. 59:11paste entire HTML which I copied from
  1255. 59:15the GitHub okay now let's identify what
  1256. 59:18is actually layout and what is part of
  1257. 59:21The View
  1258. 59:23so this is body we have the navigation
  1259. 59:27we have the header and we have a topic
  1260. 59:32navigation as well and then container
  1261. 59:35comes and then we have the section
  1262. 59:38and then a side and below is a footer
  1263. 59:41okay and some alpine.js scripts so
  1264. 59:47if we have a look in the design
  1265. 59:50so what is the layout obviously this top
  1266. 59:53part is part of layout we can consider
  1267. 59:57this about us and that Instagram section
  1268. 1:00:00to be part of layout as well or maybe we
  1269. 1:00:03don't even need that I actually want to
  1270. 1:00:05put right here latest posts maybe or
  1271. 1:00:09latest categories right here we don't
  1272. 1:00:13need obviously this in Instagram section
  1273. 1:00:16so we can at the moment we can make this
  1274. 1:00:21part of the layout okay and this will be
  1275. 1:00:24actually the content so this will be
  1276. 1:00:27actually content I'm going to get these
  1277. 1:00:29and because this is layout I'm going to
  1278. 1:00:32Output right here slot
  1279. 1:00:35okay now I'm going to open this welcome
  1280. 1:00:37blade
  1281. 1:00:40um actually I just copied this portion
  1282. 1:00:43so I'm going to save it somewhere
  1283. 1:00:45so I'm going to create new scritch file
  1284. 1:00:48blade scratch file and paste it okay
  1285. 1:00:51here we have couple of Articles those
  1286. 1:00:53are demo articles I don't want this uh
  1287. 1:00:56to be lost so I have this in scratch
  1288. 1:00:58file
  1289. 1:01:00now right here we have to make few
  1290. 1:01:03changes if I open we'll complete again
  1291. 1:01:05like the language is taken from the app
  1292. 1:01:09get local so I need to get that HTML in
  1293. 1:01:13the layout replace that like
  1294. 1:01:15oops copy this and replace here
  1295. 1:01:20okay we also want
  1296. 1:01:23this is the welcome
  1297. 1:01:26Inc
  1298. 1:01:32title
  1299. 1:01:34so we can use the title
  1300. 1:01:37from the configs but I think that's okay
  1301. 1:01:40so we can leave this at the moment
  1302. 1:01:41talwind blog template uh the content the
  1303. 1:01:46author content we can remove that
  1304. 1:01:49okay I think this is
  1305. 1:01:51this is okay this is good now let's edit
  1306. 1:01:55uh this welcome delete everything and
  1307. 1:01:59take those articles from the scratch
  1308. 1:02:01file and put under welcome
  1309. 1:02:04okay then I'm going to close the script
  1310. 1:02:06file and finally I'm going to rename the
  1311. 1:02:10welcome to be homeblade
  1312. 1:02:13okay now if we open web.php and change
  1313. 1:02:17this into home save that and open our
  1314. 1:02:22application and just reload
  1315. 1:02:24uh we have problem we don't have styles
  1316. 1:02:29let's inspect this
  1317. 1:02:32and have a look
  1318. 1:02:34reload the page
  1319. 1:02:37okay I know the reason in the home we
  1320. 1:02:42don't use the component as a layout so
  1321. 1:02:46we need to use x up layout
  1322. 1:02:52like this save and reload and here we go
  1323. 1:02:57so this is now our laravel application
  1324. 1:02:59we have layout defined and we have
  1325. 1:03:02content coming from the home
  1326. 1:03:05now let's create controller and select
  1327. 1:03:09posts and pass this to the view and
  1328. 1:03:11render them properly we don't want
  1329. 1:03:13anything to be hard-coded right here
  1330. 1:03:15okay I'm gonna bring up the terminal and
  1331. 1:03:17create controller by executing PHP
  1332. 1:03:19artisan make
  1333. 1:03:21controller and let's call this post
  1334. 1:03:24controller and let's also specify dash
  1335. 1:03:28dash resource we don't need everything
  1336. 1:03:30every resource methods but let's specify
  1337. 1:03:33still because deleting is much easier
  1338. 1:03:35than create than writing so resource and
  1339. 1:03:39dash dash model equals post let's hit
  1340. 1:03:42the enter post controller created
  1341. 1:03:45successfully and let's open post
  1342. 1:03:48controller and we have to work in the
  1343. 1:03:51index let's actually return view from
  1344. 1:03:55here which should be
  1345. 1:03:57home
  1346. 1:03:59okay and let's open web and I'm going to
  1347. 1:04:03change this into
  1348. 1:04:06post controller
  1349. 1:04:09index
  1350. 1:04:11and let's give it also a name
  1351. 1:04:14to be home
  1352. 1:04:16and let's change this use qualifier with
  1353. 1:04:20import
  1354. 1:04:21so I save this reload I see the exact
  1355. 1:04:25same result now let's open post
  1356. 1:04:27controller and I'm going to actually
  1357. 1:04:29close everything else
  1358. 1:04:31so right here we can by the way specify
  1359. 1:04:33uh based on the PHP based on the laravel
  1360. 1:04:38chain and now we can have types
  1361. 1:04:41everywhere because the minimum PHP
  1362. 1:04:44requirement for a lot of attain is 8.1
  1363. 1:04:46okay we can specify a view for example
  1364. 1:04:49that should return illuminate View
  1365. 1:04:53or we can just leave this empty as it is
  1366. 1:04:56right now that's not going to hurt as
  1367. 1:04:57well but that's additional like small uh
  1368. 1:05:00security measurement that make sure that
  1369. 1:05:03you always return vo and nothing else
  1370. 1:05:05from from here now we need to query
  1371. 1:05:08posts
  1372. 1:05:10all SQL
  1373. 1:05:12post a specified query and we want to
  1374. 1:05:17um
  1375. 1:05:18only select those posts which has active
  1376. 1:05:24equals
  1377. 1:05:25one
  1378. 1:05:27and we want also
  1379. 1:05:30those which is published
  1380. 1:05:33so where
  1381. 1:05:36published it
  1382. 1:05:41equals
  1383. 1:05:44null
  1384. 1:05:46or no where it does not equal now
  1385. 1:05:49actually or is not null would be more uh
  1386. 1:05:53more accurate maybe but let's have a
  1387. 1:05:56look what this will select order by
  1388. 1:06:01we're gonna order that by published it
  1389. 1:06:06with descending
  1390. 1:06:08and I'm going to call paginate on that
  1391. 1:06:10because we will need pagination as well
  1392. 1:06:12so we have posts and I'm gonna pass now
  1393. 1:06:15posts using compact function
  1394. 1:06:19to view
  1395. 1:06:21now if I open
  1396. 1:06:23home.blade PHP
  1397. 1:06:25right here
  1398. 1:06:27we need we have three articles
  1399. 1:06:31okay the structure is identical but we
  1400. 1:06:34don't need all of them we just need one
  1401. 1:06:36which we need to put inside the loop but
  1402. 1:06:39I want to actually create
  1403. 1:06:41maybe a separate dedicated component or
  1404. 1:06:46that article
  1405. 1:06:47PHP artisan make
  1406. 1:06:51a component
  1407. 1:06:53let's call this
  1408. 1:06:55uh post item component
  1409. 1:07:00okay and I think we don't need
  1410. 1:07:03a special class for that we can just
  1411. 1:07:07create view only
  1412. 1:07:09uh view
  1413. 1:07:11I believe that's the correct flag
  1414. 1:07:14component created successfully now let's
  1415. 1:07:16have a look uh do we have the component
  1416. 1:07:19under up view components now we don't
  1417. 1:07:22have if we go under resources views
  1418. 1:07:26components we have
  1419. 1:07:28post item right here okay and now I'm
  1420. 1:07:31gonna copy this article and paste into
  1421. 1:07:34post item
  1422. 1:07:37and we're going to accept right here
  1423. 1:07:39post and then based on the post we are
  1424. 1:07:43going to Output certain information
  1425. 1:07:46but from here
  1426. 1:07:48we are gonna iterate over posts is post
  1427. 1:07:56and then we're going to call X post item
  1428. 1:08:02like this and we specify post
  1429. 1:08:08that's going to be the post like this we
  1430. 1:08:12need to accept that uh post right here
  1431. 1:08:15let's Implement actually outputting post
  1432. 1:08:18item right here in this component so we
  1433. 1:08:22already have post variable available
  1434. 1:08:23right here so let's just try to Output
  1435. 1:08:26right here thumbnail for example post
  1436. 1:08:30thumbnail
  1437. 1:08:32then right here we need to Output
  1438. 1:08:34categories so I'm going to start
  1439. 1:08:36iterating over categories for the Post
  1440. 1:08:39we will need post categories is a
  1441. 1:08:43category
  1442. 1:08:45and like this let's output right here
  1443. 1:08:49category
  1444. 1:08:51title and right here we need to link to
  1445. 1:08:56that page where we will see only those
  1446. 1:09:00posts which belong to the category so we
  1447. 1:09:03don't have that road created yet so I'm
  1448. 1:09:05going to leave these as it is right now
  1449. 1:09:07so this one will be title for the Post
  1450. 1:09:11because this is a post item so this
  1451. 1:09:15should not be an a
  1452. 1:09:16um
  1453. 1:09:17excuse me so this should be an a
  1454. 1:09:19actually and this should be linked uh to
  1455. 1:09:22the inner page of the post we don't also
  1456. 1:09:25have that road we're going to create
  1457. 1:09:26that so let's output right here post
  1458. 1:09:30title at the moment
  1459. 1:09:33and down below we have the user
  1460. 1:09:36so we can have
  1461. 1:09:39uh post
  1462. 1:09:41like this host user name
  1463. 1:09:46and published on Android here we need
  1464. 1:09:48date okay so here we should have post
  1465. 1:09:52published it
  1466. 1:09:55and down below we need to Output the
  1467. 1:09:58description the content
  1468. 1:10:01not the whole content should be outputed
  1469. 1:10:03right here so it will make sense if we
  1470. 1:10:06just output
  1471. 1:10:08short like a few few symbols not not the
  1472. 1:10:12whole body so maybe let's assume that we
  1473. 1:10:16create a special method in the post
  1474. 1:10:19model like um get or just short body
  1475. 1:10:24okay so post has buddy but we don't want
  1476. 1:10:27the whole body to be outputted in the
  1477. 1:10:29listing so let's just call short body
  1478. 1:10:32and we will have to create that method
  1479. 1:10:36in the
  1480. 1:10:37in the post but for now let's save this
  1481. 1:10:41and have a look in the browser
  1482. 1:10:44here we go so let's just click on this
  1483. 1:10:46roll the page
  1484. 1:10:47okay nothing is actually selected and
  1485. 1:10:50let's go in the post controller because
  1486. 1:10:52I think we have something
  1487. 1:10:54Okay so
  1488. 1:10:56this wear should be probably changed
  1489. 1:10:59into a weird date because we have that
  1490. 1:11:02to be date
  1491. 1:11:04and then published it must be
  1492. 1:11:09published it actually must be
  1493. 1:11:12um
  1494. 1:11:14less than
  1495. 1:11:16now and we should use carbon now
  1496. 1:11:20okay so published it needs to be uh in
  1497. 1:11:24the past basically so if I save this
  1498. 1:11:29and now rule of the page
  1499. 1:11:31we don't see anything now let's check
  1500. 1:11:34our posts and yeah the active status is
  1501. 1:11:37not marked so we just click on edit and
  1502. 1:11:40let's mark this active and let's choose
  1503. 1:11:43date which is in the past
  1504. 1:11:45okay so that was saved and let's
  1505. 1:11:49activate the second one
  1506. 1:11:54that is in the past
  1507. 1:11:57perfect now let's reload the page okay
  1508. 1:11:59so we have an error which is good the
  1509. 1:12:01short body doesn't exist now let's open
  1510. 1:12:04host here we have the post model and we
  1511. 1:12:07have control and click on that
  1512. 1:12:09and now let's create that short body
  1513. 1:12:13now we should return string and we are
  1514. 1:12:17going to return from here Str
  1515. 1:12:20words
  1516. 1:12:22I think I'm using different Str
  1517. 1:12:24uh return Str which should be illuminate
  1518. 1:12:28illuminate support
  1519. 1:12:30then we're going to call words method
  1520. 1:12:32and that then I'm going to strip strip
  1521. 1:12:36tags remove basically any tags from this
  1522. 1:12:40body and then finally I'm going to just
  1523. 1:12:42output like a 30 words from this um from
  1524. 1:12:46this body so if I save this now and
  1525. 1:12:48reload the page we see post is actually
  1526. 1:12:51rendered the description is not there
  1527. 1:12:53because the description
  1528. 1:12:55actually is not written inside so let me
  1529. 1:12:59actually generate lorem ipsum text if I
  1530. 1:13:03go in any blade file and just type lore
  1531. 1:13:06m
  1532. 1:13:07and hit the tab this is it okay so I'm
  1533. 1:13:11going to cut this
  1534. 1:13:12and then I'm going to basically delete
  1535. 1:13:15everything and paste oops
  1536. 1:13:18okay let me remove any kind of
  1537. 1:13:19formatting paste this right here and I'm
  1538. 1:13:22going to paste multiple paragraphs okay
  1539. 1:13:24so this is just just lowering me some
  1540. 1:13:27text
  1541. 1:13:28so I say that was lowering up some tests
  1542. 1:13:31and now if I just reload
  1543. 1:13:36so here we see that the title is not
  1544. 1:13:39outputted for some reason where is the
  1545. 1:13:42Post item oops I have a typo
  1546. 1:13:46lowering some test and as you see
  1547. 1:13:49we see like a short description of the
  1548. 1:13:52long
  1549. 1:13:53and that's pretty cool if the
  1550. 1:13:55description is too small then the card
  1551. 1:13:57is displayed like this that's a Talon
  1552. 1:13:59CSS like a ping and we can fix that
  1553. 1:14:03using title and CSS but in most cases in
  1554. 1:14:0699 persons the descriptions will always
  1555. 1:14:09be at least one line so if the
  1556. 1:14:11description is like long enough then
  1557. 1:14:14this card will be on full width but of
  1558. 1:14:16course like we can add some tolerances
  1559. 1:14:18classes to stretch the Turn full width
  1560. 1:14:20what I don't like is
  1561. 1:14:22the
  1562. 1:14:24date how this looks like so let's create
  1563. 1:14:27actually
  1564. 1:14:28a function like git a formatted date
  1565. 1:14:33something like this and let's open now
  1566. 1:14:36this post and create
  1567. 1:14:39formatted data we're going to return
  1568. 1:14:41this
  1569. 1:14:44published it in the published it
  1570. 1:14:47actually needs to be an instance of
  1571. 1:14:52carbon by default published it will be I
  1572. 1:14:56think it will be string
  1573. 1:14:58um
  1574. 1:15:00actually that's good point to actually
  1575. 1:15:02see what's published at so this
  1576. 1:15:07published it
  1577. 1:15:10okay now let's see what's published it
  1578. 1:15:12that's a string as I mentioned but if we
  1579. 1:15:16create a protected variable costs right
  1580. 1:15:19here and specify that published it I
  1581. 1:15:22want this to be like date time then this
  1582. 1:15:27will be an instance of carbon so if I
  1583. 1:15:30say this and Rule of the page now we see
  1584. 1:15:33that this is an instance of carbon okay
  1585. 1:15:35and on this date time right here I can
  1586. 1:15:39call method like format and specify the
  1587. 1:15:42format so I want the format to be F oh
  1588. 1:15:47let's put in the string F then J
  1589. 1:15:50uppercase s and Y so you will see what's
  1590. 1:15:56the formats
  1591. 1:15:57and I'm going to just uh reload the page
  1592. 1:16:00so here we see so J is the name of the
  1593. 1:16:04math
  1594. 1:16:05then we have sorry f is the name of the
  1595. 1:16:09math then we have J which is the number
  1596. 1:16:13day of the month
  1597. 1:16:15and then we have this uppercase s which
  1598. 1:16:18is the um
  1599. 1:16:21this Rd or first if it's a one it's
  1600. 1:16:24going to be St if it's 2 it's going to
  1601. 1:16:28be in D I think it's called ordinal
  1602. 1:16:30index
  1603. 1:16:32mature so if we just search for like PHP
  1604. 1:16:35date time format you will see the actual
  1605. 1:16:39name of what is this like uppercase
  1606. 1:16:43s
  1607. 1:16:45somewhere right here
  1608. 1:16:52I'm just curious
  1609. 1:16:55here it is ordinal suffix exactly okay
  1610. 1:16:59so that's uppercases and if you want to
  1611. 1:17:01like change the formatting you can find
  1612. 1:17:03all the formats possible forms right
  1613. 1:17:04here so I'm going to close this okay now
  1614. 1:17:06we have dates uh now have user
  1615. 1:17:09and we have the listing actually the
  1616. 1:17:12category is actually also correctly
  1617. 1:17:14outputted however the image is not
  1618. 1:17:17correctly outputted and if we inspect
  1619. 1:17:18the image to see what's the path and we
  1620. 1:17:21see right here that we don't have
  1621. 1:17:24like um this is localhost Slash the file
  1622. 1:17:27name so probably storage is missing
  1623. 1:17:31right there so if I go in the thumbnail
  1624. 1:17:34input slash storage
  1625. 1:17:37save and just reload
  1626. 1:17:40here we go so we have now
  1627. 1:17:43we have now images available
  1628. 1:17:46so I think that's pretty cool now we can
  1629. 1:17:49think this is pretty cool now I think we
  1630. 1:17:52can move on the pagination
  1631. 1:17:54to actually activate the pagination we
  1632. 1:17:56need more than two items two posts I'm
  1633. 1:18:00gonna go ahead and create all the posts
  1634. 1:18:01and see that I'm gonna use a cedar for
  1635. 1:18:04this let's bring up the terminal and I'm
  1636. 1:18:06going to execute PHP artisan make I'm
  1637. 1:18:11going to create Factory that's going to
  1638. 1:18:13post Factory
  1639. 1:18:15see the internal is open post Factory
  1640. 1:18:22here it goes and we have to define the
  1641. 1:18:25definitions for the fields for each
  1642. 1:18:27field so we have title
  1643. 1:18:31which is going to be like a fake title
  1644. 1:18:35so actually I'm going to create a
  1645. 1:18:37variable right here title which will be
  1646. 1:18:39like fake
  1647. 1:18:41uh real real text and we can specify
  1648. 1:18:45this real text the length of the text as
  1649. 1:18:47well like 50 for example let's specify
  1650. 1:18:50so we need title right here we also need
  1651. 1:18:53the slack which needs to be generated
  1652. 1:18:55from the title that's why I created
  1653. 1:18:56title as a variable so I'm going to use
  1654. 1:18:58the Str slag method for this passing
  1655. 1:19:02title we will need thumbnail
  1656. 1:19:06thumb up
  1657. 1:19:08nail which is going to be
  1658. 1:19:14image URL we will need body
  1659. 1:19:20make
  1660. 1:19:22real text and in the real text we can
  1661. 1:19:24specify like a large
  1662. 1:19:27number
  1663. 1:19:29or Max characters we need active
  1664. 1:19:33which needs to be
  1665. 1:19:37Boolean
  1666. 1:19:39and we have
  1667. 1:19:42published
  1668. 1:19:44excuse me published it which needs to be
  1669. 1:19:50a random date time
  1670. 1:19:53okay like this and user ID let's specify
  1671. 1:19:57at the moment user wants so basically
  1672. 1:19:59every uh post created by this Factory
  1673. 1:20:02will belong to the user one now let's
  1674. 1:20:05open
  1675. 1:20:07a data base Cedar and let's uncomment
  1676. 1:20:11this Factory and change this into post
  1677. 1:20:14and we want to create like a 50
  1678. 1:20:18posts using this database seater so PHP
  1679. 1:20:22Artisan DB colon seed let's hit the
  1680. 1:20:26enter setting database it was finished
  1681. 1:20:28now let's reload the page
  1682. 1:20:33and we have those posts created which is
  1683. 1:20:37fantastic the images are broken because
  1684. 1:20:40every image now has a slash storage
  1685. 1:20:44before that okay so I guess that's okay
  1686. 1:20:48for now because we just uh like fake
  1687. 1:20:51created the post and the URL basically
  1688. 1:20:53is an absolute URL from the uh
  1689. 1:20:56placeholder via placeholder.com so in
  1690. 1:20:59our application we won't have that like
  1691. 1:21:01the absolute URLs but it's going to be
  1692. 1:21:04good addition into the system if we
  1693. 1:21:06create a function right here which will
  1694. 1:21:09check if the URL starts with HTTP then
  1695. 1:21:13it's going to return different thing
  1696. 1:21:15otherwise it's going to return different
  1697. 1:21:16things so basically I'm going to use Str
  1698. 1:21:21hearts
  1699. 1:21:23excuse me what I'm doing
  1700. 1:21:26stupid mistake so get get thumbnail
  1701. 1:21:30maybe so inside get thumbnail I'm going
  1702. 1:21:33to check if Str come on
  1703. 1:21:38starts with I'm going to specify if this
  1704. 1:21:42thumbnail if that starts with http
  1705. 1:21:47then I'm going to return this
  1706. 1:21:51thumbnail
  1707. 1:21:52okay
  1708. 1:21:54let's put semicolon otherwise we are
  1709. 1:21:57going to return slash storage slash
  1710. 1:22:00company
  1711. 1:22:02so I save this and now all the images
  1712. 1:22:05should be rendered properly
  1713. 1:22:08okay we have this one this one but the
  1714. 1:22:10others are not rendered now let's check
  1715. 1:22:12what's going on
  1716. 1:22:16okay that storage is still aided
  1717. 1:22:18if Str starts with
  1718. 1:22:22so if the thumbnail starts with http
  1719. 1:22:26it's gonna return this thumbnail
  1720. 1:22:30excuse me I don't use this gate terminal
  1721. 1:22:32so I I generally make such type of
  1722. 1:22:34mistakes very often so I create that
  1723. 1:22:36everything looks good I'm surprised why
  1724. 1:22:39it doesn't work
  1725. 1:22:40stupid mistake we don't use that
  1726. 1:22:44it
  1727. 1:22:45thumbnail
  1728. 1:22:47here we go load the page
  1729. 1:22:51Okay okay something is wrong
  1730. 1:22:54now it's broken for
  1731. 1:22:57everything
  1732. 1:23:00storage so we have storage twice I think
  1733. 1:23:02they should be removed that's it
  1734. 1:23:06that's more like it
  1735. 1:23:09no it's not
  1736. 1:23:10more like it
  1737. 1:23:14yeah the other images are there
  1738. 1:23:16but our actual images are not there
  1739. 1:23:21why
  1740. 1:23:23because I don't
  1741. 1:23:25concatenate this with these
  1742. 1:23:31another stupid mistake no this uh
  1743. 1:23:35okay challenge do you know what will
  1744. 1:23:37happen if I leave this code like this
  1745. 1:23:40just think for five seconds pause the
  1746. 1:23:43video think for five seconds and just
  1747. 1:23:45let me know
  1748. 1:23:48let me know in the comment section down
  1749. 1:23:49below what was your thoughts but that's
  1750. 1:23:52gonna definitely cause the uh rushing
  1751. 1:23:55our browser server because we are
  1752. 1:23:57calling git thumbnail inside get
  1753. 1:23:59thumbnail and just like this we will
  1754. 1:24:01crush it
  1755. 1:24:03it's basically a recursive function
  1756. 1:24:05without base case Okay so we're gonna
  1757. 1:24:08use this get thumbnail now if I reload
  1758. 1:24:11the page we see the images there
  1759. 1:24:15okay so now we have
  1760. 1:24:18more than enough post items to implement
  1761. 1:24:22actually
  1762. 1:24:23a G nation so let's go in the post
  1763. 1:24:25controller and I'm going to set the page
  1764. 1:24:27Niche 18 to 5. so to make the scrolling
  1765. 1:24:31easier and now let's go in the home
  1766. 1:24:35and we have this hard-coded pagination
  1767. 1:24:37links and at the top of that
  1768. 1:24:39we are going to Output post links the
  1769. 1:24:43post basically is a variable which is a
  1770. 1:24:47paginator variable instance of the
  1771. 1:24:49paginator and then links will simply
  1772. 1:24:52render
  1773. 1:24:55hosts excuse me posts links
  1774. 1:24:59links will will render the pagination
  1775. 1:25:02buttons as you see right here okay but
  1776. 1:25:05we need to adjust these pagination
  1777. 1:25:08buttons try to create the same design as
  1778. 1:25:12we have down below
  1779. 1:25:14okay and we just need to publish the
  1780. 1:25:17paginator views and modify it so if I
  1781. 1:25:20open now laravel documentation laravel
  1782. 1:25:28go in the documentation and search for
  1783. 1:25:30agination
  1784. 1:25:33then let's search for publish
  1785. 1:25:36here we go so under Section like
  1786. 1:25:39customizing The pagination View we can
  1787. 1:25:42publish the lateral pagination views and
  1788. 1:25:44then we can customize that okay so I'm
  1789. 1:25:46going to copy this command open the
  1790. 1:25:48terminal and paste this and hit the
  1791. 1:25:51enter so it's actually published the
  1792. 1:25:53pagination assets and we can find this
  1793. 1:25:56under resources views vendor pagination
  1794. 1:25:58so let's go under resources views vendor
  1795. 1:26:03pagination in this idea we have
  1796. 1:26:05different versions for pagination like
  1797. 1:26:08bootstrap four five some semantic UI Etc
  1798. 1:26:11so what we are interested is the tile
  1799. 1:26:13wind blade because this is the default
  1800. 1:26:15one which is used to just test it if
  1801. 1:26:18this is the actual one I'm going to
  1802. 1:26:19delete everything say that and reload
  1803. 1:26:22the website and we won't see this
  1804. 1:26:25pagination anymore okay so let's undo
  1805. 1:26:27this and now let's actually tweak this
  1806. 1:26:29we have to make few changes right here
  1807. 1:26:32let's have a look in the home so we have
  1808. 1:26:35the following classes for the pagination
  1809. 1:26:38item which is actually active so this
  1810. 1:26:41one is indicate indicates that the item
  1811. 1:26:44is active so let's actually copy this
  1812. 1:26:48open our
  1813. 1:26:50Talent blade and find the if statement
  1814. 1:26:54which indicates which one is actually
  1815. 1:26:56active so I think this is for the mobile
  1816. 1:27:02and this is for desktop okay let's focus
  1817. 1:27:04on the desktop fully
  1818. 1:27:06so here we have this is showing how many
  1819. 1:27:09items we're going to have so this let's
  1820. 1:27:12roll over the page
  1821. 1:27:14so it's showing so we don't actually
  1822. 1:27:17have this in our design so let's
  1823. 1:27:19actually remove it I'm going to remove
  1824. 1:27:21the showing now if the paginator is on
  1825. 1:27:24the first page then we render the
  1826. 1:27:26previous we're going to take care of
  1827. 1:27:28these a little bit later
  1828. 1:27:30in this case we have this previous URL
  1829. 1:27:37uh okay where is that
  1830. 1:27:41that's for three dot separator which we
  1831. 1:27:44I think also don't need but let's scroll
  1832. 1:27:47down below here it is so if the page is
  1833. 1:27:49current page then these are the classes
  1834. 1:27:52we are going to add
  1835. 1:27:54so I'm gonna now paste this save and
  1836. 1:27:57have a look
  1837. 1:28:00okay this is it okay that looks exactly
  1838. 1:28:03as this one now let's create styles for
  1839. 1:28:07the second one
  1840. 1:28:08now let's go in home
  1841. 1:28:10this is for the second
  1842. 1:28:14I think we need to add these classes
  1843. 1:28:16right here
  1844. 1:28:21here we go I'm going to paste this or
  1845. 1:28:24reload the page
  1846. 1:28:26okay that's good there's also Shadow on
  1847. 1:28:30this I'm going to remove that shadow
  1848. 1:28:38where's that shadow
  1849. 1:28:41this is for next
  1850. 1:28:43Shadow will be right here on the span
  1851. 1:28:50okay now we don't have shadows we have a
  1852. 1:28:52horror effect now let's implement the
  1853. 1:28:54next button
  1854. 1:28:56so scroll down below if paginator has
  1855. 1:29:00more pages then this is for the next one
  1856. 1:29:02otherwise this is probably next but it's
  1857. 1:29:06going to be disabled so we don't show
  1858. 1:29:09disable the next pattern instead we can
  1859. 1:29:11remove that
  1860. 1:29:12but if there's more pages we need to
  1861. 1:29:15show this next and let's take classes
  1862. 1:29:17for the next one
  1863. 1:29:24here are the classes I'm going to paste
  1864. 1:29:26that and also let's take this font
  1865. 1:29:29awesome icon
  1866. 1:29:32this one for the next one let's remove
  1867. 1:29:34this SVG
  1868. 1:29:36and paste the font awesome icon I'm
  1869. 1:29:39going to save that reload the page
  1870. 1:29:42and this is the next icon
  1871. 1:29:45let's specify by the way text as well
  1872. 1:29:48next
  1873. 1:29:51okay perfect so we have imagination
  1874. 1:29:53links and the next button and when we
  1875. 1:29:55click on the next button it actually
  1876. 1:29:57changes into page two now let's
  1877. 1:30:00Implement previews in the same way in
  1878. 1:30:03the exact same way so basically
  1879. 1:30:05I can copy this
  1880. 1:30:07and find where's the previous that
  1881. 1:30:10should be at the top
  1882. 1:30:14right here probably if paginator is on
  1883. 1:30:17the first page then we show disabled
  1884. 1:30:20previous which we don't need so I'm
  1885. 1:30:22going to actually change this if the
  1886. 1:30:24page editor is not on the first page and
  1887. 1:30:26delete that and else statement
  1888. 1:30:29and this is where we're going to display
  1889. 1:30:31the previews so I'm going to paste my
  1890. 1:30:34copied anchor link
  1891. 1:30:36okay let's format the code so we need to
  1892. 1:30:39change the url
  1893. 1:30:41to be previous
  1894. 1:30:43let's remove this
  1895. 1:30:45let's first display the arrow but the
  1896. 1:30:49arrow should not be right it should be
  1897. 1:30:50left
  1898. 1:30:51and then let's write priv right here and
  1899. 1:30:55also right here there is a margin left 2
  1900. 1:30:57which should be changed into margin
  1901. 1:30:58right two
  1902. 1:31:00and right here we also have margin left
  1903. 1:31:02I'm going to replace this in margin
  1904. 1:31:04right so I save that
  1905. 1:31:06reload the page
  1906. 1:31:08and C
  1907. 1:31:10here we go so we have previous next and
  1908. 1:31:13every link if I click previous once
  1909. 1:31:15again we are on the first page and we
  1910. 1:31:17don't see previous anymore this is
  1911. 1:31:19exactly how we want it if I go next
  1912. 1:31:24next
  1913. 1:31:25that works now click on the last one
  1914. 1:31:29and then we don't see next anymore okay
  1915. 1:31:32perfect if I go in the home right now by
  1916. 1:31:36the way how the pagination looks like on
  1917. 1:31:39the
  1918. 1:31:40yeah so this is how it looks like on
  1919. 1:31:43mobile so we don't even need these
  1920. 1:31:44previews and next and we can leave the
  1921. 1:31:47same thing uh for um
  1922. 1:31:51or mobile as well so let me actually
  1923. 1:31:52remove that we don't need open tilewind
  1924. 1:31:56scroll up that should be should not be
  1925. 1:32:00hidden so I'm going to remove that
  1926. 1:32:04it should be Flex always and let's
  1927. 1:32:08remove this above which is only for
  1928. 1:32:10mobile
  1929. 1:32:12save reload the page
  1930. 1:32:14here we see however it makes sense why
  1931. 1:32:19larval has different type of pagination
  1932. 1:32:22on mobile simply because this doesn't
  1933. 1:32:25look good on mobile isn't is it an
  1934. 1:32:27actual Mobile screen let's check this
  1935. 1:32:31let's switch to iPhone
  1936. 1:32:34that's fine but if there are more than
  1937. 1:32:36like seven pages then this will look bad
  1938. 1:32:40let's go in the pagination and change
  1939. 1:32:41this into two
  1940. 1:32:48okay displays these three dots right
  1941. 1:32:52there and there are a lot of positions
  1942. 1:32:54so actually let's go in the talent and
  1943. 1:32:56do this we need this on mobile and we
  1944. 1:32:59can leave that as it is right now and
  1945. 1:33:02let's undo this CSS class as well so on
  1946. 1:33:06pagination it will be like it was before
  1947. 1:33:09that next and previous pythons will be
  1948. 1:33:13there you get the idea you can customize
  1949. 1:33:15those buttons If you don't like
  1950. 1:33:17but that's fine
  1951. 1:33:20okay I'm going to remove because there
  1952. 1:33:23are too many links in my opinion so
  1953. 1:33:24let's go under home and before calling
  1954. 1:33:28links I'm going to call
  1955. 1:33:31uh actually that's good point so I want
  1956. 1:33:33to show you something so
  1957. 1:33:35if I just debug the posts and have a
  1958. 1:33:40look so this is an instance of length
  1959. 1:33:43aware paginator so I'm going to copy
  1960. 1:33:45that class name maybe the fully
  1961. 1:33:48qualified name and I'm going to Define
  1962. 1:33:52right here I'm going to annotate that
  1963. 1:33:54variable so
  1964. 1:33:56like this so variable
  1965. 1:34:00of posts is an instance of this length
  1966. 1:34:04aware paginator okay now if I try to use
  1967. 1:34:08posts and call some methods uh PHP
  1968. 1:34:12stream autocompletes everything what is
  1969. 1:34:14available there okay
  1970. 1:34:16uh I think
  1971. 1:34:21on each side on each side exactly this
  1972. 1:34:23is what I want so I'm going to set on
  1973. 1:34:25each side to be one if I save this now
  1974. 1:34:29and reload the page scroll down below
  1975. 1:34:31now we have a one on each side of the
  1976. 1:34:36active menu item okay and that makes
  1977. 1:34:39more sense
  1978. 1:34:40so
  1979. 1:34:41we we learned how we can actually
  1980. 1:34:44customize these on each side that's
  1981. 1:34:46pretty cool
  1982. 1:34:47now let's go in the post controller and
  1983. 1:34:49I'm going to change this into 10 I'm
  1984. 1:34:51going to display 10 items per page and
  1985. 1:34:53since we have implemented now listing of
  1986. 1:34:55the uh posts we're going to do a couple
  1987. 1:34:57of things so I'm going to clean up the
  1988. 1:34:59layout I don't need these images right
  1989. 1:35:01here Instagram section can be removed we
  1990. 1:35:04need the About Us section I'm going to
  1991. 1:35:06leave that I'm going to also clean up
  1992. 1:35:07the footer basically I'm going to
  1993. 1:35:09prepare everything as it should be
  1994. 1:35:10finally and we're going to also make
  1995. 1:35:12this about text
  1996. 1:35:15like content to be editable from the
  1997. 1:35:17admin side and also the um about us page
  1998. 1:35:22should be also created so let's go let's
  1999. 1:35:25remove this we don't see any items
  2000. 1:35:27that's that's fine now let's go in the
  2001. 1:35:31uh up blade and let's clean up a few
  2002. 1:35:36things if we start from the top
  2003. 1:35:38we have this top bar which can be
  2004. 1:35:42removed
  2005. 1:35:43that's fine we have minimal blog I'm
  2006. 1:35:45going to actually call this the code
  2007. 1:35:47holic blog let's say this this is Laura
  2008. 1:35:51mipsum text which is like a main
  2009. 1:35:54sentence about what you want to tell
  2010. 1:35:57your readers okay so this is something
  2011. 1:35:59which should be configurable from the
  2012. 1:36:01admin side
  2013. 1:36:02let's remove the Instagram section
  2014. 1:36:06here we go so let's
  2015. 1:36:08remove it
  2016. 1:36:10and in the footer there's this Carousel
  2017. 1:36:13so we can remove this Carousel and this
  2018. 1:36:17script tag for the carousel data as well
  2019. 1:36:22okay let's zoom out to have a
  2020. 1:36:26overall look
  2021. 1:36:28okay not too bad
  2022. 1:36:32not too bad
  2023. 1:36:34okay and down below let's remove the
  2024. 1:36:37links from the footer as well
  2025. 1:36:39we don't need that this is myblog.com
  2026. 1:36:43let's leave it and instead of padding
  2027. 1:36:45bottom we're going to have padding y
  2028. 1:36:47vertical
  2029. 1:36:48okay perfect
  2030. 1:36:54nice now let's make those texts editable
  2031. 1:36:57I'm going to actually create
  2032. 1:37:00a new table for that PHP artisan make
  2033. 1:37:04model
  2034. 1:37:08text
  2035. 1:37:10widget and dash M for immigration as
  2036. 1:37:14well create text widget table and let's
  2037. 1:37:18specify a few things right here like we
  2038. 1:37:20need image and title so let's define
  2039. 1:37:23table
  2040. 1:37:26string
  2041. 1:37:28image
  2042. 1:37:30that should be like 2000 48 that can be
  2043. 1:37:35nullable
  2044. 1:37:36let's duplicate this two times we need
  2045. 1:37:39titone
  2046. 1:37:41which can also be nullable so I'm going
  2047. 1:37:43to make everything nullable and I'm
  2048. 1:37:45going to explain why I do this and
  2049. 1:37:47contents well I think we can make title
  2050. 1:37:50required that's okay
  2051. 1:37:53and the content needs to be long text
  2052. 1:37:58and it must definitely be knowledgeable
  2053. 1:38:00and let's specify also active which
  2054. 1:38:03needs to be Boolean
  2055. 1:38:07like this and that by default will be
  2056. 1:38:11false so now we have this table ready
  2057. 1:38:13I'm going to add one additional column
  2058. 1:38:14it's going to be key
  2059. 1:38:16tring
  2060. 1:38:18e
  2061. 1:38:19and that must be required and that must
  2062. 1:38:23be unique as well
  2063. 1:38:25so basically the idea is that that's
  2064. 1:38:27going to be a universal table for saving
  2065. 1:38:30some text contents for your website like
  2066. 1:38:34we're going to create
  2067. 1:38:35About Us section for example the key
  2068. 1:38:37will be about us and you can specify
  2069. 1:38:40image or title and content and then
  2070. 1:38:42based on that this is extra based on
  2071. 1:38:45that we can select the data from the
  2072. 1:38:48database and output in certain places in
  2073. 1:38:52our website so that's that's good we
  2074. 1:38:56have this text widget ready
  2075. 1:38:59let's we don't have actually ready we
  2076. 1:39:01just create migration PHP Artisan
  2077. 1:39:04migrate
  2078. 1:39:07and that was applied now let's open text
  2079. 1:39:10widget
  2080. 1:39:11and I'm going to Define right here few
  2081. 1:39:14helper methods
  2082. 1:39:17first let's define a fillable
  2083. 1:39:20properties like e let's let me copy
  2084. 1:39:25everything
  2085. 1:39:27all of them are fillable
  2086. 1:39:36like this
  2087. 1:39:39okay next let's define a public static
  2088. 1:39:43function git title and this will accept
  2089. 1:39:47string e
  2090. 1:39:49and this should return the it should
  2091. 1:39:52select text widget based on the key and
  2092. 1:39:56then just a return the value of the
  2093. 1:39:58title so we are going to query widget
  2094. 1:40:01which will be text
  2095. 1:40:06widget query
  2096. 1:40:08where
  2097. 1:40:11key
  2098. 1:40:13equals
  2099. 1:40:15given key and we have to also specify
  2100. 1:40:18active status
  2101. 1:40:20where
  2102. 1:40:21active
  2103. 1:40:23corresponds to
  2104. 1:40:271.
  2105. 1:40:29or true
  2106. 1:40:30and we're going to call First on this so
  2107. 1:40:33we're just going to grab the text widget
  2108. 1:40:35and let's check now if the widget was
  2109. 1:40:39selected
  2110. 1:40:43then I'm going to return
  2111. 1:40:45a widget
  2112. 1:40:47title
  2113. 1:40:49otherwise I'm going to return an empty
  2114. 1:40:51string
  2115. 1:40:54like this
  2116. 1:40:56so let's try now to create
  2117. 1:41:01uh no let me first actually duplicate
  2118. 1:41:03this let's prepare everything right here
  2119. 1:41:04so I'm going to duplicate this and
  2120. 1:41:06create second function get content
  2121. 1:41:09which is doing something similar
  2122. 1:41:13but we actually also need probably two
  2123. 1:41:18add caching I'm going to do also caching
  2124. 1:41:21but first let's select text widget based
  2125. 1:41:24on the key and active and then if the
  2126. 1:41:28widget is found we are going to return
  2127. 1:41:30content
  2128. 1:41:32otherwise we're going to return an empty
  2129. 1:41:34string
  2130. 1:41:36okay and we might call
  2131. 1:41:40like we might select one widget and we
  2132. 1:41:43want both title
  2133. 1:41:45and content from the widget so if we do
  2134. 1:41:49like these then this method will be
  2135. 1:41:52executed and this method will be
  2136. 1:41:54executed also and this will cause
  2137. 1:41:57selecting text widgets the same text we
  2138. 1:42:00just twice why don't we cache our
  2139. 1:42:03selected text widget
  2140. 1:42:05so if we need to select it second time
  2141. 1:42:07it's going to serve from the cache okay
  2142. 1:42:11that's I think really good optimization
  2143. 1:42:14point so let's use now cache
  2144. 1:42:19uh which cache is that
  2145. 1:42:23illuminate support for size cache then
  2146. 1:42:26we are gonna call get we need to specify
  2147. 1:42:29some kind of key like text to widget for
  2148. 1:42:32example Dash in the text widget key so
  2149. 1:42:36that's going to be based on that key it
  2150. 1:42:38will either get it from the cache or
  2151. 1:42:40select then we have function let's use
  2152. 1:42:45uh key right here
  2153. 1:42:48and we are going to return these parts
  2154. 1:42:55okay and finally we're going to assign
  2155. 1:42:58this into widget
  2156. 1:43:02so what this will do is try to get
  2157. 1:43:05the content from the cache using that
  2158. 1:43:09key if the content didn't exist then it
  2159. 1:43:12will execute that function that function
  2160. 1:43:14will just uh run the following code it
  2161. 1:43:17will return the value and the cache
  2162. 1:43:20component cache facade then we'll set
  2163. 1:43:22that into into cash as well I think it
  2164. 1:43:26should have get
  2165. 1:43:28get or said or something like this
  2166. 1:43:32so we're going to test this as I
  2167. 1:43:34remember it will simply return that but
  2168. 1:43:37we can test this so if we're going to
  2169. 1:43:39get
  2170. 1:43:40also
  2171. 1:43:42we don't see that
  2172. 1:43:46okay I'm sure we can figure this out a
  2173. 1:43:48little bit later but I just want to
  2174. 1:43:51mention that when you're developing
  2175. 1:43:53something if you think
  2176. 1:43:55putting a little bit extra effort
  2177. 1:43:59beforehand and then you can finally have
  2178. 1:44:02a much better product for example you
  2179. 1:44:04don't select your the same objects twice
  2180. 1:44:07in the code we can figure this out
  2181. 1:44:09working also debug this but a little bit
  2182. 1:44:12later
  2183. 1:44:14okay so we can do the same thing right
  2184. 1:44:16here so I'm going to just simply get
  2185. 1:44:18this
  2186. 1:44:22and remove that
  2187. 1:44:26excuse me
  2188. 1:44:29delete that
  2189. 1:44:34return this
  2190. 1:44:36and we're gonna assign this into widget
  2191. 1:44:43okay perfect
  2192. 1:44:46now let's generate filament resource for
  2193. 1:44:49the tech switches PHP art design make
  2194. 1:44:53element Dash resource let's specify text
  2195. 1:44:58or widget a resource
  2196. 1:45:01generate
  2197. 1:45:09let's see the enter text widget resource
  2198. 1:45:11was generated now let's check the admin
  2199. 1:45:14panel we have text switches
  2200. 1:45:16and that's perfect
  2201. 1:45:18that's super cool uh let's modify text
  2202. 1:45:22widget resource text
  2203. 1:45:26text
  2204. 1:45:28widget resource
  2205. 1:45:31let's change the
  2206. 1:45:35group navigation group to be content
  2207. 1:45:40we have key which must be required we
  2208. 1:45:44have image which must be file upload
  2209. 1:45:48uh we have title which must be required
  2210. 1:45:51we have content and active
  2211. 1:45:55in the table we can have just
  2212. 1:45:58key
  2213. 1:45:59pain title we don't need
  2214. 1:46:02in status maybe an updated okay we just
  2215. 1:46:06need more than expected so and let's
  2216. 1:46:09actually change this to show inside the
  2217. 1:46:12form everything in a single column like
  2218. 1:46:14columns one
  2219. 1:46:16like this now let's specify about us
  2220. 1:46:19sidebar for example as a key and then
  2221. 1:46:23let's choose some sort of image do we
  2222. 1:46:25need image on the about a sidebar no we
  2223. 1:46:28don't need that let's specify title
  2224. 1:46:30about us for example and content which
  2225. 1:46:34is this well it's a lorem ipsum but you
  2226. 1:46:37can type about me so I am
  2227. 1:46:42um
  2228. 1:46:42developer with 11
  2229. 1:46:46plus years of experience that's it
  2230. 1:46:51okay let's make it active and I'm gonna
  2231. 1:46:53create that
  2232. 1:46:55and when this is created I want it to be
  2233. 1:46:57redirected to the listing page so I will
  2234. 1:47:01go
  2235. 1:47:02into text widget resource create text
  2236. 1:47:05widget and just override the
  2237. 1:47:09function
  2238. 1:47:10which I think I did in the posts
  2239. 1:47:15uh no I haven't done this in the posts
  2240. 1:47:18uh get redirect URL where do they do it
  2241. 1:47:22I think I haven't done this okay let's
  2242. 1:47:24check these filaments
  2243. 1:47:27uh redirect customizing form redirects
  2244. 1:47:31here we have this gate redirect URL I'm
  2245. 1:47:34going to copy that
  2246. 1:47:35and paste in the text widget resource
  2247. 1:47:39now
  2248. 1:47:40we need create text resource paste this
  2249. 1:47:43right here
  2250. 1:47:45save that
  2251. 1:47:47call in the filament I think we need to
  2252. 1:47:49do the same thing in update
  2253. 1:47:5280 text resource
  2254. 1:47:58so now if I edit these
  2255. 1:48:03and click save I'm redirected to the
  2256. 1:48:06list which is exactly what I want to do
  2257. 1:48:12I actually don't need the view page
  2258. 1:48:14probably
  2259. 1:48:16don't need view page so if I go in the
  2260. 1:48:19list text widgets
  2261. 1:48:24or maybe view text we just completely
  2262. 1:48:26delete that
  2263. 1:48:27and go in the text which is resource and
  2264. 1:48:31remove this View
  2265. 1:48:34what will happen
  2266. 1:48:35text widgets is included somewhere
  2267. 1:48:42let's remove it
  2268. 1:48:50okay now it opens edit page which is
  2269. 1:48:53exactly what I want
  2270. 1:48:55okay now let's go in the website and we
  2271. 1:48:57need to Output this about us text widget
  2272. 1:48:59right here so let's open sidebar
  2273. 1:49:04uh Side Bar
  2274. 1:49:06we don't have sidebars so let's create
  2275. 1:49:09this let's go in the home blade
  2276. 1:49:12and we render our section right here
  2277. 1:49:17okay where's the sidebar that is
  2278. 1:49:20probably in the up blade
  2279. 1:49:24here we go so this is a side
  2280. 1:49:27which in my opinion
  2281. 1:49:30should be
  2282. 1:49:32that in my opinion should be inside the
  2283. 1:49:36view so I'm going to take this out
  2284. 1:49:40and go in the home
  2285. 1:49:44we have this section which comes right
  2286. 1:49:46here
  2287. 1:49:47and then
  2288. 1:49:48below that section I will put the
  2289. 1:49:51sidebar
  2290. 1:49:53so the result
  2291. 1:49:55is identical
  2292. 1:49:58and now I'm going to make this as a
  2293. 1:50:00separate component
  2294. 1:50:03PHP artisan make
  2295. 1:50:06component
  2296. 1:50:08sidebar
  2297. 1:50:11okay well let's see the inter sidebar
  2298. 1:50:14component was created
  2299. 1:50:17cyber blade and now
  2300. 1:50:20let's get the aside
  2301. 1:50:23and
  2302. 1:50:26paste it here
  2303. 1:50:29and now let's output
  2304. 1:50:34text widget
  2305. 1:50:37get title and specify about us
  2306. 1:50:41sidebar which is the key
  2307. 1:50:44okay so then I'm going to copy this
  2308. 1:50:48and right here I'm gonna
  2309. 1:50:50output it
  2310. 1:50:53as an HTML
  2311. 1:50:59but I'm going to specify instead of gate
  2312. 1:51:01title I'm going to specify get
  2313. 1:51:03content let's change this into
  2314. 1:51:08let's leave this by the way we will have
  2315. 1:51:10to change this whenever the URL is
  2316. 1:51:12created but let's leave it as it is for
  2317. 1:51:14now
  2318. 1:51:15and let's have a look
  2319. 1:51:17if we go in the home blade we need to
  2320. 1:51:20use x
  2321. 1:51:21sidebar component
  2322. 1:51:24and here we go so we have this about us
  2323. 1:51:27which comes from the back end okay now
  2324. 1:51:29we have a possibility to fully customize
  2325. 1:51:31that text specify whatever you want as
  2326. 1:51:36well as change the title
  2327. 1:51:39uh save that reload here we go that view
  2328. 1:51:44button by the way needs to be removed
  2329. 1:51:47so if we simply go in the edit text and
  2330. 1:51:49view remove reload that's perfect
  2331. 1:51:54okay
  2332. 1:51:57now in the same way let's create a new
  2333. 1:52:01text widget for the following text
  2334. 1:52:05new widget
  2335. 1:52:06header let's call it just header header
  2336. 1:52:12and the content will be something you
  2337. 1:52:14know I'm going to just copy and paste
  2338. 1:52:16this
  2339. 1:52:17I don't want to
  2340. 1:52:19spend time on come up
  2341. 1:52:21something so that's active let's click
  2342. 1:52:24create
  2343. 1:52:25reload the page of course we haven't
  2344. 1:52:27used that
  2345. 1:52:28up blade
  2346. 1:52:31and at the very top we have this lorem
  2347. 1:52:34ipsum something so we will output text
  2348. 1:52:37widget get
  2349. 1:52:40get content
  2350. 1:52:42that's going to be Laura mips or
  2351. 1:52:43something actually
  2352. 1:52:46this one
  2353. 1:52:49will have a paragraph inside
  2354. 1:52:53so what we can do is just output the
  2355. 1:52:56header this is this is a title and we
  2356. 1:52:58can output the title in this case the
  2357. 1:53:00title should be this one
  2358. 1:53:04let me change this leave the content so
  2359. 1:53:07the content basically is more for HTML
  2360. 1:53:09content and by the way I haven't changed
  2361. 1:53:12this into Rich Text which I should have
  2362. 1:53:14done
  2363. 1:53:16let's change this into
  2364. 1:53:20here it is reach reach text reach editor
  2365. 1:53:24so this content is more for reach editor
  2366. 1:53:27and I'm going to specify this loading
  2367. 1:53:29with some here and if I go in the layout
  2368. 1:53:32now I want to Output the title for
  2369. 1:53:37header
  2370. 1:53:38save reload we see the same thing if I
  2371. 1:53:43modify this
  2372. 1:53:45we see now modify text so that shows
  2373. 1:53:48and this shows that it actually works
  2374. 1:53:51perfectly so these text widgets are
  2375. 1:53:54basically really handy in certain cases
  2376. 1:53:57so you have key and you can select uh
  2377. 1:53:59the text which is managed from the admin
  2378. 1:54:03panel in any place you want in the same
  2379. 1:54:06fashion we're going to create a little
  2380. 1:54:08bit later about page where we will
  2381. 1:54:11create a new text widget for the about
  2382. 1:54:13and we'll output that so I think that's
  2383. 1:54:16perfect now let's start working on the
  2384. 1:54:19post in your page let's open
  2385. 1:54:24web.php and create new roots
  2386. 1:54:27that will be simply
  2387. 1:54:30post right here but we have to specify
  2388. 1:54:33that I want to select the post by Slack
  2389. 1:54:37and we're going to have
  2390. 1:54:39show
  2391. 1:54:43and it's going to be View
  2392. 1:54:46what's going to show we already accept
  2393. 1:54:49posts right here but that post might not
  2394. 1:54:52be active
  2395. 1:54:54so we have to make an additional checks
  2396. 1:54:58like if post is not active
  2397. 1:55:03or
  2398. 1:55:06if post
  2399. 1:55:09published it is in the future
  2400. 1:55:14to specify carbon now
  2401. 1:55:16if that happens then let's just throw
  2402. 1:55:20new not found
  2403. 1:55:23HTTP exception
  2404. 1:55:26this one
  2405. 1:55:28okay otherwise we're going to proceed
  2406. 1:55:31and return View
  2407. 1:55:37show
  2408. 1:55:38and we have compact
  2409. 1:55:41here and we need to select actually post
  2410. 1:55:45no we don't need we have post so I'll
  2411. 1:55:47just specify post here
  2412. 1:55:49okay perfect
  2413. 1:55:51let's also have a look at the
  2414. 1:55:55blog template we are using and we have
  2415. 1:55:58to just copy the blog in your page Post
  2416. 1:56:02in your page content
  2417. 1:56:03before that let's create this
  2418. 1:56:07blade file and the resources we use
  2419. 1:56:11let's actually create
  2420. 1:56:14well that should be
  2421. 1:56:17post dot show
  2422. 1:56:21or maybe post start View
  2423. 1:56:24so under views let's create new file
  2424. 1:56:28post slash View
  2425. 1:56:32Dot blade.php
  2426. 1:56:37perfect we need to use x app layout
  2427. 1:56:42and now let's open our blog template
  2428. 1:56:47here it is Click get template
  2429. 1:56:50click on post HTML and click on enroll
  2430. 1:56:54so this is the HTML we need I'm going to
  2431. 1:56:57copy everything but we don't need to
  2432. 1:57:00have a layout so I'm going to paste it
  2433. 1:57:01and then clean up so we don't need this
  2434. 1:57:04HTML and talk type because we already
  2435. 1:57:06have layout defined but we don't need
  2436. 1:57:09the stop nav bar
  2437. 1:57:11we don't need this one
  2438. 1:57:13and the only thing what we need is this
  2439. 1:57:16post section so everything above
  2440. 1:57:19can be deleted
  2441. 1:57:21and everything below
  2442. 1:57:24can be deleted as well
  2443. 1:57:27like this so let's format the code I'm
  2444. 1:57:31going to save these
  2445. 1:57:33and reload the page and we actually have
  2446. 1:57:35to make proper links so I'm going to
  2447. 1:57:39open post item blade and let's specify
  2448. 1:57:43now proper links so here we need
  2449. 1:57:47Road
  2450. 1:57:48View
  2451. 1:57:50and we have to specify an actual post
  2452. 1:57:53let's copy this when we click on the
  2453. 1:57:56image
  2454. 1:57:58this is just for the categories when we
  2455. 1:58:01click on the title we want to open the
  2456. 1:58:03view page
  2457. 1:58:04and when we click on the body we want it
  2458. 1:58:07to open a view page as well so I save
  2459. 1:58:10that reload the page and let's click on
  2460. 1:58:13the image
  2461. 1:58:14you see so it opens the view page and
  2462. 1:58:17this is a slug we have an image this is
  2463. 1:58:21what's the
  2464. 1:58:23images done yeah everything is dummy
  2465. 1:58:25yeah I bet so everything is done right
  2466. 1:58:28here we have to make it uh active coming
  2467. 1:58:31from the database and we have to also
  2468. 1:58:33implement this previous in the next
  2469. 1:58:35buttons that's also very interesting and
  2470. 1:58:37I'm going to remove this user card at
  2471. 1:58:40the moment I don't need that
  2472. 1:58:42let's go in the view blade
  2473. 1:58:45let's expand this
  2474. 1:58:48and let's now output the image let me
  2475. 1:58:52actually get this from here
  2476. 1:58:54so this is an image
  2477. 1:58:56paste
  2478. 1:58:58I will need
  2479. 1:59:00I will need categories as well so I'm
  2480. 1:59:02going to copy that
  2481. 1:59:04and paste here
  2482. 1:59:06I will need titles
  2483. 1:59:10yeah
  2484. 1:59:11title as well
  2485. 1:59:14um we need to drink a water
  2486. 1:59:19like I'm talking uh one hour Non-Stop
  2487. 1:59:22and my my voice changes actually
  2488. 1:59:26so we have this categories let's format
  2489. 1:59:28these
  2490. 1:59:30and this is the actual post title so I'm
  2491. 1:59:33gonna get that
  2492. 1:59:36well
  2493. 1:59:37we need just post title we don't need
  2494. 1:59:39this to be an anchor link because that's
  2495. 1:59:42that's not necessary we are in the post
  2496. 1:59:45in your page so I'm going to change this
  2497. 1:59:47into H1 remove this href and have both
  2498. 1:59:50Title Here
  2499. 1:59:52and then we have the user information
  2500. 1:59:54and the publish date let's copy this get
  2501. 1:59:59formatted date as well
  2502. 2:00:02right here and let's get this username
  2503. 2:00:13okay so everything below is already part
  2504. 2:00:17of the body so I'm gonna delete that
  2505. 2:00:21I'm going to delete that and I'm going
  2506. 2:00:24to Output post buddy so let's wrap this
  2507. 2:00:28in a div
  2508. 2:00:29then we need post
  2509. 2:00:32body so we save that and have a look
  2510. 2:00:36so we have an actual image
  2511. 2:00:38title tag
  2512. 2:00:41and this is an HTML so we have to Output
  2513. 2:00:45it differently
  2514. 2:00:50like this
  2515. 2:00:53perfect
  2516. 2:00:55that's pretty cool let's remove the user
  2517. 2:00:58card
  2518. 2:00:59this is the user card let's remove it
  2519. 2:01:03and we have to implement next and
  2520. 2:01:05previous buttons so we have to do this
  2521. 2:01:07from the post controller we already have
  2522. 2:01:10that
  2523. 2:01:11post
  2524. 2:01:13selected by larval itself so now let's
  2525. 2:01:16select next item which will be post
  2526. 2:01:20query
  2527. 2:01:22we have to specify that we want only
  2528. 2:01:25active
  2529. 2:01:29by the way if I just specify here
  2530. 2:01:33um
  2531. 2:01:34true
  2532. 2:01:37will it work
  2533. 2:01:40we're gonna see
  2534. 2:01:41uh we are date
  2535. 2:01:45published it
  2536. 2:01:48is less than or equal
  2537. 2:01:52to carbon
  2538. 2:01:55carbon now
  2539. 2:01:59let's specify also
  2540. 2:02:04okay let me think so we have the post
  2541. 2:02:09if we have a look so this is let's say
  2542. 2:02:11this is the very first post and posts
  2543. 2:02:14are generally sorted by published
  2544. 2:02:16descending
  2545. 2:02:17so I want the next basically should
  2546. 2:02:20query
  2547. 2:02:22um host which is the first post
  2548. 2:02:25among those which has published date
  2549. 2:02:31less than the current post so we have to
  2550. 2:02:34also specify where
  2551. 2:02:38weird date like published it
  2552. 2:02:43is less than
  2553. 2:02:46less than
  2554. 2:02:48the current post
  2555. 2:02:54published it I think this is it and
  2556. 2:02:58let's order by
  2557. 2:03:01published it
  2558. 2:03:04underscore
  2559. 2:03:06descending and let's limit this into one
  2560. 2:03:10because I only want to get one
  2561. 2:03:13and then I'm going to call First on this
  2562. 2:03:16so we have next
  2563. 2:03:19uh let's double check this so I want to
  2564. 2:03:21query active post which has date Which
  2565. 2:03:25is less than or equal to now which means
  2566. 2:03:27that it must be published
  2567. 2:03:28and it's published date
  2568. 2:03:30is less than
  2569. 2:03:33the published date of the current post
  2570. 2:03:36I think that's logical and we order this
  2571. 2:03:38by the descending date which makes sure
  2572. 2:03:41that this is the very first among those
  2573. 2:03:43posts which has published at less than
  2574. 2:03:46the post date okay I'm going to
  2575. 2:03:49duplicate this and create call these
  2576. 2:03:52previews
  2577. 2:03:54in this case we need to change this less
  2578. 2:03:58than into greater than
  2579. 2:04:00and I think everything else stays the
  2580. 2:04:02same we have to provide here
  2581. 2:04:05we've and next variables now if I go in
  2582. 2:04:11The View
  2583. 2:04:12we have those two anchor tags
  2584. 2:04:15this is previous
  2585. 2:04:19and let's
  2586. 2:04:21let's specify right here title for
  2587. 2:04:24previous
  2588. 2:04:30title like this
  2589. 2:04:32and when to also handle the case when
  2590. 2:04:35the previous doesn't exist we're going
  2591. 2:04:37to do that but first I want to see an
  2592. 2:04:39error for that so here we need next
  2593. 2:04:43title
  2594. 2:04:45perfect
  2595. 2:04:47and if I
  2596. 2:04:49if I want those links to work as well I
  2597. 2:04:52have to provide right here Road
  2598. 2:04:55that's going to be View and I'm going to
  2599. 2:04:57specify previews
  2600. 2:05:00and right here
  2601. 2:05:02wrote
  2602. 2:05:03View
  2603. 2:05:05next
  2604. 2:05:07we save that reload the page and we have
  2605. 2:05:10an error the error is exactly I believe
  2606. 2:05:13right here that the previous doesn't
  2607. 2:05:15exist
  2608. 2:05:16missing required parameter for roads
  2609. 2:05:19yeah previous doesn't exist so I'm going
  2610. 2:05:21to add an extra if statement here if
  2611. 2:05:25previews exists
  2612. 2:05:28then we just render it
  2613. 2:05:32like this however this gives us the next
  2614. 2:05:36is not on the right side it is on the
  2615. 2:05:38left side so what I'm gonna do is create
  2616. 2:05:42two div elements
  2617. 2:05:45class width one over two
  2618. 2:05:48and duplicate these
  2619. 2:05:51this one should be here
  2620. 2:05:59and the other one should be
  2621. 2:06:03here
  2622. 2:06:05oops
  2623. 2:06:07hold on
  2624. 2:06:12like this so I'm sure that there will
  2625. 2:06:15always be two div elements rendered and
  2626. 2:06:18then inside there there should be
  2627. 2:06:21anchor links with display block and with
  2628. 2:06:25the full
  2629. 2:06:26I save and reload and I see next on the
  2630. 2:06:29right side if I click on the next it
  2631. 2:06:32opens the next post and now I should see
  2632. 2:06:35both previews and next well this doesn't
  2633. 2:06:38look really nice so probably we need to
  2634. 2:06:42use
  2635. 2:06:43here is to your helper
  2636. 2:06:46and just restrict this into number of
  2637. 2:06:48words like 10 maybe
  2638. 2:06:52that's too much maybe like five five
  2639. 2:06:55words
  2640. 2:06:57okay not too bad we can even increase
  2641. 2:06:59this into six six parts
  2642. 2:07:02um no it should be five
  2643. 2:07:05okay not bad so I'm going to click next
  2644. 2:07:08right here and that opens the next one
  2645. 2:07:10next and now let's go into previous okay
  2646. 2:07:14something
  2647. 2:07:16but it happened
  2648. 2:07:18so when I click next two times and then
  2649. 2:07:22I click reviews it opens the very first
  2650. 2:07:25one
  2651. 2:07:26which is not very accurate
  2652. 2:07:30if I double check the logic again
  2653. 2:07:37I think this should be
  2654. 2:07:39achievous ending
  2655. 2:07:48that should be ascending if I reload
  2656. 2:07:50click next once twice and now I click
  2657. 2:07:54previews it opens the previews and
  2658. 2:07:57another one is Javascript is weird
  2659. 2:08:00okay so we have actually implemented
  2660. 2:08:04the inner page for the Post
  2661. 2:08:07and we have implemented next in previous
  2662. 2:08:09buttons and I think we can move on the
  2663. 2:08:12next section now let's Implement
  2664. 2:08:14outputting categories in the sidebar
  2665. 2:08:18and in the main navigation as well so in
  2666. 2:08:21the main navigation I'm going to Output
  2667. 2:08:23top five categories by its number of
  2668. 2:08:30posts inside that category okay and in
  2669. 2:08:35the sidebar we're going to Simply show
  2670. 2:08:36all the categories what is available
  2671. 2:08:38right there but first let's make sure we
  2672. 2:08:41have the sidebar on the post in your
  2673. 2:08:43page so if I go in The View
  2674. 2:08:46and then we have the section
  2675. 2:08:48let's
  2676. 2:08:50let's create the very bottom and we are
  2677. 2:08:53going to display X
  2678. 2:08:55sidebar component right here so if I
  2679. 2:08:58save this reload we have this about us
  2680. 2:09:00so I'm going to display inside the
  2681. 2:09:03sidebar
  2682. 2:09:05all the categories
  2683. 2:09:09okay so here we have that
  2684. 2:09:11let's define right here
  2685. 2:09:14I'm going to create this same type of
  2686. 2:09:16div
  2687. 2:09:18and then inside there I'm going to
  2688. 2:09:21create a
  2689. 2:09:23H3 and let's specify text Excel and we
  2690. 2:09:28need font semi bold
  2691. 2:09:33and we need margin button three so let's
  2692. 2:09:35do like this
  2693. 2:09:37and that will be all categories
  2694. 2:09:41then I'm going to iterate categories but
  2695. 2:09:44I don't have any categories available in
  2696. 2:09:47this this component sidebar component so
  2697. 2:09:50let's open sidebar component
  2698. 2:09:54and first we have to select those
  2699. 2:09:58categories okay so I'm going to create
  2700. 2:10:02sidebar um sorry
  2701. 2:10:04categories equals and I'm going to copy
  2702. 2:10:08and paste the query and explain then
  2703. 2:10:12okay so let's import this category
  2704. 2:10:16so we are curing from a category We join
  2705. 2:10:19this into category post
  2706. 2:10:22and we're we're using the proper column
  2707. 2:10:25names categories ID cost category post
  2708. 2:10:27category ID then we select categories
  2709. 2:10:30title categories slag and we also query
  2710. 2:10:34count
  2711. 2:10:36um
  2712. 2:10:37count of everything as a total and we
  2713. 2:10:40grew by that by categories and order by
  2714. 2:10:44those total so this will query top five
  2715. 2:10:49categories sorted by number of hosts
  2716. 2:10:53inside that category
  2717. 2:10:55that's pretty cool right
  2718. 2:10:57so now we use compact in pass categories
  2719. 2:11:01here and if I go in this sidebar I have
  2720. 2:11:04categories available so I can already
  2721. 2:11:07iterate for each categories is category
  2722. 2:11:13and then we just need to display
  2723. 2:11:16anchor tag probably href and this is
  2724. 2:11:20something we need to create that wrote
  2725. 2:11:23posts by category
  2726. 2:11:25but then inside there we need category
  2727. 2:11:29title
  2728. 2:11:31and let's also specify some tolerances
  2729. 2:11:34classes like text is semi-bold
  2730. 2:11:40we need it to be block adding Y2 pining
  2731. 2:11:44Geeks three maybe and a little bit
  2732. 2:11:48rounded
  2733. 2:11:49okay let's make it like this and if I
  2734. 2:11:52reload the page we see all categories
  2735. 2:11:56right here
  2736. 2:11:58okay I think this looks this looks good
  2737. 2:12:02if I go in the categories
  2738. 2:12:04we have JavaScript PHP and laravel so
  2739. 2:12:07that that doesn't show the category
  2740. 2:12:10which does not have any items inside
  2741. 2:12:13there
  2742. 2:12:14and actually I want to also display
  2743. 2:12:16right here
  2744. 2:12:18category
  2745. 2:12:20total because that total is also
  2746. 2:12:23available because that is selected
  2747. 2:12:26inside there so I save that reload now
  2748. 2:12:29we see how many items are in each
  2749. 2:12:31category and if I change this join into
  2750. 2:12:35left join
  2751. 2:12:37then we're gonna also have a look in the
  2752. 2:12:42yeah let's range one of the categories
  2753. 2:12:44we are missing
  2754. 2:12:46but the
  2755. 2:12:49why was that missing
  2756. 2:12:52with the join
  2757. 2:12:55so that should be left joined for sure
  2758. 2:13:02okay we have now three categories and
  2759. 2:13:04I'm going to open the post generated
  2760. 2:13:07active posts by the database Cedar and
  2761. 2:13:11I'm gonna assign couple of them some
  2762. 2:13:14actual categories
  2763. 2:13:16for example let's move this into
  2764. 2:13:19JavaScript
  2765. 2:13:23let's open another one
  2766. 2:13:25move this into
  2767. 2:13:28JavaScript
  2768. 2:13:32now if I reload the page I see there are
  2769. 2:13:34three articles in JavaScript category
  2770. 2:13:37okay and just like this we'll have all
  2771. 2:13:39categories on the right side and when we
  2772. 2:13:41Implement a post Page by category and
  2773. 2:13:44when we click on this it's going to open
  2774. 2:13:46that page now let's take care of the
  2775. 2:13:48header as well in very very similar way
  2776. 2:13:50so I'm going to open up layout
  2777. 2:13:54app layout and right here we will need
  2778. 2:13:57to query
  2779. 2:13:59categories and by the way
  2780. 2:14:02this limit 5 is not necessary that query
  2781. 2:14:06is uh for app layout so I'm going to
  2782. 2:14:09remove this limit five
  2783. 2:14:12go in the Apple layout
  2784. 2:14:15and I'm going to just paste this
  2785. 2:14:19categories equals that
  2786. 2:14:22and then we provide
  2787. 2:14:26compact categories here
  2788. 2:14:29okay we need top five categories here
  2789. 2:14:32not inside sidebar
  2790. 2:14:37okay if we open up blade
  2791. 2:14:42this is the menu
  2792. 2:14:45so we have to iterate over categories is
  2793. 2:14:52category
  2794. 2:14:55let's move this up
  2795. 2:14:57and we are gonna output
  2796. 2:15:00a category
  2797. 2:15:02title
  2798. 2:15:05perfect let's add two more pages right
  2799. 2:15:09here
  2800. 2:15:10one will be home
  2801. 2:15:16right here we're going to have home and
  2802. 2:15:18let's adjust the URL to be wrote or home
  2803. 2:15:23and second will be about us
  2804. 2:15:28and that's gonna also have a road uh but
  2805. 2:15:31let's leave it at the moment because the
  2806. 2:15:33road doesn't exist yet so I save this
  2807. 2:15:35reload the page
  2808. 2:15:36and if any variable categories Double C
  2809. 2:15:40is not necessary here we go so we have a
  2810. 2:15:43home page we have JavaScript PHP lateral
  2811. 2:15:45all the categories what we have uh let
  2812. 2:15:48me actually quickly change the hover
  2813. 2:15:50color
  2814. 2:15:53PG array 400 let's change this into PG
  2815. 2:15:57like a blue
  2816. 2:15:59600 and maybe
  2817. 2:16:02over text white as well
  2818. 2:16:07okay much better
  2819. 2:16:11so we have now main navigation ready
  2820. 2:16:14when we click on the home that actually
  2821. 2:16:16works we have to implement now buy
  2822. 2:16:18category page and Implement also
  2823. 2:16:21clicking on that on the right side and
  2824. 2:16:23activate the uh activate all categories
  2825. 2:16:27actual category which is clicked that's
  2826. 2:16:30pretty interesting now let's go in the
  2827. 2:16:32post controller and
  2828. 2:16:35we have many actions we don't need them
  2829. 2:16:37I'm going to delete them
  2830. 2:16:40all of them actually and let's create
  2831. 2:16:43public function by category
  2832. 2:16:46here
  2833. 2:16:47it will accept category
  2834. 2:16:52and then we need to query
  2835. 2:16:54posts based on that category let's open
  2836. 2:16:58web.php as well and duplicate this
  2837. 2:17:02and I'm going to specify category slash
  2838. 2:17:07category by slug so we're going to
  2839. 2:17:10keyword it by category and the view name
  2840. 2:17:14will be by category as well
  2841. 2:17:19now let's open this by category and I'm
  2842. 2:17:22going to again copy and paste the query
  2843. 2:17:24and I'm going to explain what this query
  2844. 2:17:26is actually doing so we query posts but
  2845. 2:17:30we enjoy the post into a junction table
  2846. 2:17:33category post we are the posts ID equals
  2847. 2:17:36to the category post post ID then we
  2848. 2:17:40write it where we are category post
  2849. 2:17:42category ID is the given category ID we
  2850. 2:17:46also make sure that the post needs to be
  2851. 2:17:48active and the published date needs to
  2852. 2:17:51be in the past and we order everything
  2853. 2:17:54by publish date one small change we're
  2854. 2:17:58gonna what I'm going to make in the up
  2855. 2:18:01layout is that when I join this into
  2856. 2:18:06like category posts and I order by
  2857. 2:18:12order by total I don't consider that the
  2858. 2:18:15post needs to be active and it needs to
  2859. 2:18:18be published so this query
  2860. 2:18:21will also get the posts
  2861. 2:18:24which are not active or not published
  2862. 2:18:26the same thing will happen in the
  2863. 2:18:28sidebar
  2864. 2:18:30okay so just to make sure that I'm
  2865. 2:18:33correct I will go in the posts open the
  2866. 2:18:36one which is not active and the sign by
  2867. 2:18:40the way when I click on the post I want
  2868. 2:18:42it to start editing so I'm going to go
  2869. 2:18:45in the
  2870. 2:18:46post resource
  2871. 2:18:49and maybe
  2872. 2:18:52in the post resource and I'm going to
  2873. 2:18:54remove this view I don't need that
  2874. 2:18:58list posts
  2875. 2:19:01edit posts view action remove that
  2876. 2:19:09hand view action remove let's have a
  2877. 2:19:12look
  2878. 2:19:13uh view post is used somewhere
  2879. 2:19:17get pages
  2880. 2:19:19okay
  2881. 2:19:20now click on this it opens edit which is
  2882. 2:19:23exactly what I want so now let's assign
  2883. 2:19:26PHP for example save that it is not
  2884. 2:19:30active pay attention and if I go and
  2885. 2:19:34just reload the page
  2886. 2:19:37the count does not increase
  2887. 2:19:40uh-huh
  2888. 2:19:42but it should be increased
  2889. 2:19:44why
  2890. 2:19:49for JavaScript it is actually increased
  2891. 2:19:52but not for PHP okay what other
  2892. 2:19:57are there any other posts
  2893. 2:19:59that has a PHP there
  2894. 2:20:02I think there are no posts
  2895. 2:20:05that has PHP there so let's try to
  2896. 2:20:10get the one another one
  2897. 2:20:13so I need to PHP category reload the
  2898. 2:20:15page now there are two
  2899. 2:20:17uh two items and pay attention that this
  2900. 2:20:20is not active so it should not be two it
  2901. 2:20:22should be one
  2902. 2:20:25so let me show you remove this PHP
  2903. 2:20:26because I
  2904. 2:20:28it seemed to me like there were no posts
  2905. 2:20:32in the PHP category but it still was
  2906. 2:20:36showing one
  2907. 2:20:38exactly so this still is showing one
  2908. 2:20:42however
  2909. 2:20:48this obviously shows one because
  2910. 2:20:52it it should show one that's actually
  2911. 2:20:55correct
  2912. 2:20:57if we go in the sidebar we select total
  2913. 2:21:02count of total everything and that
  2914. 2:21:05everything includes the category itself
  2915. 2:21:08okay so this is something which is kind
  2916. 2:21:11of buggy and we should probably adjust
  2917. 2:21:15okay I'm going to get back to this
  2918. 2:21:17um it is this is not accurate hundred
  2919. 2:21:19percent but as I mentioned
  2920. 2:21:22um I'm going to get back to this okay
  2921. 2:21:24so for now let's
  2922. 2:21:27let's actually implement
  2923. 2:21:30when we click on the category it should
  2924. 2:21:32open the post by category so if I go in
  2925. 2:21:35the sidebar and change these and specify
  2926. 2:21:38Road
  2927. 2:21:39to be by category and we have to specify
  2928. 2:21:43category right here
  2929. 2:21:45below the page and I click on JavaScript
  2930. 2:21:49and let's see what happened
  2931. 2:21:53okay we see an empty page
  2932. 2:21:56we go in the
  2933. 2:21:58post controller
  2934. 2:22:00we don't return anything
  2935. 2:22:02so we are going to return
  2936. 2:22:05View
  2937. 2:22:07what will you should we return should we
  2938. 2:22:10return the same view like home and maybe
  2939. 2:22:13provide
  2940. 2:22:15posts like this
  2941. 2:22:21okay so we only see one two three
  2942. 2:22:24one two three we only see three items
  2943. 2:22:28and again count is not 100 accurate
  2944. 2:22:31we're gonna fix that but I think
  2945. 2:22:33filtering by category successfully works
  2946. 2:22:36so if I click on PHP we have to link
  2947. 2:22:38this in the header if I click on PHP
  2948. 2:22:41there are no posts or click on laravel
  2949. 2:22:44there's actually one post
  2950. 2:22:47uh that's that's good
  2951. 2:22:51that's good however I don't want posts
  2952. 2:22:55to be displayed in header if there are
  2953. 2:22:57no items there so if I go in the app
  2954. 2:23:02layout
  2955. 2:23:04change this left join into just join
  2956. 2:23:09PHP should disappear
  2957. 2:23:16I select category join on category post
  2958. 2:23:20there should not be any record right
  2959. 2:23:23there it's range
  2960. 2:23:27well I will try now to print an actual
  2961. 2:23:30query because I have a feeling something
  2962. 2:23:33is not exactly as I want so here we have
  2963. 2:23:37the query
  2964. 2:23:40and let's dump and die
  2965. 2:23:44Yuri
  2966. 2:23:47uh well I need query uh 2sql
  2967. 2:23:52here we go
  2968. 2:23:54select from categories
  2969. 2:24:02uh okay let me carry everything
  2970. 2:24:11I'm going to open now PHP storms
  2971. 2:24:15console
  2972. 2:24:17paste that
  2973. 2:24:20limit five
  2974. 2:24:22so we select from categories and we join
  2975. 2:24:25onto category post
  2976. 2:24:29finally we have group buy and order by
  2977. 2:24:31so if I execute that
  2978. 2:24:34we see PHP okay what is the ID
  2979. 2:24:38or PHP so I need to query categories ID
  2980. 2:24:42as well
  2981. 2:24:44that is five now let's open category
  2982. 2:24:47post and see if there are any posts for
  2983. 2:24:51category five actually there is post
  2984. 2:24:54four
  2985. 2:24:55four category five which is actually
  2986. 2:24:57correct so it looks like the count works
  2987. 2:25:02fine
  2988. 2:25:04if I edit there's laravel if I edit
  2989. 2:25:06there's JavaScript
  2990. 2:25:08and it looks like here it is so we have
  2991. 2:25:12PHP if I remove that and Save
  2992. 2:25:16and now let's open code
  2993. 2:25:22layout
  2994. 2:25:24remove the stamp and die
  2995. 2:25:27and now now what happens
  2996. 2:25:32I removed PHP
  2997. 2:25:35was it actually removed
  2998. 2:25:38maybe even
  2999. 2:25:39no maybe not
  3000. 2:25:42think it is not deleted that's the main
  3001. 2:25:45problem
  3002. 2:25:47stays there
  3003. 2:25:49again if I reload the page PHP is there
  3004. 2:25:52I'm going to remove that
  3005. 2:25:54and save changes
  3006. 2:26:00huh this is required and that's why I
  3007. 2:26:04thought the changes were saved but it
  3008. 2:26:05wasn't saved I'm going to assign it into
  3009. 2:26:08JavaScript
  3010. 2:26:11and save that was now saved reload the
  3011. 2:26:15page
  3012. 2:26:16let's actually
  3013. 2:26:20remove this reload and now PHP
  3014. 2:26:23disappeared from here
  3015. 2:26:25however it is still available right here
  3016. 2:26:28which is something we have to fix
  3017. 2:26:33we have to fix maybe we even completely
  3018. 2:26:36remove the categories if there are no
  3019. 2:26:41articles right there it doesn't make any
  3020. 2:26:42sense to have categories if there are no
  3021. 2:26:44articles right there so I'm gonna go in
  3022. 2:26:46the sidebar and change this into join as
  3023. 2:26:51well we display all categories but if
  3024. 2:26:53there are no posts in the category we
  3025. 2:26:55don't display it perfect I liked it now
  3026. 2:26:59let's go in the app layout
  3027. 2:27:05and let's adjust the categories
  3028. 2:27:10right here so that should be wrote
  3029. 2:27:16by Dash category
  3030. 2:27:20specify category like this
  3031. 2:27:24Okay click on these Works click on this
  3032. 2:27:26works
  3033. 2:27:27so far so good let's Implement
  3034. 2:27:30activating the
  3035. 2:27:32page which is clicked at the moment the
  3036. 2:27:34category on the sidebar which on which
  3037. 2:27:36you have clicked so if we go in the
  3038. 2:27:39sidebar
  3039. 2:27:41here we go so let's move this class down
  3040. 2:27:45and I'm going to get call now request
  3041. 2:27:50and I'm going to get the category and if
  3042. 2:27:53the category slog
  3043. 2:27:57equals that request category will be an
  3044. 2:27:59instance of the category model so if
  3045. 2:28:02that's log equals is the same as
  3046. 2:28:05category slag
  3047. 2:28:07then we're going to mark this item is
  3048. 2:28:11like highlighted so let's give it BG
  3049. 2:28:14blue uh 600 and text White
  3050. 2:28:22otherwise let's give it an empty class
  3051. 2:28:26let's move this down
  3052. 2:28:28like this reload the page and now
  3053. 2:28:30laravel is active I click on the second
  3054. 2:28:32one and JavaScript is active
  3055. 2:28:35okay
  3056. 2:28:36perfect so we made that active and in
  3057. 2:28:39the same way we can also activate the
  3058. 2:28:43home in JavaScript about us I will leave
  3059. 2:28:46this challenge to you now let's
  3060. 2:28:48Implement a botas page I'm going to open
  3061. 2:28:51web.php
  3062. 2:28:53and create a new road that should be
  3063. 2:28:56above this post slide because that's a
  3064. 2:28:59very generic route and that will handle
  3065. 2:29:02everything if there are no more specific
  3066. 2:29:05roads above that so that should be about
  3067. 2:29:08Dash as page let's remove it it's going
  3068. 2:29:12to be pretty straightforward
  3069. 2:29:14well we can use the same post controller
  3070. 2:29:17or create new controller I don't know
  3071. 2:29:19which one will be better maybe creating
  3072. 2:29:22a new controller PHP artisan make
  3073. 2:29:26controller site controller
  3074. 2:29:30enter I'm going to use right here side
  3075. 2:29:33controller
  3076. 2:29:36like this and then we're going to have
  3077. 2:29:38about
  3078. 2:29:40and the name will be about about Dash us
  3079. 2:29:44probably
  3080. 2:29:46so open site controller
  3081. 2:29:48create that function about
  3082. 2:29:51and we're going to create text widget to
  3083. 2:29:54Output the whole content for about that
  3084. 2:29:55so if I go in the text we just click
  3085. 2:29:59now let's give it key about page
  3086. 2:30:02and let's upload also an image some some
  3087. 2:30:05type of image about us title about us
  3088. 2:30:10and there's going to be some
  3089. 2:30:12lorem ipsum long text okay let me make
  3090. 2:30:16sure they copy anything
  3091. 2:30:20there's a large text
  3092. 2:30:28here we go so it also has this code
  3093. 2:30:31formatting thing
  3094. 2:30:33so I'm going to make this active and I'm
  3095. 2:30:36gonna just click create that was created
  3096. 2:30:39about page and I'm going to go in the
  3097. 2:30:41about action and we're gonna select the
  3098. 2:30:45widget so widget equals text
  3099. 2:30:49text widget
  3100. 2:30:51Yuri
  3101. 2:30:52where
  3102. 2:30:54active
  3103. 2:30:56equals
  3104. 2:30:58true
  3105. 2:31:00and we're going to query first
  3106. 2:31:03okay if the widget doesn't exist
  3107. 2:31:08if no widget then there are two options
  3108. 2:31:10either we can throw not found or we can
  3109. 2:31:13just assume that everything is empty but
  3110. 2:31:16I think not found will be more logical
  3111. 2:31:20in this case
  3112. 2:31:21Pro new not found HTTP exception
  3113. 2:31:27otherwise we're going to return View
  3114. 2:31:31about
  3115. 2:31:33and provide
  3116. 2:31:35widget
  3117. 2:31:39let's actually specify the return type
  3118. 2:31:41to review illuminate View
  3119. 2:31:44and let's go under resources and we can
  3120. 2:31:47create
  3121. 2:31:49new tweak file about blade.php
  3122. 2:31:54okay we need X
  3123. 2:31:56up layout
  3124. 2:32:00and inside there let's just
  3125. 2:32:04um let's just use this same type of
  3126. 2:32:07format we have for the Post page so
  3127. 2:32:10let's get this section
  3128. 2:32:13paste it right here
  3129. 2:32:16then for the image we're gonna use
  3130. 2:32:19widget
  3131. 2:32:22widget image and use slash storage slash
  3132. 2:32:27widget image
  3133. 2:32:29we don't need the categories section I'm
  3134. 2:32:31going to remove that we can use widget
  3135. 2:32:34title
  3136. 2:32:36we don't need that section
  3137. 2:32:38or the
  3138. 2:32:40um
  3139. 2:32:41get formatted date
  3140. 2:32:43and we need
  3141. 2:32:45widget
  3142. 2:32:48content
  3143. 2:32:52like this and we don't need this
  3144. 2:32:54previews and next buttons as well
  3145. 2:32:58so I save
  3146. 2:33:00and reload the page
  3147. 2:33:02let's actually let's open
  3148. 2:33:06about Dash us
  3149. 2:33:09here we go
  3150. 2:33:14um
  3151. 2:33:15let's remove this width
  3152. 2:33:21okay it is under container in normal
  3153. 2:33:23width and the image is broken
  3154. 2:33:28Y is the image broken
  3155. 2:33:36because there are no widget image
  3156. 2:33:40why
  3157. 2:33:42because
  3158. 2:33:45I don't have any idea let's check the
  3159. 2:33:50let's check the
  3160. 2:33:52text widgets
  3161. 2:33:54and image
  3162. 2:33:57we have that image for about page
  3163. 2:34:07okay then white is not visible
  3164. 2:34:14okay let's print
  3165. 2:34:17the whole widget
  3166. 2:34:25this is widget and it has attributes
  3167. 2:34:28and it has image to be null because that
  3168. 2:34:33is about us sidebar
  3169. 2:34:36because we don't specify key that's the
  3170. 2:34:38most important thing we just query the
  3171. 2:34:41first active one but we want to specify
  3172. 2:34:46key because that is that is essential
  3173. 2:34:50here the column key
  3174. 2:34:53equals
  3175. 2:34:55page
  3176. 2:34:58save and reload let's go under about and
  3177. 2:35:01remove this
  3178. 2:35:04and this is it the image is huge so we
  3179. 2:35:09have to probably specify
  3180. 2:35:12Max W full something like this
  3181. 2:35:19or maybe just W full
  3182. 2:35:25what is that
  3183. 2:35:30well it's it shows on a very large width
  3184. 2:35:34and white does this happen if we quickly
  3185. 2:35:38inspect that
  3186. 2:35:41we'll have this section which has
  3187. 2:35:44correct width and then the article so
  3188. 2:35:48that article probably needs to have W
  3189. 2:35:51full
  3190. 2:35:57that's fine
  3191. 2:36:00okay if I zoom out
  3192. 2:36:03this is
  3193. 2:36:05how it looks like so this is
  3194. 2:36:08this is a code
  3195. 2:36:10now let's fix this small bug when we
  3196. 2:36:13open home page right here we get request
  3197. 2:36:16category but that request category does
  3198. 2:36:18not exist and we try to get slack from
  3199. 2:36:21there that's why we have this error
  3200. 2:36:23let's go in the sidebar
  3201. 2:36:26sidebar blade and find this place
  3202. 2:36:29request category eliminated question
  3203. 2:36:31mark right here okay so this basically
  3204. 2:36:34is a relatively new feature it's going
  3205. 2:36:36to check if the request category exists
  3206. 2:36:38it's going to take then slack from there
  3207. 2:36:40if it doesn't exist then it will assume
  3208. 2:36:43that it is now so if I save that and
  3209. 2:36:45reload the page the error basically
  3210. 2:36:47disappears but none of the categories
  3211. 2:36:49are selected as soon as I click on
  3212. 2:36:51JavaScript then the JavaScript is
  3213. 2:36:53selected I click on laravel and laravel
  3214. 2:36:55is selected it's as easy as that
  3215. 2:36:58now let's start working on the SEO side
  3216. 2:37:01search engine optimization is very very
  3217. 2:37:04important thing for any website
  3218. 2:37:06especially blog you want your articles
  3219. 2:37:08to be discovered by Google that's why
  3220. 2:37:10it's good practice to Define your tags
  3221. 2:37:14H1 tag meta tags properly and we'll
  3222. 2:37:17we'll try right now to do this properly
  3223. 2:37:20every Post in from our admin panel needs
  3224. 2:37:23to have some type of meta title in meta
  3225. 2:37:27description fields and this is exactly
  3226. 2:37:29what we're going to do right now
  3227. 2:37:31now let's open page perform and terminal
  3228. 2:37:33and let's go inside the container vendor
  3229. 2:37:37being
  3230. 2:37:38sale bash and I'm going to define a new
  3231. 2:37:43migration file and 82 Fields meet a
  3232. 2:37:46title and meter description PHP artisan
  3233. 2:37:50make migration
  3234. 2:37:56fields to posts
  3235. 2:38:00table I made few typos
  3236. 2:38:04two posts table and hit the enter okay
  3237. 2:38:07let's open now add Nita fields to post
  3238. 2:38:11table and right here
  3239. 2:38:14table string
  3240. 2:38:16let's call this meter
  3241. 2:38:18title and the length of the field should
  3242. 2:38:21be like the recommended size for meter
  3243. 2:38:24title is about 60 characters
  3244. 2:38:26let's just Define into 155 because this
  3245. 2:38:29is bar chart and it doesn't hurt
  3246. 2:38:32so and these must be nullable because if
  3247. 2:38:34user doesn't want to Define meta title
  3248. 2:38:37right there we shouldn't force it let's
  3249. 2:38:39duplicate these and I'm going to Define
  3250. 2:38:41now meta description
  3251. 2:38:44okay so we have those two Fields those
  3252. 2:38:46are two the most important Fields like
  3253. 2:38:49previously meta keywords were also
  3254. 2:38:52important but recently uh basically
  3255. 2:38:55search engines uh updated their strategy
  3256. 2:38:58how they are searching and meta tiles
  3257. 2:39:00meta keywords are not that important so
  3258. 2:39:04we can just get that and I'm going to
  3259. 2:39:06paste in the down and just change the
  3260. 2:39:09string into drop column and let's just
  3261. 2:39:12remove this nullable from there as well
  3262. 2:39:14and I think this length is not necessary
  3263. 2:39:16so we have those two columns now let's
  3264. 2:39:19open Terminal and execute PHP art design
  3265. 2:39:21migrate hit the enter okay that feels
  3266. 2:39:24weird edit now let's open
  3267. 2:39:29post.php model let's scroll up find the
  3268. 2:39:32fillable and let's say it right here
  3269. 2:39:34meta title
  3270. 2:39:36and meta
  3271. 2:39:38description
  3272. 2:39:40perfect so we have model ready now let's
  3273. 2:39:42open post resource
  3274. 2:39:46scroll up in the form section so here is
  3275. 2:39:50our form we have title in Slug yes title
  3276. 2:39:54and slogan body and active well before
  3277. 2:39:58active I'm going to duplicate this body
  3278. 2:40:00and this should be text input
  3279. 2:40:03oops
  3280. 2:40:05text input from filament components like
  3281. 2:40:09this and that should be meta title and
  3282. 2:40:13let's remove required from here and
  3283. 2:40:16let's duplicate this and this should be
  3284. 2:40:18meta description
  3285. 2:40:20so and let's make these text well it
  3286. 2:40:24should be text input as well not text
  3287. 2:40:26area so I'm going to save this and
  3288. 2:40:28reload scroll down below we have meter
  3289. 2:40:30type okay let's type right there my meta
  3290. 2:40:33title in my meter in the description
  3291. 2:40:36because we're going to just test the
  3292. 2:40:38functionality it's it should not be like
  3293. 2:40:40it cannot be actual data so
  3294. 2:40:44um let's save these
  3295. 2:40:46like the proper wording would be it
  3296. 2:40:49might not be it is not mandatory to the
  3297. 2:40:51proper data so just diameter will work
  3298. 2:40:53okay I'm going to reload the page and
  3299. 2:40:56actually we should go to that specific
  3300. 2:40:58post let's copy slag and in the URL
  3301. 2:41:02let's just paste this hit the enter so
  3302. 2:41:04this is the post okay
  3303. 2:41:06but we actually have not implemented
  3304. 2:41:08anything we don't output these Meta Meta
  3305. 2:41:12titles right here so we should do that
  3306. 2:41:14but we also want me to titles to be
  3307. 2:41:17outputted on the home page for example
  3308. 2:41:19and on the about us page which are not
  3309. 2:41:22at the moment
  3310. 2:41:24um
  3311. 2:41:25are not posts and they are not even
  3312. 2:41:27pages and by the way these about us page
  3313. 2:41:29is not linked properly so let's just
  3314. 2:41:31quickly open app dot blade and find this
  3315. 2:41:35about us
  3316. 2:41:37here we go and let's change this into
  3317. 2:41:40root
  3318. 2:41:42about
  3319. 2:41:44uh no it's
  3320. 2:41:46it's probably about us
  3321. 2:41:48here we go I click this and it goes
  3322. 2:41:50right there so we need meta title
  3323. 2:41:52limited description right here as well
  3324. 2:41:53and then home and basically on
  3325. 2:41:56categories page as well so we need this
  3326. 2:41:58everywhere so I'm going to do in the
  3327. 2:42:01following way
  3328. 2:42:02in the app blade I will assume that this
  3329. 2:42:05component will always receive meta title
  3330. 2:42:07and meta description so instead of hard
  3331. 2:42:10coding having a hard-coded text right
  3332. 2:42:13here I'm going to change these in I'm
  3333. 2:42:15going to try to Output meta title right
  3334. 2:42:18there okay and if that does not exist
  3335. 2:42:22or if this is empty let's assume that we
  3336. 2:42:25will always pass that meta title okay
  3337. 2:42:27and if this is empty then we can just
  3338. 2:42:30output the code holic block or you can
  3339. 2:42:34type your own blog name so let's just
  3340. 2:42:36Define the author as well the code holic
  3341. 2:42:39animated description we're going to
  3342. 2:42:41Output right here in the same way meta
  3343. 2:42:44and description and if that doesn't
  3344. 2:42:46exist we can just leave this empty okay
  3345. 2:42:50so now we are using always meet a title
  3346. 2:42:53in meta description in the layout but we
  3347. 2:42:57need to pass those variables to the
  3348. 2:42:59layout right so let's open up layout
  3349. 2:43:03component and in the Constructor let's
  3350. 2:43:06take those two variables public string
  3351. 2:43:10meta title is an empty string or null
  3352. 2:43:14and public string and let's put a
  3353. 2:43:19question mark right here
  3354. 2:43:21in public string
  3355. 2:43:24meta oops Meetup and description is also
  3356. 2:43:30now
  3357. 2:43:31okay so here we have two variables why
  3358. 2:43:35is this all individual value
  3359. 2:43:38question mark question mark is necessary
  3360. 2:43:41right here okay so we have those two
  3361. 2:43:43variables meta title in meta description
  3362. 2:43:45and because we defined them with a
  3363. 2:43:47public key those are class properties
  3364. 2:43:50and they are available in the layout so
  3365. 2:43:53if I just save this and reload the page
  3366. 2:43:55we don't see anything nothing is passed
  3367. 2:43:57right there but if I accept right here
  3368. 2:43:59for example test save and reload and now
  3369. 2:44:02look at this by the way so title is
  3370. 2:44:06outputted right here okay and if we
  3371. 2:44:08click view page Source we see title
  3372. 2:44:10right here and by the way there also
  3373. 2:44:13exists meta title
  3374. 2:44:16but again uh and we can type like meta
  3375. 2:44:19title right here but the latest version
  3376. 2:44:21of search engines I'll look for the
  3377. 2:44:24title text So Meta title is less
  3378. 2:44:25important title is the is key so that's
  3379. 2:44:28the most important thing so we're gonna
  3380. 2:44:30just put the meter title right here okay
  3381. 2:44:33perfect so we have implemented passing
  3382. 2:44:35the data now how we're going to actually
  3383. 2:44:37pass the correct data to the app layout
  3384. 2:44:40let's start from the home I'm going to
  3385. 2:44:42open homeblade PHP and we are using this
  3386. 2:44:45app layout right here so now this layout
  3387. 2:44:48which is a component yeah it accepts
  3388. 2:44:50meta title and meta description so I'm
  3389. 2:44:54going to pass
  3390. 2:44:55Nita dish title to be something like the
  3391. 2:44:59code holy blog or we can just leave this
  3392. 2:45:02empty and because in the upper blade we
  3393. 2:45:04are taking the code holic blog we can
  3394. 2:45:06just leave this empty okay I'm not going
  3395. 2:45:08to pass this meta tape title but instead
  3396. 2:45:11I'm going to pass meta and description
  3397. 2:45:14description and that should probably be
  3398. 2:45:17the code holique
  3399. 2:45:20code holix
  3400. 2:45:22personal blog
  3401. 2:45:25about
  3402. 2:45:27coding tutorials okay
  3403. 2:45:31so I save this reload the page and look
  3404. 2:45:33at this the code holix personal blog
  3405. 2:45:35about coding tutorials and right here we
  3406. 2:45:38see the code call it block and that is
  3407. 2:45:40passed by the way
  3408. 2:45:43are everywhere okay we're right now on
  3409. 2:45:45the category page which should not be
  3410. 2:45:47passed but it is still past we're going
  3411. 2:45:48to fix that but the main thing is that
  3412. 2:45:50if we go on the home page we see that
  3413. 2:45:52the code holix Personnel blog about
  3414. 2:45:53coding and this is the title okay so far
  3415. 2:45:56so good now
  3416. 2:45:58we have implemented the home page now
  3417. 2:46:00let's go on the post page
  3418. 2:46:04post Dot View so in the post view we
  3419. 2:46:08accept post so we can take post meta
  3420. 2:46:11title and post meter description and
  3421. 2:46:14pass them meta title corresponds to
  3422. 2:46:18post
  3423. 2:46:21um title but if post meta title does not
  3424. 2:46:25exist
  3425. 2:46:26then let's take host title okay save
  3426. 2:46:31click on this now click view page source
  3427. 2:46:34and this is the title why JavaScript is
  3428. 2:46:37weird Okay so this is our title we can
  3429. 2:46:41also like prefix or suffix the blog the
  3430. 2:46:45actual application name like the code
  3431. 2:46:47holique blog we can prefix that or
  3432. 2:46:50suffix that you can do this as you want
  3433. 2:46:52like I'm going to leave this right now
  3434. 2:46:54as it is why JavaScript is weird and we
  3435. 2:46:57can also specify meta
  3436. 2:47:00Dash description is
  3437. 2:47:04post meter description
  3438. 2:47:08so I saved it I reload nothing's
  3439. 2:47:11password right here in y let's check
  3440. 2:47:14this
  3441. 2:47:15meter and description I think I have
  3442. 2:47:17passed everything correctly
  3443. 2:47:20if I go in the admin panel
  3444. 2:47:22reload
  3445. 2:47:24okay it was not saved
  3446. 2:47:27yeah that was not saved like my meter
  3447. 2:47:30title in my meta description save
  3448. 2:47:33changes that will save reload the page
  3449. 2:47:35that was lost
  3450. 2:47:37why was that lost let's check
  3451. 2:47:41post
  3452. 2:47:42PHP
  3453. 2:47:44this is why it was lost because I have
  3454. 2:47:47two t right here save that
  3455. 2:47:50okay perfect I reload the page my meta
  3456. 2:47:54title and my description I'm going to
  3457. 2:47:56click save
  3458. 2:47:58reload the page that was actually saved
  3459. 2:48:00and now if I reload the why JavaScript
  3460. 2:48:03is weird and remove the page we see my
  3461. 2:48:05meta title in my description which come
  3462. 2:48:08from here okay so if I just delete my
  3463. 2:48:11meter title and hit the enter that was
  3464. 2:48:13saved reload the page now it's going to
  3465. 2:48:15take the title actual post title from
  3466. 2:48:19here okay it's a fallback and it's good
  3467. 2:48:21good logic in my opinion so now we have
  3468. 2:48:24implemented a passing meta titles and
  3469. 2:48:27with the descriptions for the home page
  3470. 2:48:30as well as for the Post view page okay
  3471. 2:48:34what other rules do we have let's open
  3472. 2:48:37web.php and have a look so we have about
  3473. 2:48:40us page and we have Pi category page
  3474. 2:48:43let's go on the about page right here
  3475. 2:48:47which renders about that blade so let's
  3476. 2:48:49open about blade PHP and in the same way
  3477. 2:48:53we're going to pass like meta title
  3478. 2:48:58and let's just type the code holique
  3479. 2:49:02blog or maybe about the code holic
  3480. 2:49:09or something like this like the code
  3481. 2:49:10holix blog or something like this okay
  3482. 2:49:12now there's about ask page that should
  3483. 2:49:15be probably and of course we can specify
  3484. 2:49:18meta and description you get the idea
  3485. 2:49:20I'm just going to type lorem ipsum
  3486. 2:49:24okay I saved it by the way if you pass
  3487. 2:49:26this with a column uh you need to put
  3488. 2:49:29this inside quotations okay because we
  3489. 2:49:32need it expects like a variable at this
  3490. 2:49:35moment but if you remove this column we
  3491. 2:49:37can just remove this uh
  3492. 2:49:40quotations as well save that and let's
  3493. 2:49:44go on about Dash as page and here we see
  3494. 2:49:47the code holdx plug and lorem ipsum
  3495. 2:49:50perfect so we have implemented about us
  3496. 2:49:52as well and the last thing is to
  3497. 2:49:54implement the Page by category let's go
  3498. 2:49:57in the post controller by category and
  3499. 2:50:01that renders a whole
  3500. 2:50:04but you know what rendering the same
  3501. 2:50:07view for by category as we have rendered
  3502. 2:50:11for
  3503. 2:50:14for the home is not actually a good idea
  3504. 2:50:17so maybe we need to go in the home and
  3505. 2:50:21I'm going to copy this home and paste
  3506. 2:50:23inside the post folder and I'm going to
  3507. 2:50:25call this index maybe okay and in the
  3508. 2:50:29index
  3509. 2:50:30we know that
  3510. 2:50:32um
  3511. 2:50:34we let's go in the post by category and
  3512. 2:50:37let's pass the category okay from here
  3513. 2:50:39so we pass the category uh we render
  3514. 2:50:42post.index right here and now if we open
  3515. 2:50:45that index we know that we have right
  3516. 2:50:48here category so maybe we can specify
  3517. 2:50:51inside meta title to be like category
  3518. 2:50:57title Maybe
  3519. 2:50:59and meta description can be whatever
  3520. 2:51:01whatever you want like
  3521. 2:51:04um by category description or something
  3522. 2:51:07like this so I save this now and click
  3523. 2:51:10on the JavaScript which renders pull
  3524. 2:51:12Spike diggery view page source and we
  3525. 2:51:15see JavaScript which is actually the
  3526. 2:51:17title now for the category right so the
  3527. 2:51:20ideal title probably will be
  3528. 2:51:24the code holique blog dish
  3529. 2:51:29or maybe not Dash let's leave a dash
  3530. 2:51:32posts
  3531. 2:51:34by category
  3532. 2:51:37in the actual category so I save and
  3533. 2:51:39reload the code public blog post by
  3534. 2:51:41category JavaScript okay that's very
  3535. 2:51:43very logical title for that page
  3536. 2:51:47and I guess it's not more than six
  3537. 2:51:49characters as well so in the description
  3538. 2:51:51you can type something like this as well
  3539. 2:51:53and I think we are good so now we have
  3540. 2:51:56titles for every page like on the home
  3541. 2:51:59page
  3542. 2:52:00view page Source we have implemented
  3543. 2:52:03those
  3544. 2:52:04uh we have implemented uh meta titles
  3545. 2:52:07for the by category page about us page
  3546. 2:52:10let's check this once again and I think
  3547. 2:52:12that's perfect and whenever you create
  3548. 2:52:15new post from the admin panel if you
  3549. 2:52:18Define meta title and meet a description
  3550. 2:52:20uh then you basically tell search engine
  3551. 2:52:24that hey this this is the overall
  3552. 2:52:26information about my post and then it
  3553. 2:52:29helps basically search engine of course
  3554. 2:52:31only meta title and meter description
  3555. 2:52:33are not 100 enough to optimize your blog
  3556. 2:52:37post or Otero websites or any Pages you
  3557. 2:52:40can optionally add other titles like OG
  3558. 2:52:43uh open graph titles for sharing your
  3559. 2:52:47posts on Facebook or on social media and
  3560. 2:52:51I really really recommend to do that and
  3561. 2:52:54Implement those fields as well now let's
  3562. 2:52:57do some final touches on a website let
  3563. 2:53:01me first change the background color of
  3564. 2:53:03the body
  3565. 2:53:04at the moment it is white and we also
  3566. 2:53:06have white cards on that so I'm going to
  3567. 2:53:09change this into gray Dash 15 and let's
  3568. 2:53:12remove this white I'm going to save and
  3569. 2:53:14reload and now that's much better
  3570. 2:53:18now if I scroll down below and zoom out
  3571. 2:53:21slightly we see that the cards have
  3572. 2:53:23actually background transparent so let's
  3573. 2:53:26go in the post item
  3574. 2:53:29find that article and give it class PG
  3575. 2:53:33white save that
  3576. 2:53:37and reload and now this one has a white
  3577. 2:53:39background
  3578. 2:53:41if we scroll at the very top and click
  3579. 2:53:43this logo it doesn't do anything so I'm
  3580. 2:53:46going to go in the categories section
  3581. 2:53:48click right here it doesn't do anything
  3582. 2:53:50so this should go to the home page so
  3583. 2:53:53let's go in the up blade and find this
  3584. 2:53:56the code holy blog and let's change this
  3585. 2:53:59href into root home
  3586. 2:54:03save refresh the page and click right
  3587. 2:54:06here it goes to the home
  3588. 2:54:07on the right side we have this about our
  3589. 2:54:10section but whenever I click on this
  3590. 2:54:12button it doesn't do anything we need to
  3591. 2:54:14link this to the about us page so let's
  3592. 2:54:17go in the sidebar find this button and
  3593. 2:54:21we're going to change this into roads
  3594. 2:54:24about Dash us save reload the page and
  3595. 2:54:28click on this and we are on about us
  3596. 2:54:30page
  3597. 2:54:31okay let's scroll down below let's go in
  3598. 2:54:34the JavaScript section when there are
  3599. 2:54:36multiple categories on the post they are
  3600. 2:54:38not on a single line they are each on
  3601. 2:54:41its own line and we're going to change
  3602. 2:54:43that I don't like this so let's go in
  3603. 2:54:46the post item and right here we iterate
  3604. 2:54:49over our categories so I'm going to
  3605. 2:54:51create new div give it
  3606. 2:54:54it should be div
  3607. 2:54:56give it a class of flex and let's give
  3608. 2:55:00it also gap of three for example or
  3609. 2:55:03maybe even four and the closing tag goes
  3610. 2:55:06right here we save the code and now
  3611. 2:55:09let's reload the page
  3612. 2:55:14and here we see now they are all
  3613. 2:55:17categories on its own line and on a on
  3614. 2:55:20the same line and if I click on this
  3615. 2:55:21article right here we have the same
  3616. 2:55:24thing and now if I click on this article
  3617. 2:55:26and go inside uh right here there's the
  3618. 2:55:29same problem so we're going to open a
  3619. 2:55:33view.play.php find that category is
  3620. 2:55:35rendering and basically I'm going to use
  3621. 2:55:38the same class same div as a wrapper of
  3622. 2:55:42this for each
  3623. 2:55:44right here
  3624. 2:55:46format the code and reload the page and
  3625. 2:55:49voila on this article I added a code
  3626. 2:55:52which are under pre-tax but they don't
  3627. 2:55:56look like a code actually so let's add
  3628. 2:55:59small CSS to identify that this is a
  3629. 2:56:02code uh block of code so in the app play
  3630. 2:56:06in the layout just like we have the fun
  3631. 2:56:08family Carla I'm going to create a small
  3632. 2:56:10CSS I'm not doing this in a separate CSS
  3633. 2:56:14file because it's very small and very
  3634. 2:56:15minimalistic like on pre we're going to
  3635. 2:56:18have padding to be one ram let's give it
  3636. 2:56:22a background color to be
  3637. 2:56:24like a gray or black let's give it color
  3638. 2:56:28to be white and let's give it border
  3639. 2:56:31radius to be 0.5 Ram
  3640. 2:56:34and let's save this and have a look
  3641. 2:56:36reload the page and this is it I think
  3642. 2:56:39this is exactly what I wanted so and
  3643. 2:56:41let's give this also margin bottom like
  3644. 2:56:44one ram
  3645. 2:56:46like this say reload and this is exactly
  3646. 2:56:49what I wanted
  3647. 2:56:51that's it guys in this video and I hope
  3648. 2:56:54you enjoyed it if you want to see how I
  3649. 2:56:55built a full stack application with the
  3650. 2:56:57react and lateral click right here if
  3651. 2:57:00you prefer view JS you should check the
  3652. 2:57:02following video otherwise I will see you
  3653. 2:57:05in the next time

About this transcript

This page contains the full transcript of Laravel 10 Blog with Filament Admin Panel | Part 1 by The Codeholic, generated from the public captions YouTube serves with the video. The transcript has 22,271 words across 3,653 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.