Laravel 10 Blog with Filament Admin Panel | Part 1 — Transcript
Full transcript
- 0:00I have built fully functional blog with
- 0:02the larval 10 in tolerance CSS the block
- 0:04has admin panel from which you can
- 0:07manage content of your website here's
- 0:09how I did it install and set up Lateral
- 0:11with crl and Docker install filament PHP
- 0:14as an admin template integrate free blog
- 0:17template in lateral query posts and
- 0:19output on the website with pagination
- 0:21create and use text widgets to manage
- 0:23any content on the website add and use
- 0:25meta fields for search engine
- 0:27optimization let's immediately have a
- 0:29look at the demo of the project
- 0:31on the home page we output a latest
- 0:34posts the post has image title
- 0:36description and the text we also have
- 0:39pagination we can go to the next Pages
- 0:41if we want when you open the post in
- 0:43your page you're gonna see the post
- 0:45image categories title and the whole
- 0:48description of the post and right here
- 0:51we also have next and previous patterns
- 0:53and based on that you can navigate
- 0:55between the next or previous posts on
- 0:58the right side we see all categories and
- 1:00also how many posts there are in this
- 1:03specific category in the navigation we
- 1:05have the home page top three categories
- 1:08and about us page if we open URL
- 1:11localhost slash admin and then enter
- 1:13username and password we are in the
- 1:15admin panel right here we can create
- 1:17categories and modify or delete we can
- 1:20also update posts and text wages text
- 1:23widgets are just key value pairs where
- 1:25we can output certain things on the
- 1:27website like for example the header text
- 1:29is output using a text widgets and also
- 1:33this About Us section is outputted using
- 1:35text widgets if we open the post section
- 1:38and click the very first post right here
- 1:40we can change the title and based on the
- 1:42title slag is automatically generated we
- 1:45can change the image assign or remove
- 1:47categories and of course adjust the
- 1:50description of the post and finally we
- 1:52can specify meta title in description
- 1:54mark this post is active or not and
- 1:57specify publish date if the post is not
- 2:00active or published date is not
- 2:02specified or if the published date is in
- 2:04the future the post will not appear on
- 2:07the website I want to give away my
- 2:09laravel e-commerce course there are two
- 2:11things required to participate in this
- 2:13giveaway you must be subscribed to the
- 2:15channel and you must leave a comment
- 2:17down below under this video and use the
- 2:21code holique in your comment I will
- 2:23choose 10 random people as winners and
- 2:26contact them and give my larval
- 2:28e-commerce course for free I'm going to
- 2:29also announce the winners on my Twitter
- 2:31if you want you can follow me on Twitter
- 2:33but it is not actually mandatory all
- 2:36right thank you very much for watching
- 2:37this video so far I really appreciate
- 2:40every single viewer of this video and
- 2:42now let's start building the project now
- 2:45let's start building our project this
- 2:48particular project I'm going to develop
- 2:50fully on Docker if you don't know what
- 2:52is Docker or how to set up it on your
- 2:54operating system first I recommend to
- 2:56check the docker tutorials I will try to
- 2:58use Docker more and more on this channel
- 3:01when building the projects because I
- 3:03think Docker is an essential tool
- 3:06nowadays for every uh every full stake
- 3:09developer or even back-end developer so
- 3:11Docker makes things very very easy and
- 3:15very very safe okay now we're gonna use
- 3:18in this project filament PHP which is a
- 3:21toolkit for laravel Artisans which is
- 3:24tall it's a talent alpine.js laravel and
- 3:27Live Wire that's pretty awesome kit in
- 3:31my opinion right here you can check the
- 3:33admin panel demo as well but we're going
- 3:35to actually install this in our laravel
- 3:3710 project and configure it and create
- 3:40admin panel with this tall kit if you
- 3:43want to see the final version of The
- 3:45Source Code you can check this on my
- 3:47GitHub the code holy slash laravel 10
- 3:50block and finally we're going to use the
- 3:52following template that's a very very
- 3:54minimalistic blog template we're going
- 3:56to have only categories and a listing of
- 3:59the blocks and then in your page of the
- 4:01blog we aren't going to have a
- 4:03Authentication
- 4:05or authorization system users would just
- 4:08be able to browse the blog website and
- 4:11just have a look at the Articles and
- 4:13read or filter by category okay so this
- 4:17is the overview now we can already start
- 4:20building our project I'm going to close
- 4:22uh actually let's leave this because
- 4:23we're going to need this I'm going to
- 4:25close my GitHub and we will need this
- 4:27also because we're gonna check the
- 4:29documentation for the filament PHP from
- 4:32time to time now let's open marvel.com
- 4:35and go to the documentation and we're
- 4:37going to set up the project with the
- 4:39docker as I mentioned so I'm going to
- 4:41click getting started on Windows scroll
- 4:43down below right here we have the
- 4:44following command we need to run this in
- 4:46our Linux terminal okay again if you are
- 4:49Mac OS or Linux user you just need to
- 4:51run this in your terminal probably you
- 4:54will already have crl command available
- 4:56if not then you just need to install crl
- 4:59on Windows when you set up wso2 with the
- 5:02Linux operating system in my tutorial I
- 5:05set up with Ubuntu then you're good to
- 5:07go you will have this URL right there
- 5:09okay now let's open
- 5:12Ubuntu here it is
- 5:15and I'm gonna go inside www folder and
- 5:21I'm going to call
- 5:22um
- 5:23well actually we need to paste this crl
- 5:25comment right here
- 5:29right click and let's give it proper
- 5:32name example app is not the proper name
- 5:34we're going to call this laravel
- 5:3710 new
- 5:39uh well larval 10 blog Dash new okay
- 5:43because I already have a lot of 10 blog
- 5:45so I'm going to call this laravel 10
- 5:46block new let's hit the enter this will
- 5:49take a lot of time basically if you are
- 5:52running these a very first time on your
- 5:54operating system it will download a lot
- 5:57of things uh it will clone clone the
- 5:59laravel project locally and then it will
- 6:02also download the docker images and set
- 6:05them up and execute them okay so I'm
- 6:07going to pause the recording and get
- 6:09back when this is done it downloaded all
- 6:11the images and at this stage we have to
- 6:13provide our operating system uh root
- 6:16password I'm going to provide my root
- 6:19password for Ubuntu
- 6:22hit the enter and here it is so it
- 6:25successfully installed our project and
- 6:27we need to navigate into the folder and
- 6:30then execute vendor bin sale app
- 6:34okay so let's navigate into laravel
- 6:38obtain blog Dash new and then well
- 6:43actually I can execute this vendor bin
- 6:45sale up from here but first i'm going to
- 6:47open this in my editor or ID I'm going
- 6:50to use phpstorm and basically let's type
- 6:55explorer.xa and Dot so I'm basically
- 6:58trying to open right now the current
- 7:02folder with the Windows Explorer here it
- 7:06was opened on my second screen this is
- 7:09it and I'm going to go inside www here I
- 7:12have all the projects and this is it so
- 7:15level 10 blog new right click on this
- 7:18and open folder is PHP show and approach
- 7:20it
- 7:21okay so it's gonna open in a second
- 7:26if it asks you whether you want to trust
- 7:29that folder and project you just need to
- 7:31click trust it and here it is so the
- 7:34project was opened in from now on I'm
- 7:37not gonna use this Ubuntu terminal
- 7:39instead I'm going to use PHP storms
- 7:42integrated terminal and we have to start
- 7:46the project using sales so now it's
- 7:48indexing it will take a couple of
- 7:49seconds but we can actually already
- 7:51start the project we don't need to wait
- 7:54vendor Bean
- 7:58sale app
- 8:00okay so sales is basically a
- 8:02containerization mechanism built on top
- 8:05of the docker it's a specially created
- 8:08for laravel and it makes a working with
- 8:12Docker very easy okay we just run uh
- 8:15sale app I'm going to open second
- 8:16terminal and now uh we're gonna go
- 8:20inside the container inside the main
- 8:22laravel container and then every Artisan
- 8:27command needs to be run from that
- 8:30container
- 8:31all right so we're going to execute
- 8:33vendor Bean sale Bash
- 8:37and now
- 8:39we are inside that container and now
- 8:42here we have PHP latest version PHP 8.2
- 8:46and we have Artisan command and
- 8:48everything right here so we are in the
- 8:50HTML folder which has all the files of
- 8:53the live okay so this HTML is mapped to
- 8:56the current directory so so far so good
- 9:00and we have this application up and
- 9:02running right here
- 9:04now let's install filament PHP let's go
- 9:07in the filamentphp.com and scroll down
- 9:10below I want to find the documentation
- 9:12page right here we see the instruction
- 9:14how we're going to include that in the
- 9:16admin panel an example how that actually
- 9:18looks like and in my opinion this looks
- 9:21amazing and let's go in the
- 9:23documentation right here so down below
- 9:24you can also find other packages form
- 9:27Builder and table Builder but we're
- 9:29going to also explore them inside the
- 9:31admin panel documentation which actually
- 9:33actually includes other packages as well
- 9:36so here is the documentation
- 9:38and let's click on the installation
- 9:42because the requirements are there we
- 9:44have the latest version of PHP because
- 9:46we are doing this on Docker we have
- 9:48everything ladies like the latest
- 9:50version of laravel PHP and MySQL as well
- 9:54okay uh it's it's amazing I really love
- 9:57working with Docker because you don't
- 9:59really care what version of PHP you have
- 10:02on your operating system when you are
- 10:04developing on Docker you don't even need
- 10:07to have PHP installed locally on your
- 10:09operating system which is in my opinion
- 10:11amazing okay let's open now PHP storm
- 10:14and we're going to run all the commands
- 10:15as I mentioned from here so installation
- 10:17very easy very first step is to require
- 10:20filament PHP so I'm going to copy that
- 10:22and paste right here hit the enter it's
- 10:25gonna install it then we're gonna open
- 10:28composer Json and put this in the post
- 10:31update CMD so I'm just going to copy
- 10:33that
- 10:34and let's open composer Json and let's
- 10:39search for post update CMD by the way
- 10:42the filament PHP was installed I'm going
- 10:44to collapse this terminal and open
- 10:46whenever I need that
- 10:48okay oops we don't need double
- 10:51quotations
- 10:55okay we need it like this okay filament
- 10:58PHP was was uh fully installed
- 11:02let's check the documentation again and
- 11:04we have added this in the post update
- 11:07CMD as well and now we need to create
- 11:10new filament user before we do this if
- 11:13we open now localhost slash admin that's
- 11:17going to open filament PHP login page
- 11:19okay but at the moment we don't have any
- 11:22users so we won't be able to log in
- 11:24Click right here we don't even have the
- 11:26users table that's that's interesting we
- 11:29need to run migrations
- 11:32let's open
- 11:33um again terminal and let's execute PHP
- 11:37Artisan
- 11:38migrate in the enter okay so for so good
- 11:42now let's if we just click right here
- 11:46the user doesn't exist okay now let's
- 11:48execute PHP artisan make
- 11:53filament Dash user hit the enter let's
- 11:57provide the name let's provide
- 12:00email
- 12:03hit the enter okay right here I'm going
- 12:05to type yes but for some reason it shows
- 12:08an error okay so now the user is already
- 12:11created and if I hit sign in with the
- 12:14user and password
- 12:15I'm inside the filament admin panel okay
- 12:19now we can start working and developing
- 12:22from here but first I think we need to
- 12:25generate migrations and models before we
- 12:27generate migrations and models let's
- 12:29create a storage link because we're
- 12:32gonna upload images and we will need
- 12:34storage to be properly linked I'm going
- 12:37to execute PHP Artisan storage column
- 12:41Link in the enter and the link has been
- 12:44created now let's create two main models
- 12:47one will be article so PHP
- 12:51not article but category PHP artisan
- 12:55make model
- 12:58category and I'm going to specify Dash M
- 13:01as well because I will need migration
- 13:02for this as well let's hit the enter it
- 13:05was generated and the second will be
- 13:08host a model with its migration it was
- 13:12generated as well and I will also need
- 13:15category post which will be Junction
- 13:18table between posts and categories
- 13:20because one category will belong to
- 13:24multiple posts and one post might have
- 13:27multiple categories posts and categories
- 13:29will have many to many relationship I'm
- 13:32going to execute PHP artisan make model
- 13:34category
- 13:37category post okay and the immigration
- 13:41was created excuse me migration was
- 13:44created
- 13:45okay and so we have that
- 13:48and now I think we just need to open the
- 13:51migration files and just write them so
- 13:52let's go in the database migrations
- 13:56and create categories table
- 14:00here it is
- 14:02okay so what Fields do we need right
- 14:04here
- 14:05for categories I'm going to make it very
- 14:07simple and I will just add two columns
- 14:09both of them will be string one will be
- 14:12title let's give it large length and the
- 14:15second will be Slack
- 14:18okay as easy as that now let's open
- 14:21second which is host table this is the
- 14:24main table so we will need much more
- 14:26Fields right here let's define
- 14:29table
- 14:31we will need string
- 14:35which will be title with the same length
- 14:39we will need slag
- 14:44we will need thumbnail as well
- 14:48which will be the main image or the post
- 14:50and we can make thumbnail as nullable
- 14:53it's not actually required we will need
- 14:56body
- 14:58which should be long text
- 15:03and body needs to be required so we just
- 15:06remove this nullable we will also need
- 15:09a one Boolean column which should be
- 15:13active
- 15:16and we will need date time column
- 15:21oops date time which should be published
- 15:27it when the article when the post should
- 15:31be published and become available on the
- 15:33website
- 15:34and probably the last one will be the
- 15:37foreign key to the user so that should
- 15:39be foreign ID 4 we have to specify user
- 15:44model right here
- 15:46class and the field name will be
- 15:51user ID
- 15:53later in this course we can also add
- 15:55meta fields for search engine
- 15:56optimization to post table SEO is key
- 15:59for every website you want your website
- 16:01to be discovered by Google especially
- 16:03your blog website you want your posts to
- 16:06be found whenever people search for
- 16:08something that's why you should try to
- 16:10do your best and Implement best SEO on
- 16:12your website speaking about SEO if you
- 16:15want to know how search engines work
- 16:17check introduction to search engines
- 16:19course at brilliant.org who is kindly
- 16:22sponsoring this video brilliant.org is
- 16:24the best way to learn your desired
- 16:26topics interactively the search engines
- 16:28course at brilliant.org will give you an
- 16:31excellent understanding how search
- 16:32engines work how indices are implemented
- 16:35or how to implement your own search they
- 16:37have courses around math computer
- 16:39science algorithm fundamentals data
- 16:42science neural networks and much much
- 16:44more their lessons are super engaging
- 16:46and interactive I love their algorithm
- 16:49fundamentals course that's a great
- 16:51introduction to very popular and useful
- 16:53algorithms such as binary search or
- 16:56sorting of arrays in this course you
- 16:58will also learn what is Big O notation
- 17:00which is to measure the time complexity
- 17:03of your code to try everything
- 17:05brilliant.org offers 30 days free trial
- 17:08visit brilliant.org the code holy or
- 17:11click the link in the video description
- 17:13first 200 users will get 20 off on their
- 17:17annual subscription the price is very
- 17:20affordable so I really recommend to
- 17:22check brilliant.org the code holic and
- 17:25start learning interactively today
- 17:28okay so we have that generated and I
- 17:32think we need to create also a junction
- 17:36table so let's open now create category
- 17:40posts this should be called in a
- 17:43singular form because that is how it is
- 17:47recommended on the level actually now
- 17:49I'm going to open a lot of documentation
- 17:51page because I always say that whenever
- 17:53you create projects you should have the
- 17:55documentation always open next to you
- 17:58and you should always try to stick with
- 18:00the documentation because in this case
- 18:02uh you will constantly checking the
- 18:05documentation learning constantly as
- 18:07well as preserving best practices
- 18:09because in the documentation you will
- 18:11often find highlighted section for some
- 18:13best practices okay now let's search for
- 18:16many too many
- 18:18right here mean to manual
- 18:21relationships here we have that table
- 18:24structure and this is exactly what I was
- 18:27talking about so we have users or roles
- 18:29and role user okay so roll user table is
- 18:33in a singular form
- 18:35okay and then here's also an example of
- 18:38the modal structure and everything so we
- 18:40need to call our
- 18:43table category post and we will need a
- 18:47foreign IDs to categories as well as to
- 18:52posts so table
- 18:54fouring ID
- 18:57that should be
- 18:59category ID
- 19:04references on ID
- 19:08on table categories okay and we have to
- 19:13specify as well on delete to be cast 8.
- 19:17whenever category is deleted I want a
- 19:21category post records to be deleted as
- 19:24well
- 19:25okay and then we will need post ID here
- 19:30that references ID on table posts and on
- 19:34delete we need Cascade as well whenever
- 19:36post is deleted that Junction table
- 19:39records should also be deleted
- 19:42okay so we have migrations migrations
- 19:45ready and now let's execute PHP Artisan
- 19:49migrate
- 19:50hit enter okay we probably have some
- 19:53kind of error
- 19:57published it now okay so first we'll
- 20:00successfully run second was failed let's
- 20:03check one mistake I have
- 20:06date times that should be daytime should
- 20:09not be date times
- 20:11okay let's
- 20:13clear the console and execute
- 20:17and here we go so that was actually
- 20:19successfully migrated now we have tables
- 20:22created and now let's open category
- 20:26category dot PHP so I want to open
- 20:29category model and I'm gonna add right
- 20:32here fillable
- 20:34so we have title and slack and we're
- 20:38gonna add this inside fillable let's
- 20:41copy this and now let's open
- 20:44post.php model
- 20:49paste this right here so we have a title
- 20:52slug we will need thumbnail
- 20:56everything basically every column so I'm
- 20:58going to open a post table and copy
- 21:02those including user ID and
- 21:06maybe I'm going to delete this paste
- 21:09everything create multi-cursor
- 21:12and do like this
- 21:14here we go so inside fillable I have all
- 21:17the post fields
- 21:19okay and I'm going to Define also
- 21:21relations from category to post and vice
- 21:25versa and inside post we also need
- 21:27relation to users so let's create a
- 21:31public function user
- 21:34we are going to return
- 21:37this belongs to user
- 21:43is that app models user
- 21:47yes it is okay so this belongs to user
- 21:50and let's define the return type as well
- 21:53so that is the relations belong to and I
- 21:57generally don't like so long on
- 22:00namespaces inside the return type so I'm
- 22:03going to just move this up so we will
- 22:06have use right here
- 22:07okay and now let's define
- 22:11um let's define categories
- 22:13so post has categories we're going to
- 22:15return these
- 22:18belongs
- 22:20belongs to many
- 22:24and here I'm going to specify category
- 22:27class
- 22:29okay and let's specify return type here
- 22:32as well
- 22:34okay so post belongs to many categories
- 22:39and we need to do this inversed inside
- 22:42category so I'm going to go in the
- 22:44categories so let's create right here
- 22:47post function return this
- 22:52um
- 22:53this belongs to many
- 22:57host
- 22:59like this
- 23:01okay and let's specify
- 23:05return type as well
- 23:07okay so we have our models and
- 23:12migrations I think fully ready okay now
- 23:16let me close everything and I'm going to
- 23:18open our browser
- 23:20open the website let's move this as a
- 23:23very first Tab and we're going to
- 23:24generate crud for categories and for
- 23:28posts and those cards are called
- 23:30resources
- 23:32if we go in the filament PHP scroll down
- 23:34below right here after uh the user
- 23:37generated right here we have the section
- 23:39link to the section building resources
- 23:41or or on the left side we have this
- 23:45resources section and getting started
- 23:47okay so we need to create resource and
- 23:52when we create resource it generates the
- 23:54following files a resource and Pages as
- 23:57well for create edit and list we can
- 24:00also generate a view page for each
- 24:03resource well actually I think best will
- 24:05be if I generate and then explore that
- 24:07so
- 24:09I'm going to execute PHP artisan make
- 24:13filament Dash resource let's specify
- 24:16category but I'm not going to hit enter
- 24:19so if we have a look in the filament
- 24:22documentation
- 24:23we can generate two types of resources
- 24:27one is normal resource and second is
- 24:30simple resource when we generate simple
- 24:32resource it doesn't have dedicated Pages
- 24:35for create and update instead it uses
- 24:38models so categories is more like a
- 24:41simple resource we don't need dedicated
- 24:43Pages for category view or edit it can
- 24:46be just module because we have only one
- 24:48Field title and the slug is
- 24:50automatically generated from the title
- 24:52okay so for categories we need simple
- 24:55four posts we need full version but we
- 24:59if we want to generate forms in the
- 25:02tables as well then we need to install
- 25:04talktrain debug package which will read
- 25:07the schema and based on the schema it
- 25:10will generate those those form fields
- 25:15and tables as well okay that's pretty
- 25:17interesting so let's actually first Inc
- 25:19include Doctrine and debal if that's not
- 25:22included in composer Json and by default
- 25:25I think it's not included so let's just
- 25:27execute composer require Doctrine debel
- 25:31because we just need this for
- 25:33development only we have to specify Dev
- 25:36right here that's an old error don't pay
- 25:40attention to that
- 25:42okay so here it was installed and now
- 25:46let's execute the following command but
- 25:50first four categories
- 25:52I'm going to specify right here
- 25:55category and we're going to specify as
- 25:58well dash dash simple flag and generate
- 26:02okay in this dish generate will create
- 26:04form and table components as well so
- 26:07let's hit the enter
- 26:09and now let's check admin panel reload
- 26:13the page and it automatically detected
- 26:16and used that categories right here okay
- 26:18so if I click the categories we don't
- 26:21have any categories at the moment but we
- 26:23have full credit functionality I'm going
- 26:25to click new category and call this test
- 26:28for example well slug is not at the
- 26:31moment automatically generated this is
- 26:33something we need to take care of but if
- 26:36I just click create I have the
- 26:38validation error I just type test right
- 26:40here as well and click create okay and
- 26:44we see the record is added we can click
- 26:47edit
- 26:48change we can click delete okay and this
- 26:51is full fully functional uh crot already
- 26:55which is amazing just executing a single
- 26:57line let's do the same thing now for
- 26:59posts but we don't want simple we want
- 27:03full version and we have to specify
- 27:06instead of simple let's specify view as
- 27:08well because we want dedicated view page
- 27:11as well for the Post okay so
- 27:15let's hit the enter so the post resource
- 27:18was generated and if I just reload the
- 27:21page posts are available right here new
- 27:23post and we will have all the fields
- 27:25like titles like thumbnail body and
- 27:28everything is right here okay and we
- 27:30have the user which is uh at the moment
- 27:33drop down but we don't need this right
- 27:35here because we're gonna assign
- 27:37authorized authenticated users
- 27:40okay so now let's check what has been
- 27:42actually generated go in the app let's
- 27:45call UPS everything go in the app
- 27:47filament and right here we have
- 27:49resources and two main resources
- 27:52category resource and post resource and
- 27:55there are also folders with the same
- 27:58name four pages for simple we have
- 28:01manage categories which is responsible
- 28:03this one is responsible for managing the
- 28:06categories and we have dedicated Pages
- 28:09create edit list in The View
- 28:12all right mostly we are going to work
- 28:16inside resources classes okay so now
- 28:19let's open category resource and we're
- 28:22gonna have a look so we have two Fields
- 28:24right here title and slack they are text
- 28:27inputs both of them are required and
- 28:30they also have max length right here and
- 28:32down below we have the table title slot
- 28:35create updated at those fields and we
- 28:38have actions as well edit and delete and
- 28:42we have bulk actions which is delete
- 28:44okay it's pretty awesome
- 28:47now let's have a look in the post
- 28:49resource
- 28:51so we have much more Fields right here
- 28:53title slack all of them not all of them
- 28:56but most of them are text Fields this
- 29:00one is toggle it's actually switch and
- 29:03the doctrine Depot detected that that
- 29:06was a Boolean and it generated switch
- 29:09the filament generated switch for that
- 29:11and we have daytime picker as well right
- 29:14here we can pick the exact time when we
- 29:16want this post to be published on the
- 29:19website and we have select which has
- 29:21relationship to the user and right here
- 29:24we specify which
- 29:26which column I want to be displayed
- 29:29right here that's pretty configurable
- 29:31and really awesome the filament PHP and
- 29:33it's also pretty popular if you check
- 29:35their GitHub you will find like a few
- 29:37thousand stars I think 5 000 Stars right
- 29:40there it's pretty good and that's why
- 29:42it's it's it has so many stars right
- 29:45here I change this field into email just
- 29:46to demonstrate that we can change the
- 29:49relationship column name and just like
- 29:51these is now there is email available
- 29:53but as I mentioned we don't need this
- 29:55user ID right here so we can completely
- 29:58remove it but before I clean up this a
- 30:01little bit I want to First Implement
- 30:03generating slags from the title which is
- 30:06pretty interesting so right here we have
- 30:08the columns and down below we have this
- 30:10actions for posts we have only View and
- 30:13a detections by the way let's add right
- 30:16here delete action as well and we have a
- 30:20bulk daily detection as well so now if I
- 30:24go in the posts and if I just create new
- 30:27test post
- 30:29let's fill on the required fields
- 30:37Okay click create it was created
- 30:39whenever it is created we still stay on
- 30:42the same page this is something which is
- 30:45configurable so we can do that if we
- 30:47don't like and here's the post and we
- 30:50just added delete action right here by
- 30:52adding the following line that delete
- 30:55button is available if we just remove
- 30:57that line we won't see that delete
- 30:59button if we want to delete the post
- 31:02when to go in the edit and then click
- 31:04delete but I think it's really
- 31:06convenient to have this delete right
- 31:08here especially it doesn't delete
- 31:10automatically but it asks this nice
- 31:12confirmation
- 31:13okay I think we we don't need that so we
- 31:16can delete this now let's open category
- 31:19resource and go under title text input
- 31:23field and we have to add uh right here a
- 31:26few few things to uh generate slag based
- 31:30on title and we need to listen to the
- 31:33event after State updated and that's
- 31:38obviously accepts callback
- 31:41because that's an event it accepts
- 31:42callback so we have right here closure
- 31:47set and we accept state as well
- 31:51okay so we can import that closure it's
- 31:55a standard class and then I'm going to
- 31:58call set which is uh closure the set and
- 32:03pass the field name in this case we
- 32:05passed slag and that slug should be at
- 32:09like a title converted into slack so in
- 32:13this case state will be title so I just
- 32:16need to use Str
- 32:18helper to call slag on that and specify
- 32:23state
- 32:24so whenever the state is updated for the
- 32:27title uh
- 32:29alpine.js Live Wire more specifically
- 32:32Live Wire will generate slag and update
- 32:37that so if I save this now and click go
- 32:40in the categories and click new category
- 32:42and just type right here lorem
- 32:45ipsum
- 32:47uh okay it does not work because I
- 32:51missed that we have to specify reactive
- 32:53so this field is reactive okay this is
- 32:56something without that it it doesn't
- 32:58work now let's reload the page
- 33:01and that should be lorem
- 33:05okay so and the slack was automatically
- 33:08generated okay you can change the slack
- 33:11if you don't like and click create uh
- 33:15and when you change this login then if
- 33:17you decide to change the title into
- 33:19something else then slack will be
- 33:22regenerated okay just click create right
- 33:25here and we need to copy this
- 33:29functionality into post Resource as well
- 33:33so let's put this right here
- 33:38okay we have two commas
- 33:42and we need to import closure
- 33:45okay now let's go in the posts click new
- 33:49post and lorem
- 33:51ipsum and this lag is actually generated
- 33:54so perfect now let's adjust the columns
- 33:58of the tables for categories and posts
- 34:00as well as the form input Fields let's
- 34:03open phpstorm and go in the table method
- 34:06and we have title slog created at and
- 34:09updated it I think we don't need slug in
- 34:12this table and maybe created it as well
- 34:14only title and updated it will be enough
- 34:17if I just reload the page we see only
- 34:19those two fields so we can also move
- 34:23these categories into a different
- 34:25section at the moment dashboard
- 34:28categories and posts are all in the same
- 34:30section but we can actually change this
- 34:33if we open this category resource and I
- 34:37believe right here we have this property
- 34:40called navigation group and then we just
- 34:43specify the text for example content I'm
- 34:46going to save this and if I reload the
- 34:49page we see that categories are now
- 34:51under content section in this
- 34:53collapsible section by the way
- 34:55we can also change the icon right here
- 34:59the filament PHP uses a hero icons but
- 35:03version one okay so if we just type in
- 35:06the Google Hero
- 35:08icons and I really love those icons it's
- 35:11very easy to get started and use that
- 35:13you just need to copy SVG in HTML files
- 35:16in this case we need only names but this
- 35:19is version two okay we need to go to the
- 35:22version one
- 35:24here it is and then any name right here
- 35:28can be used
- 35:30after heroicon Dash o instead of
- 35:34collection we can type for example
- 35:36academic cap and just like this we can
- 35:38use any icons available right here which
- 35:41is awesome and we're going to actually
- 35:42change the icon but for the posts
- 35:46let's open post resource and let's
- 35:49change this icon into something like
- 35:52let's search for document Maybe
- 35:56now we have multiple document variations
- 36:01let's use document text I'm going to get
- 36:04this name
- 36:05and paste this right here and now let's
- 36:08use navigation group as well to be the
- 36:12same content so we need uh categories
- 36:15and posts both to be under content
- 36:19section
- 36:20here we go and the icon was also changed
- 36:23for posts
- 36:25now let's open posts and click new post
- 36:28I'm going to work now on this form and
- 36:31adjust the layout change the thumbnail
- 36:34to being a file upload field remove
- 36:38these users basically all the work that
- 36:40is necessary right here and it will also
- 36:42open the filament documentation and what
- 36:45we need is layouts so let's scroll up
- 36:48click on search and we can search for
- 36:51layouts
- 36:53I really like the way how filament PHP
- 36:57gives you possibility to uh
- 37:00configure your layouts okay so if you
- 37:03have a look you we have those columns I
- 37:09think this is for the tables but I want
- 37:11for forms
- 37:14okay I want layouts for forms
- 37:19okay it comes from the okay let's have a
- 37:23look
- 37:25layout
- 37:28yeah that's it
- 37:31here we go so basically all the form is
- 37:35rendered in this category resource right
- 37:37here under form schema method okay so we
- 37:40have those fields we can group them we
- 37:43can reorder them we can split them at
- 37:47the moment it is already split into two
- 37:50columns because by default it is
- 37:52implemented like this but we can
- 37:54actually combine this or we can wrap
- 37:57everything into a card so I'm gonna
- 37:59actually use card at the moment so
- 38:02inside the form we need to use card
- 38:05component that is filament components
- 38:07card make and we have to pass
- 38:11make and then we need schema
- 38:16we pass an array and we can put
- 38:19everything inside the schema so I'm
- 38:21going to actually take everything from
- 38:22here and put this inside the card and
- 38:25let's format the code okay now have
- 38:27everything in the card if I save this
- 38:29and reload the page we see everything
- 38:31now is inside the card and I really like
- 38:34this approach that's that's in my
- 38:36opinion better
- 38:38and I want
- 38:40the for example slug to be on the right
- 38:44side of the title okay in the thumbnail
- 38:46and body and everything to be like like
- 38:48they are at the moment okay so I'm gonna
- 38:51go and make changes right here I'm going
- 38:56to actually use a section component I
- 38:59believe it is section
- 39:01let's actually go in the documentation
- 39:05and search for
- 39:07section
- 39:11also has heading maybe we don't want
- 39:16heading it's called probably something
- 39:18else so we have possibility to generate
- 39:21Wizards or tabs or field sets
- 39:26I think what I need is either grid
- 39:30yeah I think we need grid so I'm going
- 39:33to get the grid
- 39:34paste but I won't
- 39:38The r2b2 Columns okay and actually if I
- 39:42just delete and autocomplete grid okay
- 39:44here we go so I'm going to call make
- 39:46with two columns and then I'm going to
- 39:49call
- 39:51schema on that
- 39:53and put title in slug in site
- 39:59okay
- 40:01so now we have
- 40:03form inside the form we have single card
- 40:06like this inside card we have one grid
- 40:12and then we have Fields okay if I save
- 40:15this in now have a look
- 40:18now I see title and slog next to each
- 40:21other okay this is exactly how I want it
- 40:23so if I start typing now this log is
- 40:26still populated now let's change this
- 40:28thumbnail into file upload so I'm going
- 40:31to use now file upload and we don't need
- 40:35max length and
- 40:38let's have a look here it is
- 40:40and we can have a look in the how many
- 40:43ends did I set okay
- 40:47let's search for fields
- 40:53I want to show you all field options
- 40:56what we have
- 40:58here it is under four Builder section I
- 41:01really like the documentation it's a
- 41:03very well organized
- 41:05uh we are are a where's that
- 41:10here it is so field getting started okay
- 41:13this is where we are at the moment and
- 41:15we have uh many different types
- 41:18like text input select checkbox toggle a
- 41:21radio file upload reach tags reach
- 41:24editor which is we can also use and
- 41:26repeater and Builder and uh here here's
- 41:30everything basically what it supports
- 41:32and you can also have create your own
- 41:35custom custom fields which is pretty
- 41:38cool
- 41:39okay I'm going to change these thumbnail
- 41:41into file upload I already did that I'm
- 41:43going to change this into reach editor
- 41:45that should be toggled and I'm going to
- 41:49remove the user but I'm going to change
- 41:51this into categories okay so
- 41:54relationship goes into categories
- 41:57and the title should be the column name
- 42:01should be title because categories has
- 42:05title column so we're gonna display
- 42:07title right here
- 42:09and this should be categories
- 42:13like this
- 42:15okay and that is required now that's
- 42:18actually not required you can skip
- 42:20categories on the post or or let's let's
- 42:25make it required why why you should
- 42:27create a post without categories not
- 42:30sure now let's reload the page we have
- 42:33an error
- 42:34belongs to many get owner key and name I
- 42:40think that should be
- 42:42it should be category ID
- 42:48no
- 42:49let's specify right here multiple
- 42:53we we need this to be multiple maybe
- 42:55that's that's the point yeah
- 42:58that's it so now inside categories when
- 43:02we start typing something it
- 43:05autocompletes at the moment I think we
- 43:07don't have anything in the categories so
- 43:09I want to actually delete this and
- 43:11create few actual categories like
- 43:13JavaScript
- 43:16let's create
- 43:18PHP
- 43:22let's create
- 43:24alarm l
- 43:26I think three will be now
- 43:28or testing
- 43:30new form
- 43:31and I start typing and it searches and
- 43:35duties so we can specify now multiple
- 43:37categories to our post and that looks
- 43:41pretty cool
- 43:42so I want to re change the layout again
- 43:44and this is also Rich Text pay attention
- 43:46but I want to change the layout and I
- 43:49want like a thumbnail in categories to
- 43:53be on the right side of this form so
- 43:56here we have this card and I'm going to
- 43:59create
- 44:00well we can create another card or we
- 44:03can create a greed
- 44:06and that greed uh can be splitted into
- 44:11how should I do this so let's make this
- 44:14form
- 44:15to have like a column length columns 12
- 44:19columns okay so the form now has 12
- 44:22columns this card which is the main card
- 44:25let's give it
- 44:27let's give it calls Pawn column spawn to
- 44:31have eight
- 44:33and I'm going to create now the same
- 44:35type of card second card now
- 44:40and that will have comma is missing here
- 44:43and this will have
- 44:46call spawn four
- 44:49okay and I'm going to take thumbnail
- 44:54and categories
- 44:58inside the sidebar so I format the code
- 45:02save everything reload the page and this
- 45:05is exactly what I wanted so we see right
- 45:07here horizontal scroll because my
- 45:09browser zoomed in uh a lot actually
- 45:13because I'm like generally zooming when
- 45:16I when I'm developing something it's it
- 45:18was even zoomed out but like on a normal
- 45:21screen it will look like this okay you
- 45:24can adjust the layout as much as you
- 45:26need if I click browse and choose some
- 45:29type of image let's choose this one then
- 45:32it is uploaded successfully and if I
- 45:36choose now
- 45:37let's save this actually let's make
- 45:39record so
- 45:41um
- 45:42I have this Auto completed why
- 45:44JavaScript is weird and lorem ipsum
- 45:49okay let's create click create this
- 45:51field is required but that should not be
- 45:53required so I I should
- 45:57have made it optional in migrations
- 46:02I'm going to specify this right now
- 46:05create record
- 46:06user ID doesn't have default value okay
- 46:09so now we need to set the user when the
- 46:13record is about to be created
- 46:16let's open again filament documentation
- 46:19and let's search for
- 46:22creating records
- 46:26creating records
- 46:28and customizing Data before saving this
- 46:31is exactly what we want and we can
- 46:35create we should create the following
- 46:37function I'm going to actually copy this
- 46:38function and go under
- 46:42post resource and create post okay so
- 46:46that is
- 46:47which should have the following method
- 46:50and if I save this now
- 46:53and just close this and hit create again
- 46:58hit create again
- 47:01okay I think
- 47:04because this is required
- 47:07but I actually populate this okay so
- 47:10that was created
- 47:11that was created
- 47:14okay here it is so we have user zura we
- 47:17have created update that basically
- 47:19everything except the thumbnail because
- 47:21the thumbnail needs to be an image okay
- 47:24and I think because we have this is the
- 47:26view Page by the way when we click on
- 47:28the record this is view page I click
- 47:30edit we are in the edit page the image
- 47:32is not properly saved let's choose the
- 47:37image again
- 47:39let's make detective by the way
- 47:42and let's click save changes okay that
- 47:44was saved
- 47:46okay now we have the thumbnail
- 47:49okay perfect now let's
- 47:52let's modify this table because I think
- 47:54we did everything uh pretty
- 47:58well in the uh article post creation
- 48:02page
- 48:03now let's adjust this let's go in the
- 48:06post resource scroll down below I don't
- 48:09want slog
- 48:11I don't want body and
- 48:15do I need username no I think I don't
- 48:19need the username
- 48:21however I'm going to comment this out
- 48:23don't remove and I'm going to remove
- 48:25also uh created it I will leave these
- 48:27published it so I save this and I'm
- 48:30going to make this also to be image
- 48:32column
- 48:33and the active
- 48:35is icon column which is good
- 48:39so I just reload the page let's move
- 48:41this thumbnail as a very first so we
- 48:45have a thumbnail we have titles status
- 48:48published it and updated it
- 48:52okay and just like this we have
- 48:56customized our crud whenever we click on
- 49:01the recording it is selected we have
- 49:03possibility to delete because that is
- 49:05added in the bulk edit bulk actions
- 49:09that's awesome
- 49:15if you are enjoying this video so far
- 49:17make sure you hit the like button
- 49:19thank you
- 49:23now I'm going to create one more post
- 49:25and then we can move on the front end
- 49:27that is lorem
- 49:29ipsum post and I'll specify right here
- 49:34oops to be PHP
- 49:38I'm not going to make it active also I'm
- 49:41not going to choose published it let's
- 49:44type test right here and click create
- 49:47okay we just need to adjust this I'm
- 49:49going to go in the post resource and in
- 49:52the form I'm going to remove required on
- 49:56the publish date however if it is
- 49:59required on the database level we are
- 50:01going to have problems so
- 50:04uh let's just reload the page
- 50:07let's specify Laura ipsum
- 50:11and click create
- 50:12okay category is required so we have to
- 50:16specify it
- 50:17this is required we have to specify it
- 50:20and click create
- 50:23okay publish that can be now that's
- 50:25exactly what I was thinking so actually
- 50:28I prefer to open now my existing
- 50:31migration which is for categories
- 50:37unfortunately I have to
- 50:40like I can create new migration and
- 50:43change the column but I think it will be
- 50:46more relevant to just uh make these
- 50:52nullable right here but in this case I
- 50:56have to drop last two migrations and
- 50:59recreate them so PHP Artisan uh migrate
- 51:06I'll roll back
- 51:09Dash Dash step equals two it will roll
- 51:14back
- 51:16let me create roll back
- 51:19okay is there any kind of error
- 51:23Canon drop table pause referenced by
- 51:26Foreign key constraint
- 51:33Okay so
- 51:37hold on
- 51:40right here I am dropping category posts
- 51:45but that should be category post
- 51:48this is the problem
- 51:51okay so this was problem because when
- 51:55this group migration rollback was run it
- 51:59tried to drop the category posts and
- 52:03then when the second migration was run
- 52:04it tried to draw posts but that post was
- 52:08still referencing to the category post
- 52:10table
- 52:11so let's execute these
- 52:17okay we have problem again
- 52:25drop table if exist pose that references
- 52:29to category post ID foreign okay white
- 52:33is that
- 52:34problem actually
- 52:42so first category post needs to be
- 52:44dropped right so I execute
- 52:48step one
- 52:54I think that was already dropped if we
- 52:58check migrations
- 53:05if we check migrations that's
- 53:07interesting what's going to be the
- 53:09status right there I'm going to use now
- 53:11phpstorms database tool and you can use
- 53:15basically any database client like MySQL
- 53:18workbench for example to connect to the
- 53:20database which is running under Docker
- 53:23so the host is localhost this is the
- 53:26default Port the user will be sale and
- 53:30password is just password
- 53:33literally password
- 53:36like this
- 53:38okay let's test the connection
- 53:40yep it works
- 53:43let me choose the schema
- 53:46schema needs to be
- 53:50okay what's key Mouse do we have
- 53:53there are four schemas laravel 10 block
- 53:56new this is what I want to choose and
- 53:59check now migrations
- 54:02let's have a look what's the latest
- 54:04migration there let's create posts table
- 54:07and it it is trying to drop posts
- 54:14but I think it cannot drop because there
- 54:17are records in the posts
- 54:20okay that is very very edge case because
- 54:23I just uh forgot to add the nullable in
- 54:26the published it so it doesn't work to
- 54:29spend too much time on this I'm going to
- 54:30go in the posts and just delete that and
- 54:34hopefully now I can roll back
- 54:39one
- 54:40no actually it does not roll back why
- 54:43because probably because the table is
- 54:46not dropped category post is not dropped
- 54:48exactly exactly so the previous
- 54:50migration that migration was rolled back
- 54:54because right here it was written
- 54:58right here it was written drop if exists
- 55:01category posts that did not exist the
- 55:05category post table that was not dropped
- 55:09and but this record was removed from the
- 55:13migrations table is successfully rolled
- 55:16back
- 55:18that's that's it so I can manually
- 55:20delete category post
- 55:22okay
- 55:24and now I can roll back
- 55:27yes and now I can run PHP art design me
- 55:31great okay those two migrations will be
- 55:34reapplied now if I check the database I
- 55:37will see category post right here
- 55:39and again I'm going to check uh post
- 55:43table and I will see published it is not
- 55:46required anymore okay it doesn't have
- 55:49that Green Dot next to it which
- 55:52indicates that it is required or not now
- 55:55I'm going to go under hose and I'm going
- 55:58to create
- 55:59why JavaScript is weird again let's
- 56:02choose this keyboard which is not
- 56:04relevant but like we are testing at the
- 56:06moment
- 56:08here it is
- 56:09and let's specify test here and click
- 56:13create okay that was created we haven't
- 56:17specified published yet because we just
- 56:19created our post we don't want it to be
- 56:21published at the moment okay that's the
- 56:24whole idea let's create second post
- 56:26lorem ipsum test
- 56:29let's specify
- 56:31now Mouse
- 56:34and test again right here
- 56:37right here we have possibility to
- 56:40specify headings and subheadings and
- 56:42lists and images as well as the code
- 56:45block which is pretty cool
- 56:48okay let's choose now this to be laravel
- 56:54and click create
- 56:56okay so we have successfully created two
- 57:00posts
- 57:03and I think now we can move on the front
- 57:05and side okay now let's open front end
- 57:08I'm gonna just uh
- 57:10let's duplicate this probably and remove
- 57:13it so this is the front-end side and
- 57:16this is our blog template which we want
- 57:19to
- 57:20either download or grab content so you
- 57:25click this get template it opens the
- 57:27GitHub link and then we have two html's
- 57:29plugin posts I'm going to click on blog
- 57:32and right here we have the whole HTML it
- 57:35uses alpine.js and Talon CSS
- 57:39okay and we need to adjust them
- 57:44okay I'm gonna click on row and get
- 57:47entire HTML
- 57:49okay now let's open
- 57:52uh phpstorm and go let's collapse
- 57:56everything and go under resources and
- 57:59Views at the moment we have only welcome
- 58:01blade which has the layout as well as
- 58:03the content we don't need that uh to be
- 58:07like this I want to create layout
- 58:09so I'm going to create now component
- 58:13PHP artisan make
- 58:16component let's call this up layout
- 58:21hit the enter okay app layout component
- 58:23was created so if we go in under app
- 58:26view components up layout it has right
- 58:30here view named which is under
- 58:33components app layout well I'm going to
- 58:36change these to be layouts
- 58:39up just like this
- 58:42so now if I go in the resources views
- 58:46right here we have components and then
- 58:48app layout I'm going to rename the
- 58:51components folder called this layouts
- 58:53and I'm going to rename this app layout
- 58:56and just call
- 58:57up
- 58:59so that the view name exactly matches
- 59:02now the component layout and I'm going
- 59:06to open now layout which is empty almost
- 59:09empty now it's empty and I'm going to
- 59:11paste entire HTML which I copied from
- 59:15the GitHub okay now let's identify what
- 59:18is actually layout and what is part of
- 59:21The View
- 59:23so this is body we have the navigation
- 59:27we have the header and we have a topic
- 59:32navigation as well and then container
- 59:35comes and then we have the section
- 59:38and then a side and below is a footer
- 59:41okay and some alpine.js scripts so
- 59:47if we have a look in the design
- 59:50so what is the layout obviously this top
- 59:53part is part of layout we can consider
- 59:57this about us and that Instagram section
- 1:00:00to be part of layout as well or maybe we
- 1:00:03don't even need that I actually want to
- 1:00:05put right here latest posts maybe or
- 1:00:09latest categories right here we don't
- 1:00:13need obviously this in Instagram section
- 1:00:16so we can at the moment we can make this
- 1:00:21part of the layout okay and this will be
- 1:00:24actually the content so this will be
- 1:00:27actually content I'm going to get these
- 1:00:29and because this is layout I'm going to
- 1:00:32Output right here slot
- 1:00:35okay now I'm going to open this welcome
- 1:00:37blade
- 1:00:40um actually I just copied this portion
- 1:00:43so I'm going to save it somewhere
- 1:00:45so I'm going to create new scritch file
- 1:00:48blade scratch file and paste it okay
- 1:00:51here we have couple of Articles those
- 1:00:53are demo articles I don't want this uh
- 1:00:56to be lost so I have this in scratch
- 1:00:58file
- 1:01:00now right here we have to make few
- 1:01:03changes if I open we'll complete again
- 1:01:05like the language is taken from the app
- 1:01:09get local so I need to get that HTML in
- 1:01:13the layout replace that like
- 1:01:15oops copy this and replace here
- 1:01:20okay we also want
- 1:01:23this is the welcome
- 1:01:26Inc
- 1:01:32title
- 1:01:34so we can use the title
- 1:01:37from the configs but I think that's okay
- 1:01:40so we can leave this at the moment
- 1:01:41talwind blog template uh the content the
- 1:01:46author content we can remove that
- 1:01:49okay I think this is
- 1:01:51this is okay this is good now let's edit
- 1:01:55uh this welcome delete everything and
- 1:01:59take those articles from the scratch
- 1:02:01file and put under welcome
- 1:02:04okay then I'm going to close the script
- 1:02:06file and finally I'm going to rename the
- 1:02:10welcome to be homeblade
- 1:02:13okay now if we open web.php and change
- 1:02:17this into home save that and open our
- 1:02:22application and just reload
- 1:02:24uh we have problem we don't have styles
- 1:02:29let's inspect this
- 1:02:32and have a look
- 1:02:34reload the page
- 1:02:37okay I know the reason in the home we
- 1:02:42don't use the component as a layout so
- 1:02:46we need to use x up layout
- 1:02:52like this save and reload and here we go
- 1:02:57so this is now our laravel application
- 1:02:59we have layout defined and we have
- 1:03:02content coming from the home
- 1:03:05now let's create controller and select
- 1:03:09posts and pass this to the view and
- 1:03:11render them properly we don't want
- 1:03:13anything to be hard-coded right here
- 1:03:15okay I'm gonna bring up the terminal and
- 1:03:17create controller by executing PHP
- 1:03:19artisan make
- 1:03:21controller and let's call this post
- 1:03:24controller and let's also specify dash
- 1:03:28dash resource we don't need everything
- 1:03:30every resource methods but let's specify
- 1:03:33still because deleting is much easier
- 1:03:35than create than writing so resource and
- 1:03:39dash dash model equals post let's hit
- 1:03:42the enter post controller created
- 1:03:45successfully and let's open post
- 1:03:48controller and we have to work in the
- 1:03:51index let's actually return view from
- 1:03:55here which should be
- 1:03:57home
- 1:03:59okay and let's open web and I'm going to
- 1:04:03change this into
- 1:04:06post controller
- 1:04:09index
- 1:04:11and let's give it also a name
- 1:04:14to be home
- 1:04:16and let's change this use qualifier with
- 1:04:20import
- 1:04:21so I save this reload I see the exact
- 1:04:25same result now let's open post
- 1:04:27controller and I'm going to actually
- 1:04:29close everything else
- 1:04:31so right here we can by the way specify
- 1:04:33uh based on the PHP based on the laravel
- 1:04:38chain and now we can have types
- 1:04:41everywhere because the minimum PHP
- 1:04:44requirement for a lot of attain is 8.1
- 1:04:46okay we can specify a view for example
- 1:04:49that should return illuminate View
- 1:04:53or we can just leave this empty as it is
- 1:04:56right now that's not going to hurt as
- 1:04:57well but that's additional like small uh
- 1:05:00security measurement that make sure that
- 1:05:03you always return vo and nothing else
- 1:05:05from from here now we need to query
- 1:05:08posts
- 1:05:10all SQL
- 1:05:12post a specified query and we want to
- 1:05:17um
- 1:05:18only select those posts which has active
- 1:05:24equals
- 1:05:25one
- 1:05:27and we want also
- 1:05:30those which is published
- 1:05:33so where
- 1:05:36published it
- 1:05:41equals
- 1:05:44null
- 1:05:46or no where it does not equal now
- 1:05:49actually or is not null would be more uh
- 1:05:53more accurate maybe but let's have a
- 1:05:56look what this will select order by
- 1:06:01we're gonna order that by published it
- 1:06:06with descending
- 1:06:08and I'm going to call paginate on that
- 1:06:10because we will need pagination as well
- 1:06:12so we have posts and I'm gonna pass now
- 1:06:15posts using compact function
- 1:06:19to view
- 1:06:21now if I open
- 1:06:23home.blade PHP
- 1:06:25right here
- 1:06:27we need we have three articles
- 1:06:31okay the structure is identical but we
- 1:06:34don't need all of them we just need one
- 1:06:36which we need to put inside the loop but
- 1:06:39I want to actually create
- 1:06:41maybe a separate dedicated component or
- 1:06:46that article
- 1:06:47PHP artisan make
- 1:06:51a component
- 1:06:53let's call this
- 1:06:55uh post item component
- 1:07:00okay and I think we don't need
- 1:07:03a special class for that we can just
- 1:07:07create view only
- 1:07:09uh view
- 1:07:11I believe that's the correct flag
- 1:07:14component created successfully now let's
- 1:07:16have a look uh do we have the component
- 1:07:19under up view components now we don't
- 1:07:22have if we go under resources views
- 1:07:26components we have
- 1:07:28post item right here okay and now I'm
- 1:07:31gonna copy this article and paste into
- 1:07:34post item
- 1:07:37and we're going to accept right here
- 1:07:39post and then based on the post we are
- 1:07:43going to Output certain information
- 1:07:46but from here
- 1:07:48we are gonna iterate over posts is post
- 1:07:56and then we're going to call X post item
- 1:08:02like this and we specify post
- 1:08:08that's going to be the post like this we
- 1:08:12need to accept that uh post right here
- 1:08:15let's Implement actually outputting post
- 1:08:18item right here in this component so we
- 1:08:22already have post variable available
- 1:08:23right here so let's just try to Output
- 1:08:26right here thumbnail for example post
- 1:08:30thumbnail
- 1:08:32then right here we need to Output
- 1:08:34categories so I'm going to start
- 1:08:36iterating over categories for the Post
- 1:08:39we will need post categories is a
- 1:08:43category
- 1:08:45and like this let's output right here
- 1:08:49category
- 1:08:51title and right here we need to link to
- 1:08:56that page where we will see only those
- 1:09:00posts which belong to the category so we
- 1:09:03don't have that road created yet so I'm
- 1:09:05going to leave these as it is right now
- 1:09:07so this one will be title for the Post
- 1:09:11because this is a post item so this
- 1:09:15should not be an a
- 1:09:16um
- 1:09:17excuse me so this should be an a
- 1:09:19actually and this should be linked uh to
- 1:09:22the inner page of the post we don't also
- 1:09:25have that road we're going to create
- 1:09:26that so let's output right here post
- 1:09:30title at the moment
- 1:09:33and down below we have the user
- 1:09:36so we can have
- 1:09:39uh post
- 1:09:41like this host user name
- 1:09:46and published on Android here we need
- 1:09:48date okay so here we should have post
- 1:09:52published it
- 1:09:55and down below we need to Output the
- 1:09:58description the content
- 1:10:01not the whole content should be outputed
- 1:10:03right here so it will make sense if we
- 1:10:06just output
- 1:10:08short like a few few symbols not not the
- 1:10:12whole body so maybe let's assume that we
- 1:10:16create a special method in the post
- 1:10:19model like um get or just short body
- 1:10:24okay so post has buddy but we don't want
- 1:10:27the whole body to be outputted in the
- 1:10:29listing so let's just call short body
- 1:10:32and we will have to create that method
- 1:10:36in the
- 1:10:37in the post but for now let's save this
- 1:10:41and have a look in the browser
- 1:10:44here we go so let's just click on this
- 1:10:46roll the page
- 1:10:47okay nothing is actually selected and
- 1:10:50let's go in the post controller because
- 1:10:52I think we have something
- 1:10:54Okay so
- 1:10:56this wear should be probably changed
- 1:10:59into a weird date because we have that
- 1:11:02to be date
- 1:11:04and then published it must be
- 1:11:09published it actually must be
- 1:11:12um
- 1:11:14less than
- 1:11:16now and we should use carbon now
- 1:11:20okay so published it needs to be uh in
- 1:11:24the past basically so if I save this
- 1:11:29and now rule of the page
- 1:11:31we don't see anything now let's check
- 1:11:34our posts and yeah the active status is
- 1:11:37not marked so we just click on edit and
- 1:11:40let's mark this active and let's choose
- 1:11:43date which is in the past
- 1:11:45okay so that was saved and let's
- 1:11:49activate the second one
- 1:11:54that is in the past
- 1:11:57perfect now let's reload the page okay
- 1:11:59so we have an error which is good the
- 1:12:01short body doesn't exist now let's open
- 1:12:04host here we have the post model and we
- 1:12:07have control and click on that
- 1:12:09and now let's create that short body
- 1:12:13now we should return string and we are
- 1:12:17going to return from here Str
- 1:12:20words
- 1:12:22I think I'm using different Str
- 1:12:24uh return Str which should be illuminate
- 1:12:28illuminate support
- 1:12:30then we're going to call words method
- 1:12:32and that then I'm going to strip strip
- 1:12:36tags remove basically any tags from this
- 1:12:40body and then finally I'm going to just
- 1:12:42output like a 30 words from this um from
- 1:12:46this body so if I save this now and
- 1:12:48reload the page we see post is actually
- 1:12:51rendered the description is not there
- 1:12:53because the description
- 1:12:55actually is not written inside so let me
- 1:12:59actually generate lorem ipsum text if I
- 1:13:03go in any blade file and just type lore
- 1:13:06m
- 1:13:07and hit the tab this is it okay so I'm
- 1:13:11going to cut this
- 1:13:12and then I'm going to basically delete
- 1:13:15everything and paste oops
- 1:13:18okay let me remove any kind of
- 1:13:19formatting paste this right here and I'm
- 1:13:22going to paste multiple paragraphs okay
- 1:13:24so this is just just lowering me some
- 1:13:27text
- 1:13:28so I say that was lowering up some tests
- 1:13:31and now if I just reload
- 1:13:36so here we see that the title is not
- 1:13:39outputted for some reason where is the
- 1:13:42Post item oops I have a typo
- 1:13:46lowering some test and as you see
- 1:13:49we see like a short description of the
- 1:13:52long
- 1:13:53and that's pretty cool if the
- 1:13:55description is too small then the card
- 1:13:57is displayed like this that's a Talon
- 1:13:59CSS like a ping and we can fix that
- 1:14:03using title and CSS but in most cases in
- 1:14:0699 persons the descriptions will always
- 1:14:09be at least one line so if the
- 1:14:11description is like long enough then
- 1:14:14this card will be on full width but of
- 1:14:16course like we can add some tolerances
- 1:14:18classes to stretch the Turn full width
- 1:14:20what I don't like is
- 1:14:22the
- 1:14:24date how this looks like so let's create
- 1:14:27actually
- 1:14:28a function like git a formatted date
- 1:14:33something like this and let's open now
- 1:14:36this post and create
- 1:14:39formatted data we're going to return
- 1:14:41this
- 1:14:44published it in the published it
- 1:14:47actually needs to be an instance of
- 1:14:52carbon by default published it will be I
- 1:14:56think it will be string
- 1:14:58um
- 1:15:00actually that's good point to actually
- 1:15:02see what's published at so this
- 1:15:07published it
- 1:15:10okay now let's see what's published it
- 1:15:12that's a string as I mentioned but if we
- 1:15:16create a protected variable costs right
- 1:15:19here and specify that published it I
- 1:15:22want this to be like date time then this
- 1:15:27will be an instance of carbon so if I
- 1:15:30say this and Rule of the page now we see
- 1:15:33that this is an instance of carbon okay
- 1:15:35and on this date time right here I can
- 1:15:39call method like format and specify the
- 1:15:42format so I want the format to be F oh
- 1:15:47let's put in the string F then J
- 1:15:50uppercase s and Y so you will see what's
- 1:15:56the formats
- 1:15:57and I'm going to just uh reload the page
- 1:16:00so here we see so J is the name of the
- 1:16:04math
- 1:16:05then we have sorry f is the name of the
- 1:16:09math then we have J which is the number
- 1:16:13day of the month
- 1:16:15and then we have this uppercase s which
- 1:16:18is the um
- 1:16:21this Rd or first if it's a one it's
- 1:16:24going to be St if it's 2 it's going to
- 1:16:28be in D I think it's called ordinal
- 1:16:30index
- 1:16:32mature so if we just search for like PHP
- 1:16:35date time format you will see the actual
- 1:16:39name of what is this like uppercase
- 1:16:43s
- 1:16:45somewhere right here
- 1:16:52I'm just curious
- 1:16:55here it is ordinal suffix exactly okay
- 1:16:59so that's uppercases and if you want to
- 1:17:01like change the formatting you can find
- 1:17:03all the formats possible forms right
- 1:17:04here so I'm going to close this okay now
- 1:17:06we have dates uh now have user
- 1:17:09and we have the listing actually the
- 1:17:12category is actually also correctly
- 1:17:14outputted however the image is not
- 1:17:17correctly outputted and if we inspect
- 1:17:18the image to see what's the path and we
- 1:17:21see right here that we don't have
- 1:17:24like um this is localhost Slash the file
- 1:17:27name so probably storage is missing
- 1:17:31right there so if I go in the thumbnail
- 1:17:34input slash storage
- 1:17:37save and just reload
- 1:17:40here we go so we have now
- 1:17:43we have now images available
- 1:17:46so I think that's pretty cool now we can
- 1:17:49think this is pretty cool now I think we
- 1:17:52can move on the pagination
- 1:17:54to actually activate the pagination we
- 1:17:56need more than two items two posts I'm
- 1:18:00gonna go ahead and create all the posts
- 1:18:01and see that I'm gonna use a cedar for
- 1:18:04this let's bring up the terminal and I'm
- 1:18:06going to execute PHP artisan make I'm
- 1:18:11going to create Factory that's going to
- 1:18:13post Factory
- 1:18:15see the internal is open post Factory
- 1:18:22here it goes and we have to define the
- 1:18:25definitions for the fields for each
- 1:18:27field so we have title
- 1:18:31which is going to be like a fake title
- 1:18:35so actually I'm going to create a
- 1:18:37variable right here title which will be
- 1:18:39like fake
- 1:18:41uh real real text and we can specify
- 1:18:45this real text the length of the text as
- 1:18:47well like 50 for example let's specify
- 1:18:50so we need title right here we also need
- 1:18:53the slack which needs to be generated
- 1:18:55from the title that's why I created
- 1:18:56title as a variable so I'm going to use
- 1:18:58the Str slag method for this passing
- 1:19:02title we will need thumbnail
- 1:19:06thumb up
- 1:19:08nail which is going to be
- 1:19:14image URL we will need body
- 1:19:20make
- 1:19:22real text and in the real text we can
- 1:19:24specify like a large
- 1:19:27number
- 1:19:29or Max characters we need active
- 1:19:33which needs to be
- 1:19:37Boolean
- 1:19:39and we have
- 1:19:42published
- 1:19:44excuse me published it which needs to be
- 1:19:50a random date time
- 1:19:53okay like this and user ID let's specify
- 1:19:57at the moment user wants so basically
- 1:19:59every uh post created by this Factory
- 1:20:02will belong to the user one now let's
- 1:20:05open
- 1:20:07a data base Cedar and let's uncomment
- 1:20:11this Factory and change this into post
- 1:20:14and we want to create like a 50
- 1:20:18posts using this database seater so PHP
- 1:20:22Artisan DB colon seed let's hit the
- 1:20:26enter setting database it was finished
- 1:20:28now let's reload the page
- 1:20:33and we have those posts created which is
- 1:20:37fantastic the images are broken because
- 1:20:40every image now has a slash storage
- 1:20:44before that okay so I guess that's okay
- 1:20:48for now because we just uh like fake
- 1:20:51created the post and the URL basically
- 1:20:53is an absolute URL from the uh
- 1:20:56placeholder via placeholder.com so in
- 1:20:59our application we won't have that like
- 1:21:01the absolute URLs but it's going to be
- 1:21:04good addition into the system if we
- 1:21:06create a function right here which will
- 1:21:09check if the URL starts with HTTP then
- 1:21:13it's going to return different thing
- 1:21:15otherwise it's going to return different
- 1:21:16things so basically I'm going to use Str
- 1:21:21hearts
- 1:21:23excuse me what I'm doing
- 1:21:26stupid mistake so get get thumbnail
- 1:21:30maybe so inside get thumbnail I'm going
- 1:21:33to check if Str come on
- 1:21:38starts with I'm going to specify if this
- 1:21:42thumbnail if that starts with http
- 1:21:47then I'm going to return this
- 1:21:51thumbnail
- 1:21:52okay
- 1:21:54let's put semicolon otherwise we are
- 1:21:57going to return slash storage slash
- 1:22:00company
- 1:22:02so I save this and now all the images
- 1:22:05should be rendered properly
- 1:22:08okay we have this one this one but the
- 1:22:10others are not rendered now let's check
- 1:22:12what's going on
- 1:22:16okay that storage is still aided
- 1:22:18if Str starts with
- 1:22:22so if the thumbnail starts with http
- 1:22:26it's gonna return this thumbnail
- 1:22:30excuse me I don't use this gate terminal
- 1:22:32so I I generally make such type of
- 1:22:34mistakes very often so I create that
- 1:22:36everything looks good I'm surprised why
- 1:22:39it doesn't work
- 1:22:40stupid mistake we don't use that
- 1:22:44it
- 1:22:45thumbnail
- 1:22:47here we go load the page
- 1:22:51Okay okay something is wrong
- 1:22:54now it's broken for
- 1:22:57everything
- 1:23:00storage so we have storage twice I think
- 1:23:02they should be removed that's it
- 1:23:06that's more like it
- 1:23:09no it's not
- 1:23:10more like it
- 1:23:14yeah the other images are there
- 1:23:16but our actual images are not there
- 1:23:21why
- 1:23:23because I don't
- 1:23:25concatenate this with these
- 1:23:31another stupid mistake no this uh
- 1:23:35okay challenge do you know what will
- 1:23:37happen if I leave this code like this
- 1:23:40just think for five seconds pause the
- 1:23:43video think for five seconds and just
- 1:23:45let me know
- 1:23:48let me know in the comment section down
- 1:23:49below what was your thoughts but that's
- 1:23:52gonna definitely cause the uh rushing
- 1:23:55our browser server because we are
- 1:23:57calling git thumbnail inside get
- 1:23:59thumbnail and just like this we will
- 1:24:01crush it
- 1:24:03it's basically a recursive function
- 1:24:05without base case Okay so we're gonna
- 1:24:08use this get thumbnail now if I reload
- 1:24:11the page we see the images there
- 1:24:15okay so now we have
- 1:24:18more than enough post items to implement
- 1:24:22actually
- 1:24:23a G nation so let's go in the post
- 1:24:25controller and I'm going to set the page
- 1:24:27Niche 18 to 5. so to make the scrolling
- 1:24:31easier and now let's go in the home
- 1:24:35and we have this hard-coded pagination
- 1:24:37links and at the top of that
- 1:24:39we are going to Output post links the
- 1:24:43post basically is a variable which is a
- 1:24:47paginator variable instance of the
- 1:24:49paginator and then links will simply
- 1:24:52render
- 1:24:55hosts excuse me posts links
- 1:24:59links will will render the pagination
- 1:25:02buttons as you see right here okay but
- 1:25:05we need to adjust these pagination
- 1:25:08buttons try to create the same design as
- 1:25:12we have down below
- 1:25:14okay and we just need to publish the
- 1:25:17paginator views and modify it so if I
- 1:25:20open now laravel documentation laravel
- 1:25:28go in the documentation and search for
- 1:25:30agination
- 1:25:33then let's search for publish
- 1:25:36here we go so under Section like
- 1:25:39customizing The pagination View we can
- 1:25:42publish the lateral pagination views and
- 1:25:44then we can customize that okay so I'm
- 1:25:46going to copy this command open the
- 1:25:48terminal and paste this and hit the
- 1:25:51enter so it's actually published the
- 1:25:53pagination assets and we can find this
- 1:25:56under resources views vendor pagination
- 1:25:58so let's go under resources views vendor
- 1:26:03pagination in this idea we have
- 1:26:05different versions for pagination like
- 1:26:08bootstrap four five some semantic UI Etc
- 1:26:11so what we are interested is the tile
- 1:26:13wind blade because this is the default
- 1:26:15one which is used to just test it if
- 1:26:18this is the actual one I'm going to
- 1:26:19delete everything say that and reload
- 1:26:22the website and we won't see this
- 1:26:25pagination anymore okay so let's undo
- 1:26:27this and now let's actually tweak this
- 1:26:29we have to make few changes right here
- 1:26:32let's have a look in the home so we have
- 1:26:35the following classes for the pagination
- 1:26:38item which is actually active so this
- 1:26:41one is indicate indicates that the item
- 1:26:44is active so let's actually copy this
- 1:26:48open our
- 1:26:50Talent blade and find the if statement
- 1:26:54which indicates which one is actually
- 1:26:56active so I think this is for the mobile
- 1:27:02and this is for desktop okay let's focus
- 1:27:04on the desktop fully
- 1:27:06so here we have this is showing how many
- 1:27:09items we're going to have so this let's
- 1:27:12roll over the page
- 1:27:14so it's showing so we don't actually
- 1:27:17have this in our design so let's
- 1:27:19actually remove it I'm going to remove
- 1:27:21the showing now if the paginator is on
- 1:27:24the first page then we render the
- 1:27:26previous we're going to take care of
- 1:27:28these a little bit later
- 1:27:30in this case we have this previous URL
- 1:27:37uh okay where is that
- 1:27:41that's for three dot separator which we
- 1:27:44I think also don't need but let's scroll
- 1:27:47down below here it is so if the page is
- 1:27:49current page then these are the classes
- 1:27:52we are going to add
- 1:27:54so I'm gonna now paste this save and
- 1:27:57have a look
- 1:28:00okay this is it okay that looks exactly
- 1:28:03as this one now let's create styles for
- 1:28:07the second one
- 1:28:08now let's go in home
- 1:28:10this is for the second
- 1:28:14I think we need to add these classes
- 1:28:16right here
- 1:28:21here we go I'm going to paste this or
- 1:28:24reload the page
- 1:28:26okay that's good there's also Shadow on
- 1:28:30this I'm going to remove that shadow
- 1:28:38where's that shadow
- 1:28:41this is for next
- 1:28:43Shadow will be right here on the span
- 1:28:50okay now we don't have shadows we have a
- 1:28:52horror effect now let's implement the
- 1:28:54next button
- 1:28:56so scroll down below if paginator has
- 1:29:00more pages then this is for the next one
- 1:29:02otherwise this is probably next but it's
- 1:29:06going to be disabled so we don't show
- 1:29:09disable the next pattern instead we can
- 1:29:11remove that
- 1:29:12but if there's more pages we need to
- 1:29:15show this next and let's take classes
- 1:29:17for the next one
- 1:29:24here are the classes I'm going to paste
- 1:29:26that and also let's take this font
- 1:29:29awesome icon
- 1:29:32this one for the next one let's remove
- 1:29:34this SVG
- 1:29:36and paste the font awesome icon I'm
- 1:29:39going to save that reload the page
- 1:29:42and this is the next icon
- 1:29:45let's specify by the way text as well
- 1:29:48next
- 1:29:51okay perfect so we have imagination
- 1:29:53links and the next button and when we
- 1:29:55click on the next button it actually
- 1:29:57changes into page two now let's
- 1:30:00Implement previews in the same way in
- 1:30:03the exact same way so basically
- 1:30:05I can copy this
- 1:30:07and find where's the previous that
- 1:30:10should be at the top
- 1:30:14right here probably if paginator is on
- 1:30:17the first page then we show disabled
- 1:30:20previous which we don't need so I'm
- 1:30:22going to actually change this if the
- 1:30:24page editor is not on the first page and
- 1:30:26delete that and else statement
- 1:30:29and this is where we're going to display
- 1:30:31the previews so I'm going to paste my
- 1:30:34copied anchor link
- 1:30:36okay let's format the code so we need to
- 1:30:39change the url
- 1:30:41to be previous
- 1:30:43let's remove this
- 1:30:45let's first display the arrow but the
- 1:30:49arrow should not be right it should be
- 1:30:50left
- 1:30:51and then let's write priv right here and
- 1:30:55also right here there is a margin left 2
- 1:30:57which should be changed into margin
- 1:30:58right two
- 1:31:00and right here we also have margin left
- 1:31:02I'm going to replace this in margin
- 1:31:04right so I save that
- 1:31:06reload the page
- 1:31:08and C
- 1:31:10here we go so we have previous next and
- 1:31:13every link if I click previous once
- 1:31:15again we are on the first page and we
- 1:31:17don't see previous anymore this is
- 1:31:19exactly how we want it if I go next
- 1:31:24next
- 1:31:25that works now click on the last one
- 1:31:29and then we don't see next anymore okay
- 1:31:32perfect if I go in the home right now by
- 1:31:36the way how the pagination looks like on
- 1:31:39the
- 1:31:40yeah so this is how it looks like on
- 1:31:43mobile so we don't even need these
- 1:31:44previews and next and we can leave the
- 1:31:47same thing uh for um
- 1:31:51or mobile as well so let me actually
- 1:31:52remove that we don't need open tilewind
- 1:31:56scroll up that should be should not be
- 1:32:00hidden so I'm going to remove that
- 1:32:04it should be Flex always and let's
- 1:32:08remove this above which is only for
- 1:32:10mobile
- 1:32:12save reload the page
- 1:32:14here we see however it makes sense why
- 1:32:19larval has different type of pagination
- 1:32:22on mobile simply because this doesn't
- 1:32:25look good on mobile isn't is it an
- 1:32:27actual Mobile screen let's check this
- 1:32:31let's switch to iPhone
- 1:32:34that's fine but if there are more than
- 1:32:36like seven pages then this will look bad
- 1:32:40let's go in the pagination and change
- 1:32:41this into two
- 1:32:48okay displays these three dots right
- 1:32:52there and there are a lot of positions
- 1:32:54so actually let's go in the talent and
- 1:32:56do this we need this on mobile and we
- 1:32:59can leave that as it is right now and
- 1:33:02let's undo this CSS class as well so on
- 1:33:06pagination it will be like it was before
- 1:33:09that next and previous pythons will be
- 1:33:13there you get the idea you can customize
- 1:33:15those buttons If you don't like
- 1:33:17but that's fine
- 1:33:20okay I'm going to remove because there
- 1:33:23are too many links in my opinion so
- 1:33:24let's go under home and before calling
- 1:33:28links I'm going to call
- 1:33:31uh actually that's good point so I want
- 1:33:33to show you something so
- 1:33:35if I just debug the posts and have a
- 1:33:40look so this is an instance of length
- 1:33:43aware paginator so I'm going to copy
- 1:33:45that class name maybe the fully
- 1:33:48qualified name and I'm going to Define
- 1:33:52right here I'm going to annotate that
- 1:33:54variable so
- 1:33:56like this so variable
- 1:34:00of posts is an instance of this length
- 1:34:04aware paginator okay now if I try to use
- 1:34:08posts and call some methods uh PHP
- 1:34:12stream autocompletes everything what is
- 1:34:14available there okay
- 1:34:16uh I think
- 1:34:21on each side on each side exactly this
- 1:34:23is what I want so I'm going to set on
- 1:34:25each side to be one if I save this now
- 1:34:29and reload the page scroll down below
- 1:34:31now we have a one on each side of the
- 1:34:36active menu item okay and that makes
- 1:34:39more sense
- 1:34:40so
- 1:34:41we we learned how we can actually
- 1:34:44customize these on each side that's
- 1:34:46pretty cool
- 1:34:47now let's go in the post controller and
- 1:34:49I'm going to change this into 10 I'm
- 1:34:51going to display 10 items per page and
- 1:34:53since we have implemented now listing of
- 1:34:55the uh posts we're going to do a couple
- 1:34:57of things so I'm going to clean up the
- 1:34:59layout I don't need these images right
- 1:35:01here Instagram section can be removed we
- 1:35:04need the About Us section I'm going to
- 1:35:06leave that I'm going to also clean up
- 1:35:07the footer basically I'm going to
- 1:35:09prepare everything as it should be
- 1:35:10finally and we're going to also make
- 1:35:12this about text
- 1:35:15like content to be editable from the
- 1:35:17admin side and also the um about us page
- 1:35:22should be also created so let's go let's
- 1:35:25remove this we don't see any items
- 1:35:27that's that's fine now let's go in the
- 1:35:31uh up blade and let's clean up a few
- 1:35:36things if we start from the top
- 1:35:38we have this top bar which can be
- 1:35:42removed
- 1:35:43that's fine we have minimal blog I'm
- 1:35:45going to actually call this the code
- 1:35:47holic blog let's say this this is Laura
- 1:35:51mipsum text which is like a main
- 1:35:54sentence about what you want to tell
- 1:35:57your readers okay so this is something
- 1:35:59which should be configurable from the
- 1:36:01admin side
- 1:36:02let's remove the Instagram section
- 1:36:06here we go so let's
- 1:36:08remove it
- 1:36:10and in the footer there's this Carousel
- 1:36:13so we can remove this Carousel and this
- 1:36:17script tag for the carousel data as well
- 1:36:22okay let's zoom out to have a
- 1:36:26overall look
- 1:36:28okay not too bad
- 1:36:32not too bad
- 1:36:34okay and down below let's remove the
- 1:36:37links from the footer as well
- 1:36:39we don't need that this is myblog.com
- 1:36:43let's leave it and instead of padding
- 1:36:45bottom we're going to have padding y
- 1:36:47vertical
- 1:36:48okay perfect
- 1:36:54nice now let's make those texts editable
- 1:36:57I'm going to actually create
- 1:37:00a new table for that PHP artisan make
- 1:37:04model
- 1:37:08text
- 1:37:10widget and dash M for immigration as
- 1:37:14well create text widget table and let's
- 1:37:18specify a few things right here like we
- 1:37:20need image and title so let's define
- 1:37:23table
- 1:37:26string
- 1:37:28image
- 1:37:30that should be like 2000 48 that can be
- 1:37:35nullable
- 1:37:36let's duplicate this two times we need
- 1:37:39titone
- 1:37:41which can also be nullable so I'm going
- 1:37:43to make everything nullable and I'm
- 1:37:45going to explain why I do this and
- 1:37:47contents well I think we can make title
- 1:37:50required that's okay
- 1:37:53and the content needs to be long text
- 1:37:58and it must definitely be knowledgeable
- 1:38:00and let's specify also active which
- 1:38:03needs to be Boolean
- 1:38:07like this and that by default will be
- 1:38:11false so now we have this table ready
- 1:38:13I'm going to add one additional column
- 1:38:14it's going to be key
- 1:38:16tring
- 1:38:18e
- 1:38:19and that must be required and that must
- 1:38:23be unique as well
- 1:38:25so basically the idea is that that's
- 1:38:27going to be a universal table for saving
- 1:38:30some text contents for your website like
- 1:38:34we're going to create
- 1:38:35About Us section for example the key
- 1:38:37will be about us and you can specify
- 1:38:40image or title and content and then
- 1:38:42based on that this is extra based on
- 1:38:45that we can select the data from the
- 1:38:48database and output in certain places in
- 1:38:52our website so that's that's good we
- 1:38:56have this text widget ready
- 1:38:59let's we don't have actually ready we
- 1:39:01just create migration PHP Artisan
- 1:39:04migrate
- 1:39:07and that was applied now let's open text
- 1:39:10widget
- 1:39:11and I'm going to Define right here few
- 1:39:14helper methods
- 1:39:17first let's define a fillable
- 1:39:20properties like e let's let me copy
- 1:39:25everything
- 1:39:27all of them are fillable
- 1:39:36like this
- 1:39:39okay next let's define a public static
- 1:39:43function git title and this will accept
- 1:39:47string e
- 1:39:49and this should return the it should
- 1:39:52select text widget based on the key and
- 1:39:56then just a return the value of the
- 1:39:58title so we are going to query widget
- 1:40:01which will be text
- 1:40:06widget query
- 1:40:08where
- 1:40:11key
- 1:40:13equals
- 1:40:15given key and we have to also specify
- 1:40:18active status
- 1:40:20where
- 1:40:21active
- 1:40:23corresponds to
- 1:40:271.
- 1:40:29or true
- 1:40:30and we're going to call First on this so
- 1:40:33we're just going to grab the text widget
- 1:40:35and let's check now if the widget was
- 1:40:39selected
- 1:40:43then I'm going to return
- 1:40:45a widget
- 1:40:47title
- 1:40:49otherwise I'm going to return an empty
- 1:40:51string
- 1:40:54like this
- 1:40:56so let's try now to create
- 1:41:01uh no let me first actually duplicate
- 1:41:03this let's prepare everything right here
- 1:41:04so I'm going to duplicate this and
- 1:41:06create second function get content
- 1:41:09which is doing something similar
- 1:41:13but we actually also need probably two
- 1:41:18add caching I'm going to do also caching
- 1:41:21but first let's select text widget based
- 1:41:24on the key and active and then if the
- 1:41:28widget is found we are going to return
- 1:41:30content
- 1:41:32otherwise we're going to return an empty
- 1:41:34string
- 1:41:36okay and we might call
- 1:41:40like we might select one widget and we
- 1:41:43want both title
- 1:41:45and content from the widget so if we do
- 1:41:49like these then this method will be
- 1:41:52executed and this method will be
- 1:41:54executed also and this will cause
- 1:41:57selecting text widgets the same text we
- 1:42:00just twice why don't we cache our
- 1:42:03selected text widget
- 1:42:05so if we need to select it second time
- 1:42:07it's going to serve from the cache okay
- 1:42:11that's I think really good optimization
- 1:42:14point so let's use now cache
- 1:42:19uh which cache is that
- 1:42:23illuminate support for size cache then
- 1:42:26we are gonna call get we need to specify
- 1:42:29some kind of key like text to widget for
- 1:42:32example Dash in the text widget key so
- 1:42:36that's going to be based on that key it
- 1:42:38will either get it from the cache or
- 1:42:40select then we have function let's use
- 1:42:45uh key right here
- 1:42:48and we are going to return these parts
- 1:42:55okay and finally we're going to assign
- 1:42:58this into widget
- 1:43:02so what this will do is try to get
- 1:43:05the content from the cache using that
- 1:43:09key if the content didn't exist then it
- 1:43:12will execute that function that function
- 1:43:14will just uh run the following code it
- 1:43:17will return the value and the cache
- 1:43:20component cache facade then we'll set
- 1:43:22that into into cash as well I think it
- 1:43:26should have get
- 1:43:28get or said or something like this
- 1:43:32so we're going to test this as I
- 1:43:34remember it will simply return that but
- 1:43:37we can test this so if we're going to
- 1:43:39get
- 1:43:40also
- 1:43:42we don't see that
- 1:43:46okay I'm sure we can figure this out a
- 1:43:48little bit later but I just want to
- 1:43:51mention that when you're developing
- 1:43:53something if you think
- 1:43:55putting a little bit extra effort
- 1:43:59beforehand and then you can finally have
- 1:44:02a much better product for example you
- 1:44:04don't select your the same objects twice
- 1:44:07in the code we can figure this out
- 1:44:09working also debug this but a little bit
- 1:44:12later
- 1:44:14okay so we can do the same thing right
- 1:44:16here so I'm going to just simply get
- 1:44:18this
- 1:44:22and remove that
- 1:44:26excuse me
- 1:44:29delete that
- 1:44:34return this
- 1:44:36and we're gonna assign this into widget
- 1:44:43okay perfect
- 1:44:46now let's generate filament resource for
- 1:44:49the tech switches PHP art design make
- 1:44:53element Dash resource let's specify text
- 1:44:58or widget a resource
- 1:45:01generate
- 1:45:09let's see the enter text widget resource
- 1:45:11was generated now let's check the admin
- 1:45:14panel we have text switches
- 1:45:16and that's perfect
- 1:45:18that's super cool uh let's modify text
- 1:45:22widget resource text
- 1:45:26text
- 1:45:28widget resource
- 1:45:31let's change the
- 1:45:35group navigation group to be content
- 1:45:40we have key which must be required we
- 1:45:44have image which must be file upload
- 1:45:48uh we have title which must be required
- 1:45:51we have content and active
- 1:45:55in the table we can have just
- 1:45:58key
- 1:45:59pain title we don't need
- 1:46:02in status maybe an updated okay we just
- 1:46:06need more than expected so and let's
- 1:46:09actually change this to show inside the
- 1:46:12form everything in a single column like
- 1:46:14columns one
- 1:46:16like this now let's specify about us
- 1:46:19sidebar for example as a key and then
- 1:46:23let's choose some sort of image do we
- 1:46:25need image on the about a sidebar no we
- 1:46:28don't need that let's specify title
- 1:46:30about us for example and content which
- 1:46:34is this well it's a lorem ipsum but you
- 1:46:37can type about me so I am
- 1:46:42um
- 1:46:42developer with 11
- 1:46:46plus years of experience that's it
- 1:46:51okay let's make it active and I'm gonna
- 1:46:53create that
- 1:46:55and when this is created I want it to be
- 1:46:57redirected to the listing page so I will
- 1:47:01go
- 1:47:02into text widget resource create text
- 1:47:05widget and just override the
- 1:47:09function
- 1:47:10which I think I did in the posts
- 1:47:15uh no I haven't done this in the posts
- 1:47:18uh get redirect URL where do they do it
- 1:47:22I think I haven't done this okay let's
- 1:47:24check these filaments
- 1:47:27uh redirect customizing form redirects
- 1:47:31here we have this gate redirect URL I'm
- 1:47:34going to copy that
- 1:47:35and paste in the text widget resource
- 1:47:39now
- 1:47:40we need create text resource paste this
- 1:47:43right here
- 1:47:45save that
- 1:47:47call in the filament I think we need to
- 1:47:49do the same thing in update
- 1:47:5280 text resource
- 1:47:58so now if I edit these
- 1:48:03and click save I'm redirected to the
- 1:48:06list which is exactly what I want to do
- 1:48:12I actually don't need the view page
- 1:48:14probably
- 1:48:16don't need view page so if I go in the
- 1:48:19list text widgets
- 1:48:24or maybe view text we just completely
- 1:48:26delete that
- 1:48:27and go in the text which is resource and
- 1:48:31remove this View
- 1:48:34what will happen
- 1:48:35text widgets is included somewhere
- 1:48:42let's remove it
- 1:48:50okay now it opens edit page which is
- 1:48:53exactly what I want
- 1:48:55okay now let's go in the website and we
- 1:48:57need to Output this about us text widget
- 1:48:59right here so let's open sidebar
- 1:49:04uh Side Bar
- 1:49:06we don't have sidebars so let's create
- 1:49:09this let's go in the home blade
- 1:49:12and we render our section right here
- 1:49:17okay where's the sidebar that is
- 1:49:20probably in the up blade
- 1:49:24here we go so this is a side
- 1:49:27which in my opinion
- 1:49:30should be
- 1:49:32that in my opinion should be inside the
- 1:49:36view so I'm going to take this out
- 1:49:40and go in the home
- 1:49:44we have this section which comes right
- 1:49:46here
- 1:49:47and then
- 1:49:48below that section I will put the
- 1:49:51sidebar
- 1:49:53so the result
- 1:49:55is identical
- 1:49:58and now I'm going to make this as a
- 1:50:00separate component
- 1:50:03PHP artisan make
- 1:50:06component
- 1:50:08sidebar
- 1:50:11okay well let's see the inter sidebar
- 1:50:14component was created
- 1:50:17cyber blade and now
- 1:50:20let's get the aside
- 1:50:23and
- 1:50:26paste it here
- 1:50:29and now let's output
- 1:50:34text widget
- 1:50:37get title and specify about us
- 1:50:41sidebar which is the key
- 1:50:44okay so then I'm going to copy this
- 1:50:48and right here I'm gonna
- 1:50:50output it
- 1:50:53as an HTML
- 1:50:59but I'm going to specify instead of gate
- 1:51:01title I'm going to specify get
- 1:51:03content let's change this into
- 1:51:08let's leave this by the way we will have
- 1:51:10to change this whenever the URL is
- 1:51:12created but let's leave it as it is for
- 1:51:14now
- 1:51:15and let's have a look
- 1:51:17if we go in the home blade we need to
- 1:51:20use x
- 1:51:21sidebar component
- 1:51:24and here we go so we have this about us
- 1:51:27which comes from the back end okay now
- 1:51:29we have a possibility to fully customize
- 1:51:31that text specify whatever you want as
- 1:51:36well as change the title
- 1:51:39uh save that reload here we go that view
- 1:51:44button by the way needs to be removed
- 1:51:47so if we simply go in the edit text and
- 1:51:49view remove reload that's perfect
- 1:51:54okay
- 1:51:57now in the same way let's create a new
- 1:52:01text widget for the following text
- 1:52:05new widget
- 1:52:06header let's call it just header header
- 1:52:12and the content will be something you
- 1:52:14know I'm going to just copy and paste
- 1:52:16this
- 1:52:17I don't want to
- 1:52:19spend time on come up
- 1:52:21something so that's active let's click
- 1:52:24create
- 1:52:25reload the page of course we haven't
- 1:52:27used that
- 1:52:28up blade
- 1:52:31and at the very top we have this lorem
- 1:52:34ipsum something so we will output text
- 1:52:37widget get
- 1:52:40get content
- 1:52:42that's going to be Laura mips or
- 1:52:43something actually
- 1:52:46this one
- 1:52:49will have a paragraph inside
- 1:52:53so what we can do is just output the
- 1:52:56header this is this is a title and we
- 1:52:58can output the title in this case the
- 1:53:00title should be this one
- 1:53:04let me change this leave the content so
- 1:53:07the content basically is more for HTML
- 1:53:09content and by the way I haven't changed
- 1:53:12this into Rich Text which I should have
- 1:53:14done
- 1:53:16let's change this into
- 1:53:20here it is reach reach text reach editor
- 1:53:24so this content is more for reach editor
- 1:53:27and I'm going to specify this loading
- 1:53:29with some here and if I go in the layout
- 1:53:32now I want to Output the title for
- 1:53:37header
- 1:53:38save reload we see the same thing if I
- 1:53:43modify this
- 1:53:45we see now modify text so that shows
- 1:53:48and this shows that it actually works
- 1:53:51perfectly so these text widgets are
- 1:53:54basically really handy in certain cases
- 1:53:57so you have key and you can select uh
- 1:53:59the text which is managed from the admin
- 1:54:03panel in any place you want in the same
- 1:54:06fashion we're going to create a little
- 1:54:08bit later about page where we will
- 1:54:11create a new text widget for the about
- 1:54:13and we'll output that so I think that's
- 1:54:16perfect now let's start working on the
- 1:54:19post in your page let's open
- 1:54:24web.php and create new roots
- 1:54:27that will be simply
- 1:54:30post right here but we have to specify
- 1:54:33that I want to select the post by Slack
- 1:54:37and we're going to have
- 1:54:39show
- 1:54:43and it's going to be View
- 1:54:46what's going to show we already accept
- 1:54:49posts right here but that post might not
- 1:54:52be active
- 1:54:54so we have to make an additional checks
- 1:54:58like if post is not active
- 1:55:03or
- 1:55:06if post
- 1:55:09published it is in the future
- 1:55:14to specify carbon now
- 1:55:16if that happens then let's just throw
- 1:55:20new not found
- 1:55:23HTTP exception
- 1:55:26this one
- 1:55:28okay otherwise we're going to proceed
- 1:55:31and return View
- 1:55:37show
- 1:55:38and we have compact
- 1:55:41here and we need to select actually post
- 1:55:45no we don't need we have post so I'll
- 1:55:47just specify post here
- 1:55:49okay perfect
- 1:55:51let's also have a look at the
- 1:55:55blog template we are using and we have
- 1:55:58to just copy the blog in your page Post
- 1:56:02in your page content
- 1:56:03before that let's create this
- 1:56:07blade file and the resources we use
- 1:56:11let's actually create
- 1:56:14well that should be
- 1:56:17post dot show
- 1:56:21or maybe post start View
- 1:56:24so under views let's create new file
- 1:56:28post slash View
- 1:56:32Dot blade.php
- 1:56:37perfect we need to use x app layout
- 1:56:42and now let's open our blog template
- 1:56:47here it is Click get template
- 1:56:50click on post HTML and click on enroll
- 1:56:54so this is the HTML we need I'm going to
- 1:56:57copy everything but we don't need to
- 1:57:00have a layout so I'm going to paste it
- 1:57:01and then clean up so we don't need this
- 1:57:04HTML and talk type because we already
- 1:57:06have layout defined but we don't need
- 1:57:09the stop nav bar
- 1:57:11we don't need this one
- 1:57:13and the only thing what we need is this
- 1:57:16post section so everything above
- 1:57:19can be deleted
- 1:57:21and everything below
- 1:57:24can be deleted as well
- 1:57:27like this so let's format the code I'm
- 1:57:31going to save these
- 1:57:33and reload the page and we actually have
- 1:57:35to make proper links so I'm going to
- 1:57:39open post item blade and let's specify
- 1:57:43now proper links so here we need
- 1:57:47Road
- 1:57:48View
- 1:57:50and we have to specify an actual post
- 1:57:53let's copy this when we click on the
- 1:57:56image
- 1:57:58this is just for the categories when we
- 1:58:01click on the title we want to open the
- 1:58:03view page
- 1:58:04and when we click on the body we want it
- 1:58:07to open a view page as well so I save
- 1:58:10that reload the page and let's click on
- 1:58:13the image
- 1:58:14you see so it opens the view page and
- 1:58:17this is a slug we have an image this is
- 1:58:21what's the
- 1:58:23images done yeah everything is dummy
- 1:58:25yeah I bet so everything is done right
- 1:58:28here we have to make it uh active coming
- 1:58:31from the database and we have to also
- 1:58:33implement this previous in the next
- 1:58:35buttons that's also very interesting and
- 1:58:37I'm going to remove this user card at
- 1:58:40the moment I don't need that
- 1:58:42let's go in the view blade
- 1:58:45let's expand this
- 1:58:48and let's now output the image let me
- 1:58:52actually get this from here
- 1:58:54so this is an image
- 1:58:56paste
- 1:58:58I will need
- 1:59:00I will need categories as well so I'm
- 1:59:02going to copy that
- 1:59:04and paste here
- 1:59:06I will need titles
- 1:59:10yeah
- 1:59:11title as well
- 1:59:14um we need to drink a water
- 1:59:19like I'm talking uh one hour Non-Stop
- 1:59:22and my my voice changes actually
- 1:59:26so we have this categories let's format
- 1:59:28these
- 1:59:30and this is the actual post title so I'm
- 1:59:33gonna get that
- 1:59:36well
- 1:59:37we need just post title we don't need
- 1:59:39this to be an anchor link because that's
- 1:59:42that's not necessary we are in the post
- 1:59:45in your page so I'm going to change this
- 1:59:47into H1 remove this href and have both
- 1:59:50Title Here
- 1:59:52and then we have the user information
- 1:59:54and the publish date let's copy this get
- 1:59:59formatted date as well
- 2:00:02right here and let's get this username
- 2:00:13okay so everything below is already part
- 2:00:17of the body so I'm gonna delete that
- 2:00:21I'm going to delete that and I'm going
- 2:00:24to Output post buddy so let's wrap this
- 2:00:28in a div
- 2:00:29then we need post
- 2:00:32body so we save that and have a look
- 2:00:36so we have an actual image
- 2:00:38title tag
- 2:00:41and this is an HTML so we have to Output
- 2:00:45it differently
- 2:00:50like this
- 2:00:53perfect
- 2:00:55that's pretty cool let's remove the user
- 2:00:58card
- 2:00:59this is the user card let's remove it
- 2:01:03and we have to implement next and
- 2:01:05previous buttons so we have to do this
- 2:01:07from the post controller we already have
- 2:01:10that
- 2:01:11post
- 2:01:13selected by larval itself so now let's
- 2:01:16select next item which will be post
- 2:01:20query
- 2:01:22we have to specify that we want only
- 2:01:25active
- 2:01:29by the way if I just specify here
- 2:01:33um
- 2:01:34true
- 2:01:37will it work
- 2:01:40we're gonna see
- 2:01:41uh we are date
- 2:01:45published it
- 2:01:48is less than or equal
- 2:01:52to carbon
- 2:01:55carbon now
- 2:01:59let's specify also
- 2:02:04okay let me think so we have the post
- 2:02:09if we have a look so this is let's say
- 2:02:11this is the very first post and posts
- 2:02:14are generally sorted by published
- 2:02:16descending
- 2:02:17so I want the next basically should
- 2:02:20query
- 2:02:22um host which is the first post
- 2:02:25among those which has published date
- 2:02:31less than the current post so we have to
- 2:02:34also specify where
- 2:02:38weird date like published it
- 2:02:43is less than
- 2:02:46less than
- 2:02:48the current post
- 2:02:54published it I think this is it and
- 2:02:58let's order by
- 2:03:01published it
- 2:03:04underscore
- 2:03:06descending and let's limit this into one
- 2:03:10because I only want to get one
- 2:03:13and then I'm going to call First on this
- 2:03:16so we have next
- 2:03:19uh let's double check this so I want to
- 2:03:21query active post which has date Which
- 2:03:25is less than or equal to now which means
- 2:03:27that it must be published
- 2:03:28and it's published date
- 2:03:30is less than
- 2:03:33the published date of the current post
- 2:03:36I think that's logical and we order this
- 2:03:38by the descending date which makes sure
- 2:03:41that this is the very first among those
- 2:03:43posts which has published at less than
- 2:03:46the post date okay I'm going to
- 2:03:49duplicate this and create call these
- 2:03:52previews
- 2:03:54in this case we need to change this less
- 2:03:58than into greater than
- 2:04:00and I think everything else stays the
- 2:04:02same we have to provide here
- 2:04:05we've and next variables now if I go in
- 2:04:11The View
- 2:04:12we have those two anchor tags
- 2:04:15this is previous
- 2:04:19and let's
- 2:04:21let's specify right here title for
- 2:04:24previous
- 2:04:30title like this
- 2:04:32and when to also handle the case when
- 2:04:35the previous doesn't exist we're going
- 2:04:37to do that but first I want to see an
- 2:04:39error for that so here we need next
- 2:04:43title
- 2:04:45perfect
- 2:04:47and if I
- 2:04:49if I want those links to work as well I
- 2:04:52have to provide right here Road
- 2:04:55that's going to be View and I'm going to
- 2:04:57specify previews
- 2:05:00and right here
- 2:05:02wrote
- 2:05:03View
- 2:05:05next
- 2:05:07we save that reload the page and we have
- 2:05:10an error the error is exactly I believe
- 2:05:13right here that the previous doesn't
- 2:05:15exist
- 2:05:16missing required parameter for roads
- 2:05:19yeah previous doesn't exist so I'm going
- 2:05:21to add an extra if statement here if
- 2:05:25previews exists
- 2:05:28then we just render it
- 2:05:32like this however this gives us the next
- 2:05:36is not on the right side it is on the
- 2:05:38left side so what I'm gonna do is create
- 2:05:42two div elements
- 2:05:45class width one over two
- 2:05:48and duplicate these
- 2:05:51this one should be here
- 2:05:59and the other one should be
- 2:06:03here
- 2:06:05oops
- 2:06:07hold on
- 2:06:12like this so I'm sure that there will
- 2:06:15always be two div elements rendered and
- 2:06:18then inside there there should be
- 2:06:21anchor links with display block and with
- 2:06:25the full
- 2:06:26I save and reload and I see next on the
- 2:06:29right side if I click on the next it
- 2:06:32opens the next post and now I should see
- 2:06:35both previews and next well this doesn't
- 2:06:38look really nice so probably we need to
- 2:06:42use
- 2:06:43here is to your helper
- 2:06:46and just restrict this into number of
- 2:06:48words like 10 maybe
- 2:06:52that's too much maybe like five five
- 2:06:55words
- 2:06:57okay not too bad we can even increase
- 2:06:59this into six six parts
- 2:07:02um no it should be five
- 2:07:05okay not bad so I'm going to click next
- 2:07:08right here and that opens the next one
- 2:07:10next and now let's go into previous okay
- 2:07:14something
- 2:07:16but it happened
- 2:07:18so when I click next two times and then
- 2:07:22I click reviews it opens the very first
- 2:07:25one
- 2:07:26which is not very accurate
- 2:07:30if I double check the logic again
- 2:07:37I think this should be
- 2:07:39achievous ending
- 2:07:48that should be ascending if I reload
- 2:07:50click next once twice and now I click
- 2:07:54previews it opens the previews and
- 2:07:57another one is Javascript is weird
- 2:08:00okay so we have actually implemented
- 2:08:04the inner page for the Post
- 2:08:07and we have implemented next in previous
- 2:08:09buttons and I think we can move on the
- 2:08:12next section now let's Implement
- 2:08:14outputting categories in the sidebar
- 2:08:18and in the main navigation as well so in
- 2:08:21the main navigation I'm going to Output
- 2:08:23top five categories by its number of
- 2:08:30posts inside that category okay and in
- 2:08:35the sidebar we're going to Simply show
- 2:08:36all the categories what is available
- 2:08:38right there but first let's make sure we
- 2:08:41have the sidebar on the post in your
- 2:08:43page so if I go in The View
- 2:08:46and then we have the section
- 2:08:48let's
- 2:08:50let's create the very bottom and we are
- 2:08:53going to display X
- 2:08:55sidebar component right here so if I
- 2:08:58save this reload we have this about us
- 2:09:00so I'm going to display inside the
- 2:09:03sidebar
- 2:09:05all the categories
- 2:09:09okay so here we have that
- 2:09:11let's define right here
- 2:09:14I'm going to create this same type of
- 2:09:16div
- 2:09:18and then inside there I'm going to
- 2:09:21create a
- 2:09:23H3 and let's specify text Excel and we
- 2:09:28need font semi bold
- 2:09:33and we need margin button three so let's
- 2:09:35do like this
- 2:09:37and that will be all categories
- 2:09:41then I'm going to iterate categories but
- 2:09:44I don't have any categories available in
- 2:09:47this this component sidebar component so
- 2:09:50let's open sidebar component
- 2:09:54and first we have to select those
- 2:09:58categories okay so I'm going to create
- 2:10:02sidebar um sorry
- 2:10:04categories equals and I'm going to copy
- 2:10:08and paste the query and explain then
- 2:10:12okay so let's import this category
- 2:10:16so we are curing from a category We join
- 2:10:19this into category post
- 2:10:22and we're we're using the proper column
- 2:10:25names categories ID cost category post
- 2:10:27category ID then we select categories
- 2:10:30title categories slag and we also query
- 2:10:34count
- 2:10:36um
- 2:10:37count of everything as a total and we
- 2:10:40grew by that by categories and order by
- 2:10:44those total so this will query top five
- 2:10:49categories sorted by number of hosts
- 2:10:53inside that category
- 2:10:55that's pretty cool right
- 2:10:57so now we use compact in pass categories
- 2:11:01here and if I go in this sidebar I have
- 2:11:04categories available so I can already
- 2:11:07iterate for each categories is category
- 2:11:13and then we just need to display
- 2:11:16anchor tag probably href and this is
- 2:11:20something we need to create that wrote
- 2:11:23posts by category
- 2:11:25but then inside there we need category
- 2:11:29title
- 2:11:31and let's also specify some tolerances
- 2:11:34classes like text is semi-bold
- 2:11:40we need it to be block adding Y2 pining
- 2:11:44Geeks three maybe and a little bit
- 2:11:48rounded
- 2:11:49okay let's make it like this and if I
- 2:11:52reload the page we see all categories
- 2:11:56right here
- 2:11:58okay I think this looks this looks good
- 2:12:02if I go in the categories
- 2:12:04we have JavaScript PHP and laravel so
- 2:12:07that that doesn't show the category
- 2:12:10which does not have any items inside
- 2:12:13there
- 2:12:14and actually I want to also display
- 2:12:16right here
- 2:12:18category
- 2:12:20total because that total is also
- 2:12:23available because that is selected
- 2:12:26inside there so I save that reload now
- 2:12:29we see how many items are in each
- 2:12:31category and if I change this join into
- 2:12:35left join
- 2:12:37then we're gonna also have a look in the
- 2:12:42yeah let's range one of the categories
- 2:12:44we are missing
- 2:12:46but the
- 2:12:49why was that missing
- 2:12:52with the join
- 2:12:55so that should be left joined for sure
- 2:13:02okay we have now three categories and
- 2:13:04I'm going to open the post generated
- 2:13:07active posts by the database Cedar and
- 2:13:11I'm gonna assign couple of them some
- 2:13:14actual categories
- 2:13:16for example let's move this into
- 2:13:19JavaScript
- 2:13:23let's open another one
- 2:13:25move this into
- 2:13:28JavaScript
- 2:13:32now if I reload the page I see there are
- 2:13:34three articles in JavaScript category
- 2:13:37okay and just like this we'll have all
- 2:13:39categories on the right side and when we
- 2:13:41Implement a post Page by category and
- 2:13:44when we click on this it's going to open
- 2:13:46that page now let's take care of the
- 2:13:48header as well in very very similar way
- 2:13:50so I'm going to open up layout
- 2:13:54app layout and right here we will need
- 2:13:57to query
- 2:13:59categories and by the way
- 2:14:02this limit 5 is not necessary that query
- 2:14:06is uh for app layout so I'm going to
- 2:14:09remove this limit five
- 2:14:12go in the Apple layout
- 2:14:15and I'm going to just paste this
- 2:14:19categories equals that
- 2:14:22and then we provide
- 2:14:26compact categories here
- 2:14:29okay we need top five categories here
- 2:14:32not inside sidebar
- 2:14:37okay if we open up blade
- 2:14:42this is the menu
- 2:14:45so we have to iterate over categories is
- 2:14:52category
- 2:14:55let's move this up
- 2:14:57and we are gonna output
- 2:15:00a category
- 2:15:02title
- 2:15:05perfect let's add two more pages right
- 2:15:09here
- 2:15:10one will be home
- 2:15:16right here we're going to have home and
- 2:15:18let's adjust the URL to be wrote or home
- 2:15:23and second will be about us
- 2:15:28and that's gonna also have a road uh but
- 2:15:31let's leave it at the moment because the
- 2:15:33road doesn't exist yet so I save this
- 2:15:35reload the page
- 2:15:36and if any variable categories Double C
- 2:15:40is not necessary here we go so we have a
- 2:15:43home page we have JavaScript PHP lateral
- 2:15:45all the categories what we have uh let
- 2:15:48me actually quickly change the hover
- 2:15:50color
- 2:15:53PG array 400 let's change this into PG
- 2:15:57like a blue
- 2:15:59600 and maybe
- 2:16:02over text white as well
- 2:16:07okay much better
- 2:16:11so we have now main navigation ready
- 2:16:14when we click on the home that actually
- 2:16:16works we have to implement now buy
- 2:16:18category page and Implement also
- 2:16:21clicking on that on the right side and
- 2:16:23activate the uh activate all categories
- 2:16:27actual category which is clicked that's
- 2:16:30pretty interesting now let's go in the
- 2:16:32post controller and
- 2:16:35we have many actions we don't need them
- 2:16:37I'm going to delete them
- 2:16:40all of them actually and let's create
- 2:16:43public function by category
- 2:16:46here
- 2:16:47it will accept category
- 2:16:52and then we need to query
- 2:16:54posts based on that category let's open
- 2:16:58web.php as well and duplicate this
- 2:17:02and I'm going to specify category slash
- 2:17:07category by slug so we're going to
- 2:17:10keyword it by category and the view name
- 2:17:14will be by category as well
- 2:17:19now let's open this by category and I'm
- 2:17:22going to again copy and paste the query
- 2:17:24and I'm going to explain what this query
- 2:17:26is actually doing so we query posts but
- 2:17:30we enjoy the post into a junction table
- 2:17:33category post we are the posts ID equals
- 2:17:36to the category post post ID then we
- 2:17:40write it where we are category post
- 2:17:42category ID is the given category ID we
- 2:17:46also make sure that the post needs to be
- 2:17:48active and the published date needs to
- 2:17:51be in the past and we order everything
- 2:17:54by publish date one small change we're
- 2:17:58gonna what I'm going to make in the up
- 2:18:01layout is that when I join this into
- 2:18:06like category posts and I order by
- 2:18:12order by total I don't consider that the
- 2:18:15post needs to be active and it needs to
- 2:18:18be published so this query
- 2:18:21will also get the posts
- 2:18:24which are not active or not published
- 2:18:26the same thing will happen in the
- 2:18:28sidebar
- 2:18:30okay so just to make sure that I'm
- 2:18:33correct I will go in the posts open the
- 2:18:36one which is not active and the sign by
- 2:18:40the way when I click on the post I want
- 2:18:42it to start editing so I'm going to go
- 2:18:45in the
- 2:18:46post resource
- 2:18:49and maybe
- 2:18:52in the post resource and I'm going to
- 2:18:54remove this view I don't need that
- 2:18:58list posts
- 2:19:01edit posts view action remove that
- 2:19:09hand view action remove let's have a
- 2:19:12look
- 2:19:13uh view post is used somewhere
- 2:19:17get pages
- 2:19:19okay
- 2:19:20now click on this it opens edit which is
- 2:19:23exactly what I want so now let's assign
- 2:19:26PHP for example save that it is not
- 2:19:30active pay attention and if I go and
- 2:19:34just reload the page
- 2:19:37the count does not increase
- 2:19:40uh-huh
- 2:19:42but it should be increased
- 2:19:44why
- 2:19:49for JavaScript it is actually increased
- 2:19:52but not for PHP okay what other
- 2:19:57are there any other posts
- 2:19:59that has a PHP there
- 2:20:02I think there are no posts
- 2:20:05that has PHP there so let's try to
- 2:20:10get the one another one
- 2:20:13so I need to PHP category reload the
- 2:20:15page now there are two
- 2:20:17uh two items and pay attention that this
- 2:20:20is not active so it should not be two it
- 2:20:22should be one
- 2:20:25so let me show you remove this PHP
- 2:20:26because I
- 2:20:28it seemed to me like there were no posts
- 2:20:32in the PHP category but it still was
- 2:20:36showing one
- 2:20:38exactly so this still is showing one
- 2:20:42however
- 2:20:48this obviously shows one because
- 2:20:52it it should show one that's actually
- 2:20:55correct
- 2:20:57if we go in the sidebar we select total
- 2:21:02count of total everything and that
- 2:21:05everything includes the category itself
- 2:21:08okay so this is something which is kind
- 2:21:11of buggy and we should probably adjust
- 2:21:15okay I'm going to get back to this
- 2:21:17um it is this is not accurate hundred
- 2:21:19percent but as I mentioned
- 2:21:22um I'm going to get back to this okay
- 2:21:24so for now let's
- 2:21:27let's actually implement
- 2:21:30when we click on the category it should
- 2:21:32open the post by category so if I go in
- 2:21:35the sidebar and change these and specify
- 2:21:38Road
- 2:21:39to be by category and we have to specify
- 2:21:43category right here
- 2:21:45below the page and I click on JavaScript
- 2:21:49and let's see what happened
- 2:21:53okay we see an empty page
- 2:21:56we go in the
- 2:21:58post controller
- 2:22:00we don't return anything
- 2:22:02so we are going to return
- 2:22:05View
- 2:22:07what will you should we return should we
- 2:22:10return the same view like home and maybe
- 2:22:13provide
- 2:22:15posts like this
- 2:22:21okay so we only see one two three
- 2:22:24one two three we only see three items
- 2:22:28and again count is not 100 accurate
- 2:22:31we're gonna fix that but I think
- 2:22:33filtering by category successfully works
- 2:22:36so if I click on PHP we have to link
- 2:22:38this in the header if I click on PHP
- 2:22:41there are no posts or click on laravel
- 2:22:44there's actually one post
- 2:22:47uh that's that's good
- 2:22:51that's good however I don't want posts
- 2:22:55to be displayed in header if there are
- 2:22:57no items there so if I go in the app
- 2:23:02layout
- 2:23:04change this left join into just join
- 2:23:09PHP should disappear
- 2:23:16I select category join on category post
- 2:23:20there should not be any record right
- 2:23:23there it's range
- 2:23:27well I will try now to print an actual
- 2:23:30query because I have a feeling something
- 2:23:33is not exactly as I want so here we have
- 2:23:37the query
- 2:23:40and let's dump and die
- 2:23:44Yuri
- 2:23:47uh well I need query uh 2sql
- 2:23:52here we go
- 2:23:54select from categories
- 2:24:02uh okay let me carry everything
- 2:24:11I'm going to open now PHP storms
- 2:24:15console
- 2:24:17paste that
- 2:24:20limit five
- 2:24:22so we select from categories and we join
- 2:24:25onto category post
- 2:24:29finally we have group buy and order by
- 2:24:31so if I execute that
- 2:24:34we see PHP okay what is the ID
- 2:24:38or PHP so I need to query categories ID
- 2:24:42as well
- 2:24:44that is five now let's open category
- 2:24:47post and see if there are any posts for
- 2:24:51category five actually there is post
- 2:24:54four
- 2:24:55four category five which is actually
- 2:24:57correct so it looks like the count works
- 2:25:02fine
- 2:25:04if I edit there's laravel if I edit
- 2:25:06there's JavaScript
- 2:25:08and it looks like here it is so we have
- 2:25:12PHP if I remove that and Save
- 2:25:16and now let's open code
- 2:25:22layout
- 2:25:24remove the stamp and die
- 2:25:27and now now what happens
- 2:25:32I removed PHP
- 2:25:35was it actually removed
- 2:25:38maybe even
- 2:25:39no maybe not
- 2:25:42think it is not deleted that's the main
- 2:25:45problem
- 2:25:47stays there
- 2:25:49again if I reload the page PHP is there
- 2:25:52I'm going to remove that
- 2:25:54and save changes
- 2:26:00huh this is required and that's why I
- 2:26:04thought the changes were saved but it
- 2:26:05wasn't saved I'm going to assign it into
- 2:26:08JavaScript
- 2:26:11and save that was now saved reload the
- 2:26:15page
- 2:26:16let's actually
- 2:26:20remove this reload and now PHP
- 2:26:23disappeared from here
- 2:26:25however it is still available right here
- 2:26:28which is something we have to fix
- 2:26:33we have to fix maybe we even completely
- 2:26:36remove the categories if there are no
- 2:26:41articles right there it doesn't make any
- 2:26:42sense to have categories if there are no
- 2:26:44articles right there so I'm gonna go in
- 2:26:46the sidebar and change this into join as
- 2:26:51well we display all categories but if
- 2:26:53there are no posts in the category we
- 2:26:55don't display it perfect I liked it now
- 2:26:59let's go in the app layout
- 2:27:05and let's adjust the categories
- 2:27:10right here so that should be wrote
- 2:27:16by Dash category
- 2:27:20specify category like this
- 2:27:24Okay click on these Works click on this
- 2:27:26works
- 2:27:27so far so good let's Implement
- 2:27:30activating the
- 2:27:32page which is clicked at the moment the
- 2:27:34category on the sidebar which on which
- 2:27:36you have clicked so if we go in the
- 2:27:39sidebar
- 2:27:41here we go so let's move this class down
- 2:27:45and I'm going to get call now request
- 2:27:50and I'm going to get the category and if
- 2:27:53the category slog
- 2:27:57equals that request category will be an
- 2:27:59instance of the category model so if
- 2:28:02that's log equals is the same as
- 2:28:05category slag
- 2:28:07then we're going to mark this item is
- 2:28:11like highlighted so let's give it BG
- 2:28:14blue uh 600 and text White
- 2:28:22otherwise let's give it an empty class
- 2:28:26let's move this down
- 2:28:28like this reload the page and now
- 2:28:30laravel is active I click on the second
- 2:28:32one and JavaScript is active
- 2:28:35okay
- 2:28:36perfect so we made that active and in
- 2:28:39the same way we can also activate the
- 2:28:43home in JavaScript about us I will leave
- 2:28:46this challenge to you now let's
- 2:28:48Implement a botas page I'm going to open
- 2:28:51web.php
- 2:28:53and create a new road that should be
- 2:28:56above this post slide because that's a
- 2:28:59very generic route and that will handle
- 2:29:02everything if there are no more specific
- 2:29:05roads above that so that should be about
- 2:29:08Dash as page let's remove it it's going
- 2:29:12to be pretty straightforward
- 2:29:14well we can use the same post controller
- 2:29:17or create new controller I don't know
- 2:29:19which one will be better maybe creating
- 2:29:22a new controller PHP artisan make
- 2:29:26controller site controller
- 2:29:30enter I'm going to use right here side
- 2:29:33controller
- 2:29:36like this and then we're going to have
- 2:29:38about
- 2:29:40and the name will be about about Dash us
- 2:29:44probably
- 2:29:46so open site controller
- 2:29:48create that function about
- 2:29:51and we're going to create text widget to
- 2:29:54Output the whole content for about that
- 2:29:55so if I go in the text we just click
- 2:29:59now let's give it key about page
- 2:30:02and let's upload also an image some some
- 2:30:05type of image about us title about us
- 2:30:10and there's going to be some
- 2:30:12lorem ipsum long text okay let me make
- 2:30:16sure they copy anything
- 2:30:20there's a large text
- 2:30:28here we go so it also has this code
- 2:30:31formatting thing
- 2:30:33so I'm going to make this active and I'm
- 2:30:36gonna just click create that was created
- 2:30:39about page and I'm going to go in the
- 2:30:41about action and we're gonna select the
- 2:30:45widget so widget equals text
- 2:30:49text widget
- 2:30:51Yuri
- 2:30:52where
- 2:30:54active
- 2:30:56equals
- 2:30:58true
- 2:31:00and we're going to query first
- 2:31:03okay if the widget doesn't exist
- 2:31:08if no widget then there are two options
- 2:31:10either we can throw not found or we can
- 2:31:13just assume that everything is empty but
- 2:31:16I think not found will be more logical
- 2:31:20in this case
- 2:31:21Pro new not found HTTP exception
- 2:31:27otherwise we're going to return View
- 2:31:31about
- 2:31:33and provide
- 2:31:35widget
- 2:31:39let's actually specify the return type
- 2:31:41to review illuminate View
- 2:31:44and let's go under resources and we can
- 2:31:47create
- 2:31:49new tweak file about blade.php
- 2:31:54okay we need X
- 2:31:56up layout
- 2:32:00and inside there let's just
- 2:32:04um let's just use this same type of
- 2:32:07format we have for the Post page so
- 2:32:10let's get this section
- 2:32:13paste it right here
- 2:32:16then for the image we're gonna use
- 2:32:19widget
- 2:32:22widget image and use slash storage slash
- 2:32:27widget image
- 2:32:29we don't need the categories section I'm
- 2:32:31going to remove that we can use widget
- 2:32:34title
- 2:32:36we don't need that section
- 2:32:38or the
- 2:32:40um
- 2:32:41get formatted date
- 2:32:43and we need
- 2:32:45widget
- 2:32:48content
- 2:32:52like this and we don't need this
- 2:32:54previews and next buttons as well
- 2:32:58so I save
- 2:33:00and reload the page
- 2:33:02let's actually let's open
- 2:33:06about Dash us
- 2:33:09here we go
- 2:33:14um
- 2:33:15let's remove this width
- 2:33:21okay it is under container in normal
- 2:33:23width and the image is broken
- 2:33:28Y is the image broken
- 2:33:36because there are no widget image
- 2:33:40why
- 2:33:42because
- 2:33:45I don't have any idea let's check the
- 2:33:50let's check the
- 2:33:52text widgets
- 2:33:54and image
- 2:33:57we have that image for about page
- 2:34:07okay then white is not visible
- 2:34:14okay let's print
- 2:34:17the whole widget
- 2:34:25this is widget and it has attributes
- 2:34:28and it has image to be null because that
- 2:34:33is about us sidebar
- 2:34:36because we don't specify key that's the
- 2:34:38most important thing we just query the
- 2:34:41first active one but we want to specify
- 2:34:46key because that is that is essential
- 2:34:50here the column key
- 2:34:53equals
- 2:34:55page
- 2:34:58save and reload let's go under about and
- 2:35:01remove this
- 2:35:04and this is it the image is huge so we
- 2:35:09have to probably specify
- 2:35:12Max W full something like this
- 2:35:19or maybe just W full
- 2:35:25what is that
- 2:35:30well it's it shows on a very large width
- 2:35:34and white does this happen if we quickly
- 2:35:38inspect that
- 2:35:41we'll have this section which has
- 2:35:44correct width and then the article so
- 2:35:48that article probably needs to have W
- 2:35:51full
- 2:35:57that's fine
- 2:36:00okay if I zoom out
- 2:36:03this is
- 2:36:05how it looks like so this is
- 2:36:08this is a code
- 2:36:10now let's fix this small bug when we
- 2:36:13open home page right here we get request
- 2:36:16category but that request category does
- 2:36:18not exist and we try to get slack from
- 2:36:21there that's why we have this error
- 2:36:23let's go in the sidebar
- 2:36:26sidebar blade and find this place
- 2:36:29request category eliminated question
- 2:36:31mark right here okay so this basically
- 2:36:34is a relatively new feature it's going
- 2:36:36to check if the request category exists
- 2:36:38it's going to take then slack from there
- 2:36:40if it doesn't exist then it will assume
- 2:36:43that it is now so if I save that and
- 2:36:45reload the page the error basically
- 2:36:47disappears but none of the categories
- 2:36:49are selected as soon as I click on
- 2:36:51JavaScript then the JavaScript is
- 2:36:53selected I click on laravel and laravel
- 2:36:55is selected it's as easy as that
- 2:36:58now let's start working on the SEO side
- 2:37:01search engine optimization is very very
- 2:37:04important thing for any website
- 2:37:06especially blog you want your articles
- 2:37:08to be discovered by Google that's why
- 2:37:10it's good practice to Define your tags
- 2:37:14H1 tag meta tags properly and we'll
- 2:37:17we'll try right now to do this properly
- 2:37:20every Post in from our admin panel needs
- 2:37:23to have some type of meta title in meta
- 2:37:27description fields and this is exactly
- 2:37:29what we're going to do right now
- 2:37:31now let's open page perform and terminal
- 2:37:33and let's go inside the container vendor
- 2:37:37being
- 2:37:38sale bash and I'm going to define a new
- 2:37:43migration file and 82 Fields meet a
- 2:37:46title and meter description PHP artisan
- 2:37:50make migration
- 2:37:56fields to posts
- 2:38:00table I made few typos
- 2:38:04two posts table and hit the enter okay
- 2:38:07let's open now add Nita fields to post
- 2:38:11table and right here
- 2:38:14table string
- 2:38:16let's call this meter
- 2:38:18title and the length of the field should
- 2:38:21be like the recommended size for meter
- 2:38:24title is about 60 characters
- 2:38:26let's just Define into 155 because this
- 2:38:29is bar chart and it doesn't hurt
- 2:38:32so and these must be nullable because if
- 2:38:34user doesn't want to Define meta title
- 2:38:37right there we shouldn't force it let's
- 2:38:39duplicate these and I'm going to Define
- 2:38:41now meta description
- 2:38:44okay so we have those two Fields those
- 2:38:46are two the most important Fields like
- 2:38:49previously meta keywords were also
- 2:38:52important but recently uh basically
- 2:38:55search engines uh updated their strategy
- 2:38:58how they are searching and meta tiles
- 2:39:00meta keywords are not that important so
- 2:39:04we can just get that and I'm going to
- 2:39:06paste in the down and just change the
- 2:39:09string into drop column and let's just
- 2:39:12remove this nullable from there as well
- 2:39:14and I think this length is not necessary
- 2:39:16so we have those two columns now let's
- 2:39:19open Terminal and execute PHP art design
- 2:39:21migrate hit the enter okay that feels
- 2:39:24weird edit now let's open
- 2:39:29post.php model let's scroll up find the
- 2:39:32fillable and let's say it right here
- 2:39:34meta title
- 2:39:36and meta
- 2:39:38description
- 2:39:40perfect so we have model ready now let's
- 2:39:42open post resource
- 2:39:46scroll up in the form section so here is
- 2:39:50our form we have title in Slug yes title
- 2:39:54and slogan body and active well before
- 2:39:58active I'm going to duplicate this body
- 2:40:00and this should be text input
- 2:40:03oops
- 2:40:05text input from filament components like
- 2:40:09this and that should be meta title and
- 2:40:13let's remove required from here and
- 2:40:16let's duplicate this and this should be
- 2:40:18meta description
- 2:40:20so and let's make these text well it
- 2:40:24should be text input as well not text
- 2:40:26area so I'm going to save this and
- 2:40:28reload scroll down below we have meter
- 2:40:30type okay let's type right there my meta
- 2:40:33title in my meter in the description
- 2:40:36because we're going to just test the
- 2:40:38functionality it's it should not be like
- 2:40:40it cannot be actual data so
- 2:40:44um let's save these
- 2:40:46like the proper wording would be it
- 2:40:49might not be it is not mandatory to the
- 2:40:51proper data so just diameter will work
- 2:40:53okay I'm going to reload the page and
- 2:40:56actually we should go to that specific
- 2:40:58post let's copy slag and in the URL
- 2:41:02let's just paste this hit the enter so
- 2:41:04this is the post okay
- 2:41:06but we actually have not implemented
- 2:41:08anything we don't output these Meta Meta
- 2:41:12titles right here so we should do that
- 2:41:14but we also want me to titles to be
- 2:41:17outputted on the home page for example
- 2:41:19and on the about us page which are not
- 2:41:22at the moment
- 2:41:24um
- 2:41:25are not posts and they are not even
- 2:41:27pages and by the way these about us page
- 2:41:29is not linked properly so let's just
- 2:41:31quickly open app dot blade and find this
- 2:41:35about us
- 2:41:37here we go and let's change this into
- 2:41:40root
- 2:41:42about
- 2:41:44uh no it's
- 2:41:46it's probably about us
- 2:41:48here we go I click this and it goes
- 2:41:50right there so we need meta title
- 2:41:52limited description right here as well
- 2:41:53and then home and basically on
- 2:41:56categories page as well so we need this
- 2:41:58everywhere so I'm going to do in the
- 2:42:01following way
- 2:42:02in the app blade I will assume that this
- 2:42:05component will always receive meta title
- 2:42:07and meta description so instead of hard
- 2:42:10coding having a hard-coded text right
- 2:42:13here I'm going to change these in I'm
- 2:42:15going to try to Output meta title right
- 2:42:18there okay and if that does not exist
- 2:42:22or if this is empty let's assume that we
- 2:42:25will always pass that meta title okay
- 2:42:27and if this is empty then we can just
- 2:42:30output the code holic block or you can
- 2:42:34type your own blog name so let's just
- 2:42:36Define the author as well the code holic
- 2:42:39animated description we're going to
- 2:42:41Output right here in the same way meta
- 2:42:44and description and if that doesn't
- 2:42:46exist we can just leave this empty okay
- 2:42:50so now we are using always meet a title
- 2:42:53in meta description in the layout but we
- 2:42:57need to pass those variables to the
- 2:42:59layout right so let's open up layout
- 2:43:03component and in the Constructor let's
- 2:43:06take those two variables public string
- 2:43:10meta title is an empty string or null
- 2:43:14and public string and let's put a
- 2:43:19question mark right here
- 2:43:21in public string
- 2:43:24meta oops Meetup and description is also
- 2:43:30now
- 2:43:31okay so here we have two variables why
- 2:43:35is this all individual value
- 2:43:38question mark question mark is necessary
- 2:43:41right here okay so we have those two
- 2:43:43variables meta title in meta description
- 2:43:45and because we defined them with a
- 2:43:47public key those are class properties
- 2:43:50and they are available in the layout so
- 2:43:53if I just save this and reload the page
- 2:43:55we don't see anything nothing is passed
- 2:43:57right there but if I accept right here
- 2:43:59for example test save and reload and now
- 2:44:02look at this by the way so title is
- 2:44:06outputted right here okay and if we
- 2:44:08click view page Source we see title
- 2:44:10right here and by the way there also
- 2:44:13exists meta title
- 2:44:16but again uh and we can type like meta
- 2:44:19title right here but the latest version
- 2:44:21of search engines I'll look for the
- 2:44:24title text So Meta title is less
- 2:44:25important title is the is key so that's
- 2:44:28the most important thing so we're gonna
- 2:44:30just put the meter title right here okay
- 2:44:33perfect so we have implemented passing
- 2:44:35the data now how we're going to actually
- 2:44:37pass the correct data to the app layout
- 2:44:40let's start from the home I'm going to
- 2:44:42open homeblade PHP and we are using this
- 2:44:45app layout right here so now this layout
- 2:44:48which is a component yeah it accepts
- 2:44:50meta title and meta description so I'm
- 2:44:54going to pass
- 2:44:55Nita dish title to be something like the
- 2:44:59code holy blog or we can just leave this
- 2:45:02empty and because in the upper blade we
- 2:45:04are taking the code holic blog we can
- 2:45:06just leave this empty okay I'm not going
- 2:45:08to pass this meta tape title but instead
- 2:45:11I'm going to pass meta and description
- 2:45:14description and that should probably be
- 2:45:17the code holique
- 2:45:20code holix
- 2:45:22personal blog
- 2:45:25about
- 2:45:27coding tutorials okay
- 2:45:31so I save this reload the page and look
- 2:45:33at this the code holix personal blog
- 2:45:35about coding tutorials and right here we
- 2:45:38see the code call it block and that is
- 2:45:40passed by the way
- 2:45:43are everywhere okay we're right now on
- 2:45:45the category page which should not be
- 2:45:47passed but it is still past we're going
- 2:45:48to fix that but the main thing is that
- 2:45:50if we go on the home page we see that
- 2:45:52the code holix Personnel blog about
- 2:45:53coding and this is the title okay so far
- 2:45:56so good now
- 2:45:58we have implemented the home page now
- 2:46:00let's go on the post page
- 2:46:04post Dot View so in the post view we
- 2:46:08accept post so we can take post meta
- 2:46:11title and post meter description and
- 2:46:14pass them meta title corresponds to
- 2:46:18post
- 2:46:21um title but if post meta title does not
- 2:46:25exist
- 2:46:26then let's take host title okay save
- 2:46:31click on this now click view page source
- 2:46:34and this is the title why JavaScript is
- 2:46:37weird Okay so this is our title we can
- 2:46:41also like prefix or suffix the blog the
- 2:46:45actual application name like the code
- 2:46:47holique blog we can prefix that or
- 2:46:50suffix that you can do this as you want
- 2:46:52like I'm going to leave this right now
- 2:46:54as it is why JavaScript is weird and we
- 2:46:57can also specify meta
- 2:47:00Dash description is
- 2:47:04post meter description
- 2:47:08so I saved it I reload nothing's
- 2:47:11password right here in y let's check
- 2:47:14this
- 2:47:15meter and description I think I have
- 2:47:17passed everything correctly
- 2:47:20if I go in the admin panel
- 2:47:22reload
- 2:47:24okay it was not saved
- 2:47:27yeah that was not saved like my meter
- 2:47:30title in my meta description save
- 2:47:33changes that will save reload the page
- 2:47:35that was lost
- 2:47:37why was that lost let's check
- 2:47:41post
- 2:47:42PHP
- 2:47:44this is why it was lost because I have
- 2:47:47two t right here save that
- 2:47:50okay perfect I reload the page my meta
- 2:47:54title and my description I'm going to
- 2:47:56click save
- 2:47:58reload the page that was actually saved
- 2:48:00and now if I reload the why JavaScript
- 2:48:03is weird and remove the page we see my
- 2:48:05meta title in my description which come
- 2:48:08from here okay so if I just delete my
- 2:48:11meter title and hit the enter that was
- 2:48:13saved reload the page now it's going to
- 2:48:15take the title actual post title from
- 2:48:19here okay it's a fallback and it's good
- 2:48:21good logic in my opinion so now we have
- 2:48:24implemented a passing meta titles and
- 2:48:27with the descriptions for the home page
- 2:48:30as well as for the Post view page okay
- 2:48:34what other rules do we have let's open
- 2:48:37web.php and have a look so we have about
- 2:48:40us page and we have Pi category page
- 2:48:43let's go on the about page right here
- 2:48:47which renders about that blade so let's
- 2:48:49open about blade PHP and in the same way
- 2:48:53we're going to pass like meta title
- 2:48:58and let's just type the code holique
- 2:49:02blog or maybe about the code holic
- 2:49:09or something like this like the code
- 2:49:10holix blog or something like this okay
- 2:49:12now there's about ask page that should
- 2:49:15be probably and of course we can specify
- 2:49:18meta and description you get the idea
- 2:49:20I'm just going to type lorem ipsum
- 2:49:24okay I saved it by the way if you pass
- 2:49:26this with a column uh you need to put
- 2:49:29this inside quotations okay because we
- 2:49:32need it expects like a variable at this
- 2:49:35moment but if you remove this column we
- 2:49:37can just remove this uh
- 2:49:40quotations as well save that and let's
- 2:49:44go on about Dash as page and here we see
- 2:49:47the code holdx plug and lorem ipsum
- 2:49:50perfect so we have implemented about us
- 2:49:52as well and the last thing is to
- 2:49:54implement the Page by category let's go
- 2:49:57in the post controller by category and
- 2:50:01that renders a whole
- 2:50:04but you know what rendering the same
- 2:50:07view for by category as we have rendered
- 2:50:11for
- 2:50:14for the home is not actually a good idea
- 2:50:17so maybe we need to go in the home and
- 2:50:21I'm going to copy this home and paste
- 2:50:23inside the post folder and I'm going to
- 2:50:25call this index maybe okay and in the
- 2:50:29index
- 2:50:30we know that
- 2:50:32um
- 2:50:34we let's go in the post by category and
- 2:50:37let's pass the category okay from here
- 2:50:39so we pass the category uh we render
- 2:50:42post.index right here and now if we open
- 2:50:45that index we know that we have right
- 2:50:48here category so maybe we can specify
- 2:50:51inside meta title to be like category
- 2:50:57title Maybe
- 2:50:59and meta description can be whatever
- 2:51:01whatever you want like
- 2:51:04um by category description or something
- 2:51:07like this so I save this now and click
- 2:51:10on the JavaScript which renders pull
- 2:51:12Spike diggery view page source and we
- 2:51:15see JavaScript which is actually the
- 2:51:17title now for the category right so the
- 2:51:20ideal title probably will be
- 2:51:24the code holique blog dish
- 2:51:29or maybe not Dash let's leave a dash
- 2:51:32posts
- 2:51:34by category
- 2:51:37in the actual category so I save and
- 2:51:39reload the code public blog post by
- 2:51:41category JavaScript okay that's very
- 2:51:43very logical title for that page
- 2:51:47and I guess it's not more than six
- 2:51:49characters as well so in the description
- 2:51:51you can type something like this as well
- 2:51:53and I think we are good so now we have
- 2:51:56titles for every page like on the home
- 2:51:59page
- 2:52:00view page Source we have implemented
- 2:52:03those
- 2:52:04uh we have implemented uh meta titles
- 2:52:07for the by category page about us page
- 2:52:10let's check this once again and I think
- 2:52:12that's perfect and whenever you create
- 2:52:15new post from the admin panel if you
- 2:52:18Define meta title and meet a description
- 2:52:20uh then you basically tell search engine
- 2:52:24that hey this this is the overall
- 2:52:26information about my post and then it
- 2:52:29helps basically search engine of course
- 2:52:31only meta title and meter description
- 2:52:33are not 100 enough to optimize your blog
- 2:52:37post or Otero websites or any Pages you
- 2:52:40can optionally add other titles like OG
- 2:52:43uh open graph titles for sharing your
- 2:52:47posts on Facebook or on social media and
- 2:52:51I really really recommend to do that and
- 2:52:54Implement those fields as well now let's
- 2:52:57do some final touches on a website let
- 2:53:01me first change the background color of
- 2:53:03the body
- 2:53:04at the moment it is white and we also
- 2:53:06have white cards on that so I'm going to
- 2:53:09change this into gray Dash 15 and let's
- 2:53:12remove this white I'm going to save and
- 2:53:14reload and now that's much better
- 2:53:18now if I scroll down below and zoom out
- 2:53:21slightly we see that the cards have
- 2:53:23actually background transparent so let's
- 2:53:26go in the post item
- 2:53:29find that article and give it class PG
- 2:53:33white save that
- 2:53:37and reload and now this one has a white
- 2:53:39background
- 2:53:41if we scroll at the very top and click
- 2:53:43this logo it doesn't do anything so I'm
- 2:53:46going to go in the categories section
- 2:53:48click right here it doesn't do anything
- 2:53:50so this should go to the home page so
- 2:53:53let's go in the up blade and find this
- 2:53:56the code holy blog and let's change this
- 2:53:59href into root home
- 2:54:03save refresh the page and click right
- 2:54:06here it goes to the home
- 2:54:07on the right side we have this about our
- 2:54:10section but whenever I click on this
- 2:54:12button it doesn't do anything we need to
- 2:54:14link this to the about us page so let's
- 2:54:17go in the sidebar find this button and
- 2:54:21we're going to change this into roads
- 2:54:24about Dash us save reload the page and
- 2:54:28click on this and we are on about us
- 2:54:30page
- 2:54:31okay let's scroll down below let's go in
- 2:54:34the JavaScript section when there are
- 2:54:36multiple categories on the post they are
- 2:54:38not on a single line they are each on
- 2:54:41its own line and we're going to change
- 2:54:43that I don't like this so let's go in
- 2:54:46the post item and right here we iterate
- 2:54:49over our categories so I'm going to
- 2:54:51create new div give it
- 2:54:54it should be div
- 2:54:56give it a class of flex and let's give
- 2:55:00it also gap of three for example or
- 2:55:03maybe even four and the closing tag goes
- 2:55:06right here we save the code and now
- 2:55:09let's reload the page
- 2:55:14and here we see now they are all
- 2:55:17categories on its own line and on a on
- 2:55:20the same line and if I click on this
- 2:55:21article right here we have the same
- 2:55:24thing and now if I click on this article
- 2:55:26and go inside uh right here there's the
- 2:55:29same problem so we're going to open a
- 2:55:33view.play.php find that category is
- 2:55:35rendering and basically I'm going to use
- 2:55:38the same class same div as a wrapper of
- 2:55:42this for each
- 2:55:44right here
- 2:55:46format the code and reload the page and
- 2:55:49voila on this article I added a code
- 2:55:52which are under pre-tax but they don't
- 2:55:56look like a code actually so let's add
- 2:55:59small CSS to identify that this is a
- 2:56:02code uh block of code so in the app play
- 2:56:06in the layout just like we have the fun
- 2:56:08family Carla I'm going to create a small
- 2:56:10CSS I'm not doing this in a separate CSS
- 2:56:14file because it's very small and very
- 2:56:15minimalistic like on pre we're going to
- 2:56:18have padding to be one ram let's give it
- 2:56:22a background color to be
- 2:56:24like a gray or black let's give it color
- 2:56:28to be white and let's give it border
- 2:56:31radius to be 0.5 Ram
- 2:56:34and let's save this and have a look
- 2:56:36reload the page and this is it I think
- 2:56:39this is exactly what I wanted so and
- 2:56:41let's give this also margin bottom like
- 2:56:44one ram
- 2:56:46like this say reload and this is exactly
- 2:56:49what I wanted
- 2:56:51that's it guys in this video and I hope
- 2:56:54you enjoyed it if you want to see how I
- 2:56:55built a full stack application with the
- 2:56:57react and lateral click right here if
- 2:57:00you prefer view JS you should check the
- 2:57:02following video otherwise I will see you
- 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.