How to make a Blog in Laravel

In this article, we will go through how to make a blog in Laravel. We will build a simple blog and admin panel for managing the users and task. Source code for this project is available on GitHub, link: https://github.com/digitalcrm/Blog-Laravel.

1. Installation

First you will need a fresh installation of the Laravel framework. Install the Laravel framework using composer:
“composer create-project –prefer-dist projectname”

2. Prepping the Database

2.1.Connect Database with your Laravel project:

Go to your database server and create database. In this article, I have used the wamp server phpMyAdmin :

Connect with your project, go to “.env” file and change the DB_CONNECTION, Database, User_name and password. In phpMyAdmin the default value of user_name is root and password is null(empty):

3. Make Database Model and Migrations

Next, create migrations and models for your blog. For creating model/migration run the artisan command in your terminal: “php artisan make:model model_name –m”. Here “-m” refers to migrations.

In this article, I have created different models and migrations for User and Admin. The migration will be place in the “database/migrations” and Model will be placed in “app/model” directory of your project.

Model “post.php”

Migration table “create_posts_table.php”

After creating and setup the migrations accordingly to your blog databases, run the migrate command in your terminals. Command: “php artisan migrate”

After running migrate command, tables will be generated in database:

4. Routing

Next, we will add routes to our blog or application. Basically routes are used to points URLs to controllers or closure function that should be executed when a user accesses a given page. By default, all Laravel routes are defined in the “routes/web.php” file.
In this article, I have created many routes for User, Admin, Home and Auth.

5. Controller

After adding the routes, we will need a controller for our blog or project. In Laravel all controller are generated in the “app\Http\Controller” directory. Command:
php artisan make:controller ControllerName –resources
OR
php artisan make:controller ControllerName
Resource Controller command

Resource Controller (“app/Http/Controller/Admin/PostController.php”) file

Controller Command

Controller File (“app/Http/Controller/User/PostController.php”)

In this article, I have created the different controller for the User, Admin and Home part of our blog.

In the Admin controller, I have duplicated the auth controller for admin side authentication purpose.

6. Authentication

Run the auth artisan command in your terminal for creating the authentication in your project.
Command: “php artisan make:auth”.

After running this, the command will generate auth controllers, views and routes for your project.

Controller: Auth controllers are generated in “app/Http/Controllers/Auth” directory.

Views: auth views are generated under in “resources/views/auth” directory.

7. Building Layouts & Views

In this article has multiple views which contain a form for Admin, Blog, role, category, permission, tag, list users and as well as a listing of all blog. As we know all Laravel views are stored in “resources/views”. So we have defined multiple layout view in this directory.

7.1. Layouts
In this layout, we have created the app layouts for Login, Register and Logout.

7.2. Admin Views
In this view, we have created multiple views for admin task and also created an admin panel and blog page layouts.

7.3. User Views
Basically, as we know all web applications share the same layout across pages. So, in this view, we have defined the layouts for users. Laravel makes it easy to share these common features across every page using Blade layouts.

8. Adding Tasks

After creating the view, we have to move for create, update, store, edit, and delete tasks for each route of controller. Example for post-controller:

create

store

edit and update

destroy

9. Authorization

Laravel uses policies to organize authorization logic into simple, small classes. Typically, each policy corresponds to a model. In this article, we create a PostPolicy using the artisan command:
“php artisan make:policy PostPolicy”

After this command, we will add some validation in “post policy” as needed.

10. Blog Interface

Home Page

Admin Dashboard

Blog Create

User’s Blogs

1 thought on “How to make a Blog in Laravel”

Leave a Comment

