Product Management System By Laravel

Welcome back to bbn11. In these posts, I want to share step by step-by-step guide on the Laravel php framework with best example practices and share code.

Laravel is an open-source PHP framework that used to develop large and complex projects in an efficient manners

In these posts, we cover all the basic and advanced concepts of Laravel.

Contents we touch on cover post

  1. How to install Laravel
  2. How to configure with database
  3. How to create Route
  4. How to Create a Controller
  5. How to Create View Blade template
  6. How to Create Models
  7. How to Create tables
  8. Login and Logout Authentication
  9. How to add columns to a Database
  10. How to Migrate Database
  11. How to Create Relationships on Laravel
  12. How to create Middleware
  13. How to Add Flash Messages
  14. Handling Errors
  15. Validations

Let’s cover the above contents one by one based on project management System concepts.

How to install Laravel

Laravel is a very lightweight PHP framework, easy to learn, and easy to work with Laravel. Laravel has a simple command line interface called artisan. Artisan is used for accessing Laravel commands, and compiling Laravel projects and routes.

Installation of Laravel is an effortless and straightforward step.

We can install Laravel with one command line. To install Laravel use the below commands

composer create-project --prefer-dist laravel/laravel pms

After Installing the Laravel project we must change our directory to project folders.

cd pms
php artisan serve // used to run the project

When we run our project we get the below interfaces.

How to Configure Laravel with Database

Laravel configuration with database easy step and configure only in one file. Laravel Configuration may take less than one minute. To configure open your project by code editor you have and edit .env file.

DB_Database= Type the Database name want to create.

DB_USERNAME = Type Your server username

DB_PASSWORD= Type your server password

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pmsdb// change to your
DB_USERNAME=root
DB_PASSWORD=

Database configuration is updating the above code

How to create Route

Creating a route on Laravel is the main and basic thing to develop the system. Without a route, we can not run our project. No route No System at all. Route means pass and getways of our system.

To create a route in Laravel follow the following step.

step 1: select the routes folder and open it

Step 2: Open the web.php files

Add your route here by using the following methods

GET,POST,PUT,DELETE

GET = Selecting data or displaying data to the interface

POST= Submitting data to the database used for saving data to the database.

PUT= Used for Updating data for the database.

DELETE=Deleting data from data based/ used for removing data from the database.

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home',function ()
{
    return 'Welcome to Home Pages';
});

The above code shows how to create a route without any controllers.

We can also create routes by using controllers we first know how to create Controllers,

How to Create a Controller

Controller acting the main role on Laravels. On the controller, we write the basic logic of the system.

Create all functions on controllers, like index, create, store, update,destroy, and other functions as our system needs.

Commands used to create Controllers

PHP artisan make:controller ProductController -r

After Running the above we get below codes

 <?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
class ProductController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }
    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        //
    }
    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        //
    }
    /**
     * Display the specified resource.
     */
    public function show(string $id)
    {
        //
    }
    /**
     * Show the form for editing the specified resource.
     */
    public function edit(string $id)
    {
        //
    }
    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, string $id)
    {
        //
    }
    /**
     * Remove the specified resource from storage.
     */
    public function destroy(string $id)
    {
        //
    }
}

The above code shows all the basic and crud functions of the product controllers.

How to Create View Blade template

Laravel uses an HTML template called blade template. Blade template is easy to use and edit as HTML for developers. On the blade template, we can use Bootstrap or other what we want for front-end interfaces.

How to integrate Bootstrap Laravel

Bootstrap is the collection of CSS and JS files, bootstrap is free opensource resources

We can download Bootstrap free from get bootstrap and use it.

To use Bootstrap on Laravel follow the following step.

step 1: Download Bootstrap

Step 2: Extract bootstrap

Step 3: Copy the bootstrap file and paste it into public folders, use it.

Step 4: We can also bootstrap online by using cdn files.

Lates start coding now on blade template.

Select resources/views create a products folder and create a file list.blade.php

To create a Laravel blade use the extension aa.blade.php //

The above images show steps on how to create a view blade template on Laravel.

list.blade.php

In these blade templates design lists of products with their image and prices, easy to navigate and manage the product details.

Author: bbnadmin

1 thought on “Product Management System By Laravel

Leave a Reply

Your email address will not be published. Required fields are marked *