CRUD App On Laravel

Laravel is a very robust php framework that is used to develop fully functional systems.

On Laravel reusability of code and functions is very simple and easy.

To Understand the Laravel PHP framework we must start from scratch and share on these posts.

Let’s start by creating a simple Laravel app and configuring it. To get more details about Laravel and how to create Laravel full documentation visit How to be Professional on Laravel https://bbn11.com/how-to-be-professional-on-laravel/ and get detailed concepts on leaves.

To Create a Laravel project use the following

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

description of some details about the above command

  • composer -> package managers of the project
  • create-project -> It is a command that is used to download or clone the Laravel framework from hosted sites
  • –prefer-dist -> package we have to use it
  • laravel/laravel is the version of the Laravel framework
  • laracrud the name of our project

Change your directory to your project name

cd laracrud

Then open your project with code editors

Code Structure of Laravel applications folder.

Laravel has it own code structures and folders

App folder contains the main functions of the Laravel setups

It contains the following folders and files

  • Console
  • Exceptions
  • HTTP
  • Models
  • Providers

Lets start typing the codes.

Create View by using Blade Laravel template

To create blade template we must understand the following things.

All view files are stored in the resources folder

Create folder views/layouts on views.

In the layouts folder create the file master_layout.blade.php

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>EMS</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
  </head>
<body>
  <nav class="navbar navbar-expand-lg bg-body-tertiary">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Home</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
</div>
  </div>
</nav>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
</script>
  </bod

The above code shows how to create blade files and include bootstrap on our projects.

How to Run Laravel Project by using terminals

php artisan serve

After typing the above command we get the following outputs.

INFO Server running on [http://127.0.0.1:8000].Press Ctrl+C to stop the server

How to Create Route?

To create route in Laravel we must go to the routes folder select web.php and add your routes to route list.. to get all the route list use the following command

php artisan route:list
<?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 view('layouts.master_layouts');
});

The above code shows how to create a route on Laravel setups

Route::get(‘home’,function(){} );

call the functions that render views of blade templates.

Author: bbnadmin

2 thoughts on “CRUD App On Laravel

  1. Hi there, i read your blog from time to time and i
    own a similar one and i was just wondering if you
    get a lot of spam remarks? If so how do you protect against it, any plugin or anything you can suggest?
    I get so much lately it’s driving me insane so any help is very much appreciated.

Leave a Reply

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