Laravel 5 Admin Panel
In this tutorial, you are going to learn how to create a complete Laravel admin panel from scratch. We will use the beautiful open source admin panel Gentelella. Gentelella is a responsive HTML5 admin panel that is hosted on Git hub.
We will use Laravel version 5.3* for these tutorial series
Our admin panel will allow us to create, update, read and delete records from the database. We will also be able to upload images and implement many other features.
The image below shows you how the complete admin panel will look like
The above image is in Spanish but you can also localize it to English as shown in the image below
Topics to be covered
We will cover the following topics in tutorial;
- Tutorial prerequisites
- Topics to be covered in the tutorial series
- Creating a new Laravel 5.3* project
- Laravel new project configurations
- Tutorial Complete Code
This tutorial assumes;
- You understand the basics of Laravel 5. If you do then I recommend you start with these Laravel 5 Tutorial series.
- You have PHP, MySQL and a web server i.e. Apache up and running
- Laravel Homestead – this is optional but provides a great development environment. If you are new to Laravel homestead then I recommend you read the series on Laravel Homestead
- You have composer installed
- You have a text editor or IDE that supports PHP.
- You have a modern web browser that supports HTML5
- Git – this is optional but highly recommended. This tutorial has a repository on GitHub, with Git, you will be able to clone starter code for each tutorial.
Topics to be covered in the tutorial series
We will cover the following topics in these tutorial series.
- Laravel 5 Routing
- Laravel 5 Views
- Laravel 5 Eloquent Relationships
- Laravel 5 Validation
- Laravel 5 Exception Handling
- Laravel 5 Authentication and Authorization
- Laravel 5 Localization
- Laravel 5 File Uploading
- Laravel 5 Sending Email
- …and many more topics
Creating a new Laravel 5.3* project
I am using XAMPP on Windows 10 and I have installed xampp on drive
I will be using composer to create the new project
Open the terminal / command prompt and navigate to htdocs directory
Run the following command
composer create-project laravel/laravel laradmin 5.3.*
- composer create-project laravel/laravel tells composer to create a new Laravel project. laradmin specifies the directory that composer should use. 5.3.* tells composer to fetch the most recent minor update of Laravel of 5.3
We will be using Laravel’s built in web serve.
Run the following command
php artisan serve --port=8888
php artisan servestarts the built-in server
--port=8888specifies the port number that the serve should use. If you do not specify any port then Laravel will use port 8000.
Load the following URL in your web browser
You should be able to see the default Laravel home page.
Laravel new project configurations
In this section, we are going to configure our newly created project. Laravel already ships with sensible defaults. Laravel configuration files are stored in the
config directory. For our project, the complete path is
We will leave most of the settings as they are. We will configure the following settings for now.
- Time zone
- Application namespace
- Users model namespace
When creating records in the database, Laravel uses timestamps. Timestamps are generated based on the specified timezone.
By default, Laravel uses UTC time zone. I am in a +3 GMT time zone so I will set mine to Dar es Salaam Africa. Feel free to use the time zone that matches your zone. For a complete reference of supported time zones, refer to this link http://php.net/manual/en/timezones.php
Location the following line
'timezone' => 'UTC',
Update it to the following
'timezone' => 'Africa/Dar_es_Salaam',
That’s it for the time zone.
By default, Laravel uses
App as the namespace, it works fine but I prefer using a more description namespace for all my projects. The admin panel we are creating is for Larashop so we will use
Larashop as the application namespace.
We will use artisan to set the namespace
Run the following command
php artisan app:name Larashop
- php artisan app:name Larashop sets the application namespace to Larashop and updates all
Just to make sure that the application namespace has been updated, open the default controller in
The namespace of the Controller should be
Laravel automatically replaces the default namespace
App with the new one that you just set.
Users model namespace
By default, Laravel creates models in the app directory. Personal I prefer putting all the models in a Models directory that is inside the app directory. We will be doing the same here.
Create a new directory
Models in the
Move the user model from
Next open the file
Replace the namespace
with namespace Larashop\Models;
Laravel has built in authentication functionality that uses the default User model with the default namespace. We will need to update the namespace.
Open the authentication configuration file
Locate and replace the following code
'model' => Larashop\User::class,
With the following
'model' => Larashop\Models\User::class,
- We have updated the default namespace
Tutorial Complete Code
If you have git installed, run the following command to clone the complete tutorial project code
git clone -b 01_starter https://github.com/KodeBlog/Laradmin.git laradmin
git clone -b 01_starter https://github.com/KodeBlog/Laradmin.git laradminclones the branch 01_starter from the repository
https://github.com/KodeBlog/Laradmin.gitinto a local folder
Run the following command to browser to the root of the project
We will now use composer to install dependencies.
When the installation is completed, run the following artisan command
php artisan serve
In this tutorial, we created a new Laravel 5.3.* project, set the application namespace and configured the time zone and user model. We will be making more configurations as we proceed.
In the next tutorial, we will look at Laravel routing and some of the best practices. We will also create routes and controllers for our project.
Kode Blog Tutorials is dedicated to bring you update to date, high quality free tutorials. You can support us by using the social media buttons to like and share the tutorial and subscribing to our newsletter. Please use the comments section below to give us feedback.
You can sign up for a free account on our site and you will be able to keep track of your progress as you go through the tutorial series and get notifications when we publish new content.
This tutorial will show you how to create Eloquent ORM relationships and retrieve data based on relationships....readmore
This tutorial introdcues you to routing in Laravel and some of the best practices that you should know....readmore
This tutorial introduces you to blade template and how you can use it efficiently ...readmore
This tutorial introduces you to laravel validation using a real world example and best practices...readmore
This tutorial introduces you to exception handling using a real world example application and best practices...readmore
This tutorial shows you how to use artisan to scaffold authentication then customizing the authentication to meet your needs...readmore
This tutorial shows you how to implement user roles and permissions using a real world example...readmore