%d bloggers like this:
adıyamanescortağrı escortinstagram takipçi hilesiwso shellhtml code encryptionbursa escortistanbul escortantalya escortkayseri escortsakarya escortgaziantep escorteskişehir escortmersin escortankara escortizmir escortadana escorthtml kod şifrelemeinstagram takipçi hilesiçekiliş sitesiserver scansunucu taramasite speed testsite hız testiseo newsgoogle newssite analysisseo analysisbacklink saleshacklink panelpubg hile alwordpress themeswordpress free temaWordpress Free Themeswordpress ücretsiz temahtml kod şifrelemeWho issunucu taramaseo sorgulamaseo sorgulaseoTanıtım Yazısıhacklinkbacklink albacklinkseo araclarıseo analizsite analizbacklink satışhacklink satıştitan jeldelay spreymucize kremtitan jelgeciktirici hapcialis fiyatcialis 100 mgviagra fiyatıpenis büyütücü kremlifta 5 mgwso shellwso shellafyon escortaksaray escortamasya escortardahan escortartvin escortaydın escortbalıkesir escortbartın escortbatman escortbayburt escortbilecik escortbingöl escortbitlis escortbolu escortburdur escortçanakkale escortçankırı escortçorum escortdenizli escortdiyarbakır escortdüzce escortedirne escortkars escortelazığ escorterzincan escorterzurum escortgiresun escortgümüşhane escorthatay escortığdır escortısparta escortmaraş escortkarabük escortkastamonu escortmalatya escortkilis escortkırıkkale escortkırklareli escortkırşehir escortkocaeli escortkonya escortkütahya escortmanisa escortmardin escortmuğla escortmuş escortnevşehir escortniğde escortordu escortosmaniye escortrize escortsamsun escorturfa escortsiirt escortşırnak escortsivas escorttekirdağ escorttokat escorttrabzon escorttunceli escortuşak escortvan escortyozgat escortyalova escortzonguldak escortkıbrıs escortAnkara rus escortankara escortankara escortankara escort bayanEscort ankaraAnkara escort kızlarankara escortSincan escort bayanEscort sincanSincan escortEryaman escortEryaman escort bayanEscort eryamanKeçiören EscortKeçiören escort bayanEtlik escortEtlik escort bayanÇankaya escort bayanKızılay escortKızılay escort bayanÇankaya escortantalya escortantalya escort bayanEscort antalyaantalya escortantalya escort bayanEscort antalyaankara escortankara escort bayanEscort ankaracialis 5 mg fiyatviagra 100 mgstag 9000yapay kızlık zarıegzama şampuanıkeratin serumçorlu escortçerkezköy escortsivas escortmanisa escortizmir escorthatay escorterzurum escortbalikesir escorturfa escorttrabzon escorttekirdag escortsamsun escortsakarya escortordu escortmugla escortmersin escortmardin escortmaras escortmalatya escortkonya escortkocaeli escortkayseri escorteskisehir escortdiyarbakir escortdenizli escortbursa escortaydin escortantep escortankara escortadana escortbursa sinirsiz escortizmit escortşişli escort bayanşişli bayan escortkurtkoy escort bayanşişli escortşişli bayan escortşişli bayan escorttuzla escorttuzla escort bayancialis jelcialis fiyatlifta 20 mgviagra satın alviagra 100 mg fiyatviagra siparişcialis 5 mg fiyatsultangazi escortsinop escortpendik escortesenyurt escortzeytinburnu escortküçükçekmece escortbeşiktaş escorttuzla escortbeykoz escortfatih escortsancaktepe escortarnavutköy escortbağcılar escortümraniye escortbeyoğlu escortüsküdar escortesenler escortmecidiyeköy escortsarıyer escortetiler escortlevent escortbebek escortgaziosmanpaşa escortkartal escortbaşakşehir escortşişli escorthalkalı escortbahçelievler escortortaköy escorteyüp escortbahçeşehir escortkağıthane escorttaksim escortçekmeköy escortsultançiftliği escortşaşkınbakkal escortbayrampaşa escortbeylikdüzü escortkadıköy escortataşehir escortbakırköy escortmerter escortataköy escortnişantaşı escortkozyatağı escortavcılar escortbüyükçekmece escortkurtköy escortiçerenköy escortküçükyalı escortbostancı escortşirinevler escorterenköy escortadana escortadıyaman escortafyon escortağrı escortaksaray escortamasya escortankara escortantalya escortardahan escortartvin escortaydın escortbalıkesir escortbartın escortbatman escortbayburt escortbilecik escortbingöl escortbitlis escortbolu escortburdur escortbursa escortçanakkale escortçankırı escortçorum escortdenizli escortdiyarbakir escortdüzce escortedirne escortelazığ escorterzincan escorterzurum escorteskişehir escortantep escortgiresun escortgümüşhane escorthakkari escorthatay escortığdır escortistanbul escortizmir escortkarabük escortkaraman escortkars escortkastamonu escortkütahya escortkayseri escortkıbrıs escortkilis escortkırıkkale escortkırklareli escortkırşehir escortkocaeli escortkonya escortmalatya escortmanisa escortmaraş escortmardin escortmersin escortmuğla escortmuş escortnevşehir escortniğde escortordu escortosmaniye escortrize escortsakarya escortsamsun escortsiirt escortsinop escorthacklink seoBest Gaming Monitorswireless earbudsshapermint bra reviewsBest Dog Crateraycon reviewsbest stethoscopeinstagram beğeni hilesiinstagram unfollowinstagram takipci satın alinstagram Followers Freeinsagram Free Followerssmm panelsmm panelinstagram takipci hilesiinstagram Followersinstagram free likesinstagram takipci hilesiinstagram takipci hilesiinstagram takipci hilesiinstagram takipci hilesitatto girlsoyun indirmakale programımeme küçültmebacklink albacklink satıştempobettempobettempobet1xbetmarsbahisperabetmobilbahissuperbetinelexbetpaykwikrotabet1xbetjojobetsekabetbetistsafirbetsafirbetcasinomaxirestbetbaymavisultanbetcratosslotbetbooastropaytempobetdidim escortkadın newskadına özelworld newsizmir escortmersin escortataşehir escortataşehir escortbeşiktaş escortesenler escortesenyurt escortfatih escortkadıköy escortkartal escortmaltepe escortpendik escortsarıyer escortpendik escortmaltepe escortkartal escortkadıköy escorttaksim escortsilivri escortşişli escortbağcılar escortbursa escortantalya escortankara escortadana escortgaziantep escortseo analysisistanbul escortsex hikayeviagra satın alviagra fiyatıdegrawso shellc99 shellpendik escortastropayjojobet1xbetadana escortcanlı bahisadana eskortnevşehir escortbedava bonus veren bahis siteleribedava bonusdeneme bonusu30 tl bonus veren bahis sitelerihoşgeldin bonususex hikayeleriTürkçe Bahis Şirketlericanlı bahiskaçak iddaabahisbahis sitelerihoşgeldin bonusu veren bahis siteleriporno hikayeleristanbul escortc99 shellr57 shellbypass shellwebroot shellpendik escortvigrandedegra 100 mgorcafilcialis nedircialis 20 mg eczane fiyatıcialis fiyatcialis 20 mgcialis 100 mgviagra fiyatliftalifta 5 mghardciscialis eczanecialis 5 mg fiyatıcialis 100 mg fiyatcialis 5 mgviagra fiyatlarıviagra satışonline eczane viagraviagra eczanecialis 20 mgcialis 100 mgcialis hapcialis 20cialis eczanecialis satışcialis fiyatlarıcialis fiyatıviagra fiyatviagra fiyatlarıviagra eczaneviagra satın alpfizer viagra satışonline eczane viagrapfizer viagra satın alviagra siparişviagra sipariş hattıviagra fiyat 2021online viagra siparişviagra fiyat 2021 eczaneviagra fiyat eczanekartal escortcialis 5 mgkamagra satın alkamagrakamagra jelkamagra jel siparişkamagra siparişkamagra fiyatkamagra jel fiyatıkamagra fiyatıkamagra 100mgkamagra 100mg fiyatsüper kamagrakamagra nedirpendik escortkurtkoy escorttuzla escortkayseri escortmozrankGamelooplogsuz shell indirlitespeed bypass shellindoxploit shellphp shellgoogle sıra buluculitespeed bypass shellbacklink sorgulamaeryaman escortistanbul bayan escortbingöl escorthacklink satışbacklink satışhacklink panelhacklinkeskişehir escortkırklareli escortçekmeköy escortsancaktepe escortbodrum escortkuşadası escortc99 shellc99 shelllifta 20 mgliftalifta 20lifta 20 mg nedirlifta nedirhacklink seokarşıyaka escortbuca escortalsancak escortkonak escortkuşadası escortbeylikdüzü escortbornova escortçeşme escortgöztepe escort