Laravel CMS | N-08 | Creating a Basic Laravel Blog

CoderOne · Beginner ·🛠️ AI Tools & Apps ·8y ago

Key Takeaways

Creates a basic blog using Laravel CMS

Full Transcript

hey what you're gonna know is how old were doing welcome to the eighth series of making a control management system in Louisville we are in the eighth so go ahead and watch the last one if you haven't already so in today's one we're gonna talk about how to do this blog and I've already gone and designed this for you so I about the not born up and the cards in here as you can see so we can add adjust the logic and show our post that has been saved in the database right out of the box we have created a lot of stuff so let me just go back into the lord of the CMS told them and we have the last story or wealth out of the post adding as well as the categories and all the Ajax and pop-ups so we have covered them in the past few tours of the series so please make sure to watch them before watching the eighth one so the last one we've we've covered the other new post with the title with the category of featuring from there and also the post content all of that in one place so now when we add the post we won't be able to know about them unless we have a blog or something to show the post for us therefore we're gonna create that blog I've already gone and set up this couple of files actually in the models and stuff so first of all come and do is create a default under the views and add an index top plate dot PHP and I named the folder or the filter a blog so it's gonna represent our blog files and the index page is in here so enter the index I've gone and just extends from the app layouts so make sure to audit your I don't think if you really want to do like a big block by the way if you are intended to make a business blog in here so make sure to create a difference or separate application than your ruler poll CMS application create a new layer for application and use that for a blog then you can fetch the data from the database the DNS has been inserted from your like by your CMS so you can integrate that or further degree that with the CMS which makes is a really really nice one make sure to not use it this why this way because in this particular one we are using it like in very very simple please make sure to use it in another different way to differentiate from your CMS application anyway so I've gone out and the include so I've made a separate file for the navbar so if we go up in here under the included on the Nakamoto blade of PHP and have grabs this code from the snip sets available in bootstrap documentation so if we go back and bootstrap calm and the documentation you're gonna find the navbar make sure to check this out and all they're not borrowing here with a search bar with with with a lot of stuff with like a bootstrap or a responsive my bar for your mobile devices a screen responsive all of this kind of stuff with the different colors ever just gone and copy the code and paste in here I'm gonna also find it coming together please make sure if you really want to check this card going to the github you're gonna find the source code in there so I've gone and put the code in here and then concluded the math bar and do our main - row section so and I've had the Creator that death with middle of eights a colony the bootstrap and I'm off sets of two and create a just a blog title in here and add the two cards and they've grabbed the card also from the bootstrap documentation so if you go to the cards you're gonna find all the available cards on here with different dimensions and image dimensions in here so please make sure to LIKE grab whatever code you really need in here so whatever you switch you need you're gonna grab it and put in here I've just grabbed two of them in here so demonstrates how it's gonna look like and also I've gone into the routes like if we go to the web PHP and you're gonna find just a hard-coded function in here or hard-coded callback function so it's gonna return a view to the blog dot index simple as that we're going here go forward slash the blog we're gonna find our index blog page this all we have done to make that happen two children are in the two cards and here now what we're going to do actually is share the post data that has been saved on the database so now if you go to the Waffle House phpMyAdmin to check out our database and she to see actually the post that has been saved from our CMS in here you're gonna see all the posts so I want to fetch the post from the database then render them out on the blog in here in nice way what you can do later on is implement the authentication system for the login and the signup and also the pages in here if we were not like that loads of pages from your blog let's say categories and into the category is gonna have like I'm a web development programming game developments a lot of other things so you can add them up in here within the NOC bar but for professional uses you can create your own or style your I'm not going in for make it looks a bit better than this because this is like default theme from the bootstrap I don't really like it but just for the basic stuff in here now as I've said if you go to the admin panel and you're gonna find our posts we have already one post in here for the dip on the database for the time being but we're gonna add a lot of other things a lot of other posts in the next video you can do that from from the CMS so let me just open up the same as in a new page so we'll go to CMS pop dev me take over this and then we're gonna open up on the new post and we can add a new post so what you can do here for the post content is it was a custom posts or contents manager so you can find this by googling and I have realized one is a CK editor so if we go to the CK editor you can find this also this parabola in deterring author just Google this antony gonna find us make sure to use this one to integrate three easy to integrate it just using javascript and gonna make your life easier when writing posts especially very long posts for your blog anyway now for fetching from the database we're gonna go back in here and create a controller so Nagios PHP artisan make controller I'm gonna need the controller is blog we draw a simple stance I'm gonna - - resource so that gonna create the controller for us then we're gonna fetch the data me something's going on in here me control control is not a couple key speech garrison okay with the problem just do you mean in one of these okay it means one of these yeah but I control what's going on if you draw me too much okay something is messed up and let's try again yeah control has been created successfully there were something wrong in here just I missed I'm painting now the control has been successfully audit and you're up under up up HTTP and over here gonna find block control it is so let me just minimize this for a second and under the index page you wanna just return the view serve you and gonna be like indoor our blog file or folder and index so you're just gonna return this and on the web top HP rather than just how can you function I'm gonna call our controlling here so long controller ah I'm gonna name this make sure to name your Rob's because you're gonna they're gonna make your life easier when you're trying to reference a specific route for another application so make sure to do that I'm gonna make you're like way much more easier now it's gonna end up blog blog controller and yeah this is and X okay everything looks fine in here we go refresh we should seen out effects in here no changes at all so fresh the world with the same as gay everything is working now try to other the logics so for the index page we want to pass in the available posts alongside this view to allow me around the routes from the index page so to show the data to render out the post data in here under our cards containers so to do that we're gonna fetch it from the database so another blog gonna need to include or use of posts model host okay so to grab the data from the base now we should create a post and call it post and ordered by make sure to order your posts by whatever Proctor but I'm gonna eat with the created adds timestamps and and descending and gonna get this all of it without filtering so here we are just gonna pass it through with a width method to the view so well and we're gonna call this second we are going to call this posts yeah I'm gonna put the post variable up here with method this working post is being now under our index dot blade dot PHP we should put the data in here so as you can see I have two of these let me just come this one oh let's just get rid of all of this because we have already a sales version of this now we need to create a phone booth looks through each of the posts in here and creating a statement first to check if like the there's at least one post in order to render this if not like no posts is available there's a zero post in our database we need to like shell message no post available for the moment your blog has no post few moments please try again or return it another time or something like this so let me just end the F over here and down here and if the back use the couch method and those during than 0 then you can render out and we're gonna use a Nelson you so else here you can just put a dev and class off a large a lot danger know those samples that's so here we cannot render out or use our folder so as we have done the last one before group is a form each you can use it for each or for a normal for with an AI plus plus and stuff so I'm gonna use for all for each for simplicity me so for each I'm gonna look over post post and we are going to close the form you so for each here we're gonna use the post myth all the posts close here so to fetch the data it's like an instance from our database table the post on the admin panel so we can able to do put the title on here so post title make sure to name yours in here your variable the same as the field name on your database as you can see how the name of title so I'm gonna grab this one make sure to if you if you haven't been following the tutorials series from the beginning like you have created your own variable names and stuff make sure to put them in here in order to make things work for you and I forget about the curly braces around in the title in here so let me just do that very quickly and also the context justice or text we are going to render about we're not so here you can do a function function that reduces the post content so let's say you have a post contents off I don't know 300 characters or 400 characters you don't wanna like display all the 300 characters in here you're just gonna type or display or show an overview of your both so to do that you need just a kind of a function to reduces the text into like I don't know a quarter or one of four of its full lengths or something like you can do that very easily user.php I'm not gonna do I'm gonna just gonna put those contents okay and here you can this but I'm gonna allow you to navigate into the actual post page so let's see here you're gonna see the offer view of the post and we could go somewhere or we can change this like to show show post okay read post for example so Reese post will come up like use this read post cannot read the whole post content and with an image with thumbnail because you're not supporting a thumbnail right now we can see you can put the thumbnail up here for more like making your blog looks a bit better than this but this is very basic I'm just gonna show these structures and how to get and use or get stuff from the database no that should do the job perfectly let's try to look or refresh our page actually and we should see something like the posts and one only post a post title as we have called this a post title and nothing more like a post content and what we can do is add another P in here and plus equals card - text try to add back author and get hosed off simple stats try to refresh now everything should look fine and we should see the post author so that is using as you see author is a stamp in US but yeah ridiculous using the author or prepending the author in here I'm just gonna use the author original author name and you can add another post in here I don't know let's say new host whatever and this category like new cats and this is another just post okay now other new post you should see a success message over here telling us like the post has been successfully on post added successfully and refers to CMS we should see a new post listing here so yep a new post new post media post concert and that that's how it's gonna be done looping each one and just rendering them then you can style your your own post is like this it's very simple using little bug it's way much more simple than using like a normal PHP or whatever other framework level very very simple very convenient for everybody wanna do something very simple or something really powerful by the way at the same time now what we wanna cover is showing the actual post content so when we click on this read post you're gonna redirect us or take us to another page where we're gonna see the full post contents and with the author and stuff you can style this but I'm gonna just prove this arbitrary so I'm gonna go into the blog I haven't done this like haven't added this for you before recording the video so yeah let's do that very fast and make it really basic so we're creating your file I mean I shouldn't call it a shell don't blade PHP which is gonna show that the a single posts and for that we're also gonna extend from the leg and we're gonna put section and then we remember about this section I always forgot about the sections me - row and suction and here we can or we need to include an after so we talk to this desk over here we need to put this one as well so let me copy this and let me just make this the offsets a bit like for a for or to do it doing the job perfectly so in a problem here okay then here we should put our posts so the post post contents gonna I'm gonna hold first to be for the h3 is the post time I'm gonna put a class of we stock class text centers you gonna align the text into the center and I'm gonna here put the post I'm just gonna put this empty back go back comes back into here for a second and the other one we're gonna put is a P here the post content is gonna go all the post contents and what actually gonna use is class yes card text for making this looks a bit nicer and or before that we can add like I don't know some small with class of a bootstrap text commuted makes the text a bit muted change the color to gray very dark quite actually and here we're gonna put the off so now let's go ahead and route it into our Dysport to this post so how to route this actually is part by passing an arguments in here so let's say when we click on this wheat post it gonna redirect us local touch TMS to dev /blog then /the ID of this post where it's gonna show us the actual post and so to do that three simple using their phone so you're gonna go into web dot PHP so using another route and a get method I'm gonna call it blonde then /then to reference or to tell it but we're gonna pass in a variable in here you use two curly braces then between them puts your Wilbur name here you variable name sure about this I can't spell a variable okay a block /a curly brace then an ID then another closing photo please then put the controller method can handle this cell block controller add show so this is a specific show one show method in our controller which takes an argument of an ID and that can do the job for us so if you haven't liked let me create the category don't specify - - resource option we won't get all of this like shell method and the index method and store method already for us so you can create them by yourself but you can't touch - resource option gonna allow you to win a bit of time maybe yeah so using the category semicolon up here category not indexed so I'm gonna call this in a second and show method block intro again in session ID now for telling it like when we click on this button to route us or to redirect us into the actual show page so what we actually going to do is to go ahead give me a second going to be blah controller and I was gonna run to us as you can see the show method takes an ID so we're gonna pass in the ID or the post ID and for routing we need to go to the end exponent of PHP and under the primary pattern here until the href opener puts or the function of routes route function which can allow to us and we put the name of the router meaning its category top index and here we specify which ID so we passing in the neck the second argument is the ID so here we're gonna put the ID which is going to be involved the post or you can pass in an array if you have a multiple IDs I like using that you put the variable name to get variable name that we have just put it in here so let me go to the web tour PHP this one it should be this one so the ID then you put the volume in here like the actual ID and I'm gonna put post by the actual post ID in here because we have in the post one as simple as does it gonna routes us into the new page but we can't because we're not handling this he has to let me go to the board control I'll show this show or like fill out the show method and single post in here so you're gonna fetch the actual post from the database so post we're gonna use post and find or fail so kind of finds it otherwise it's gonna fail over to an exception and I'm gonna put all right in here then under all post we're just gonna call a few return a view and a view of [Music] blog with so I'm gonna pass the post we pass the actual post into our view to render out the data samples that this house can being done behind the scenes so now it's gonna route us dublado Chow and passing the post attribute now variable now going to the plate of shell and puts in the post in here so post and we put your title and here the post post the post contents were born in its post samples that there should the job perfectly frost not refresh and now we will be able to go ahead to the post and see the actual post content now for the new post the click read post it takes block ID and it gonna just redirect us back into here okay why this is happening we're not going into there or something like something's going on this should be something wrong there has to be something wrong yeah so not the index I'm calling the index by the way I'm lecturing so that is guess to go to the index dot page I'm calling category index where should I call the show routing okay now should go back just to the blog try this again and that should work for us okay post I could see 4/1 on the ID of the actual post and gonna take us into another play well the this is the author and it's the post title and this is the content so the context you already have the constants can see here all the only content into the post content you can add however you want and you can start this page which kind of switch your need or whatever you do so I guess this is what we have covered for today you can you can also other this one other the functionality for this if we go to the helm one you can use the raft method as we have done in here it's gonna be very simple just calling the route one with the route name and it's gonna redirect you into the actual page you wanna see so I guess this pretty much it guys for today's we've implemented that's gonna be very simple as you have seen here for I'm doing single post we're showing the single post also showing all the developer posts Blanco's this was a very very simple blog now for covering the sign up and the login or the authentication system maybe I'm gonna put in the next video tutorial some authentication system in here like how to log in and register people so I guess this is pretty much it guys think is watching I hope you really enjoyed us if you have any problems issues please make sure to comment them below I would be very happy to you know response and give you the best I have out there so in the next video tutorial till then see you the next time

Original Description

Read the Written Tutorial: http://go.ipenywis.com/ipeny1b19 --- Official Links---- Official Website: http://ipenywis.com Official Facebook: http://go.ipenywis.com/ipeny4907 Official Twitter: http://go.ipenywis.com/islem9a03 Official GitHub Repo: http://go.ipenywis.com/ipeny5c0e ---Support US--- By Becoming a Patreon: http://go.ipenywis.com/ipeny5024
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CoderOne · CoderOne · 8 of 60

1 Laravel CMS | N-01 | Getting Started and Environment Set Up
Laravel CMS | N-01 | Getting Started and Environment Set Up
CoderOne
2 Laravel CMS | N-02 | Routes, Controllers and Views
Laravel CMS | N-02 | Routes, Controllers and Views
CoderOne
3 Laravel CMS | N-03 | Dealing With Assets and Page Layouts
Laravel CMS | N-03 | Dealing With Assets and Page Layouts
CoderOne
4 Laravel CMS | N-04 | Migration, Models and Adding Categories
Laravel CMS | N-04 | Migration, Models and Adding Categories
CoderOne
5 Laravel CMS | N-05 | Showing Added Categories, and Session Messages
Laravel CMS | N-05 | Showing Added Categories, and Session Messages
CoderOne
6 Laravel CMS | N-06 | Edit\Remove Categories using AJAX and Popups
Laravel CMS | N-06 | Edit\Remove Categories using AJAX and Popups
CoderOne
7 Laravel CMS | N-07 | Add New Post
Laravel CMS | N-07 | Add New Post
CoderOne
Laravel CMS | N-08 | Creating a Basic Laravel Blog
Laravel CMS | N-08 | Creating a Basic Laravel Blog
CoderOne
9 HTML5 Canvas For Beginners | Getting Started | #01 with Webpack
HTML5 Canvas For Beginners | Getting Started | #01 with Webpack
CoderOne
10 HTML5 Canvas For Beginners | Drawing Basic Shapes | 02
HTML5 Canvas For Beginners | Drawing Basic Shapes | 02
CoderOne
11 HTML5 Canvas | Drawing Text With Circles | Part 01
HTML5 Canvas | Drawing Text With Circles | Part 01
CoderOne
12 HTML5 Canvas | Text Animation and Circle Collision | Part 02
HTML5 Canvas | Text Animation and Circle Collision | Part 02
CoderOne
13 Complete Guide To Web Development In 2018
Complete Guide To Web Development In 2018
CoderOne
14 AJAX & JSON Explained | Examples
AJAX & JSON Explained | Examples
CoderOne
15 Visual Studio Code Web Development Setup and Extensions
Visual Studio Code Web Development Setup and Extensions
CoderOne
16 Electron Build Desktop Apps HTML/CSS/JS - Getting Started 01
Electron Build Desktop Apps HTML/CSS/JS - Getting Started 01
CoderOne
17 Electron Build Desktop Apps HTML/CSS/JS | Creating Windows and Processes 02
Electron Build Desktop Apps HTML/CSS/JS | Creating Windows and Processes 02
CoderOne
18 Electron Build Desktop Apps HTML\CSS\JS | Dialog, Sessions and Cookies 03
Electron Build Desktop Apps HTML\CSS\JS | Dialog, Sessions and Cookies 03
CoderOne
19 Electron Build Desktop Apps HTML\CSS\JS | Custom App Menu & Context Menu 04
Electron Build Desktop Apps HTML\CSS\JS | Custom App Menu & Context Menu 04
CoderOne
20 Electron Build Desktop Apps HTML\CSS\JS | Package, Build and Deploy your App 05
Electron Build Desktop Apps HTML\CSS\JS | Package, Build and Deploy your App 05
CoderOne
21 Node.js Brief Beginners Introduction #01
Node.js Brief Beginners Introduction #01
CoderOne
22 Node.js How Modules Works & NPM #02
Node.js How Modules Works & NPM #02
CoderOne
23 Node.js Working With Events and Event Emitter #03
Node.js Working With Events and Event Emitter #03
CoderOne
24 Node.js File System (Read and Write) FS 04
Node.js File System (Read and Write) FS 04
CoderOne
25 Node.js Create a Basic Server Using Express 05
Node.js Create a Basic Server Using Express 05
CoderOne
26 Json Web Token Authentication JWT Explained Securing API
Json Web Token Authentication JWT Explained Securing API
CoderOne
27 CSS Flex Box Design | Practical Examples |
CSS Flex Box Design | Practical Examples |
CoderOne
28 API How It Works With Practical Examples
API How It Works With Practical Examples
CoderOne
29 MongoDB Getting Started 01
MongoDB Getting Started 01
CoderOne
30 MongoDB Working with APIs and Practical Examples
MongoDB Working with APIs and Practical Examples
CoderOne
31 Create a Command Line Interface (CLI) Using Node JS #01
Create a Command Line Interface (CLI) Using Node JS #01
CoderOne
32 Create a Command Line Interface (CLI) Using Node JS 02
Create a Command Line Interface (CLI) Using Node JS 02
CoderOne
33 Build React Apps | Introduction And Getting Started #01
Build React Apps | Introduction And Getting Started #01
CoderOne
34 Build React Apps | Working With Components And Multiple Rendering #02
Build React Apps | Working With Components And Multiple Rendering #02
CoderOne
35 Build React Apps | App State Management | Practical Examples #03
Build React Apps | App State Management | Practical Examples #03
CoderOne
36 Build React Apps | Getting Started With Flux (Intro) #04
Build React Apps | Getting Started With Flux (Intro) #04
CoderOne
37 Build React Apps | Create a Clock Timer Using React 05
Build React Apps | Create a Clock Timer Using React 05
CoderOne
38 Build React Apps | Create a Clock Timer Using React 05 | PART2|
Build React Apps | Create a Clock Timer Using React 05 | PART2|
CoderOne
39 CSS Preprocessors Getting Started | SASS and LESS | Practical Examples
CSS Preprocessors Getting Started | SASS and LESS | Practical Examples
CoderOne
40 Regex Introduction | Learn Regular Expressions 01
Regex Introduction | Learn Regular Expressions 01
CoderOne
41 PHP VS Node.js Which is Best For Web Development
PHP VS Node.js Which is Best For Web Development
CoderOne
42 Drag and Drop Using Native Javascript 01
Drag and Drop Using Native Javascript 01
CoderOne
43 Drag And Drop Using Native Javascript 02
Drag And Drop Using Native Javascript 02
CoderOne
44 Master Git (Version Control) in One Video From Scratch
Master Git (Version Control) in One Video From Scratch
CoderOne
45 Let's Learn The New Javascript ES6 Class Syntax
Let's Learn The New Javascript ES6 Class Syntax
CoderOne
46 Let's Create A BlockChain On Node.js
Let's Create A BlockChain On Node.js
CoderOne
47 Best Online Code Editors For Web Developers
Best Online Code Editors For Web Developers
CoderOne
48 Let's Create a Modern Login Form on React #01
Let's Create a Modern Login Form on React #01
CoderOne
49 Let's Create a Modern Login Form on React #02
Let's Create a Modern Login Form on React #02
CoderOne
50 Laravel CMS | N-09 | Admin Registration
Laravel CMS | N-09 | Admin Registration
CoderOne
51 Laravel CMS | N-10 | Login and Authentication
Laravel CMS | N-10 | Login and Authentication
CoderOne
52 Let's Create a Twitter Bot (Listen and Retweet)
Let's Create a Twitter Bot (Listen and Retweet)
CoderOne
53 Rapid Webpage Creation With Emmet (HTML & CSS)
Rapid Webpage Creation With Emmet (HTML & CSS)
CoderOne
54 Create Popups and Modals Using Native Javascript, HTML and CSS
Create Popups and Modals Using Native Javascript, HTML and CSS
CoderOne
55 Promises and Callbacks on Javascript With Practical Examples
Promises and Callbacks on Javascript With Practical Examples
CoderOne
56 Create Collapses using Native Javascript, HTML and CSS
Create Collapses using Native Javascript, HTML and CSS
CoderOne
57 Let's Learn Typescript (Javascript Devs) | Getting Started 01
Let's Learn Typescript (Javascript Devs) | Getting Started 01
CoderOne
58 Let's Learn Typescript | Interfaces and Generic Types (The Typing System) 02
Let's Learn Typescript | Interfaces and Generic Types (The Typing System) 02
CoderOne
59 Let's Learn Typescript | Work With Classes, Modules and Enums 03
Let's Learn Typescript | Work With Classes, Modules and Enums 03
CoderOne
60 Let's Learn Typescript | React and Webpack With TS 04
Let's Learn Typescript | React and Webpack With TS 04
CoderOne

Related Reads

Up next
Your Competitors Are Using This: The AI SEO Toolkit for Brand Mentions
Matt Tutorials
Watch →