Laravel INT221 Project
Laravel INT221 Project
Date:1-Nov-23
Submitted To:
Dr. Karthick Panneerselvan
Submitted By:
Sreehari Vinod P
Reg No.12018861
Table of Contents
2
CLIENTAPPROVAL
EMAIL: [email protected]
SUMMARY: This document summarizes the software requirements for a Laravel CRUD
application for a supermarket. The purpose of this application is to provide a generic CRUD
interface for managing any type of data of client. The □
application will be easy to use and extensible,
and it will support common CRUD features such as create, read, update, and delete.
OUTCOME: CRUD app is a web application that allows users to create, read, update, and
delete data in a database. CRUD apps are often used to manage customer data, product data,
inventory data, and other types of data.
ACTION TO COMPLETION: Design and develop the user interface, ensuring that it is
intuitive and user-friendly. Implement the CRUD functionality, ensuring that it is secure,
performant, and scalable. Test the application thoroughly and deploy it to production.
BENEFITS: The application will be secure and will protect user data from unauthorized
access. It will also be performant and will be able to handle many concurrent users. The
application will be extensible and will be easy to customize to meet the specific needs of
different users.
REQUIREMENTS: Working laptop with any operating system installed, Web server: Apache
or Nginx PHP: PHP 8.0 or higher Database: MySQL, PostgreSQL, or SQLite.
ACCEPTANCE OF PROPOSAL
3
1. Introduction
A CRUD app is a type of software application that allows users to create, read, update, and
delete data. This is the most basic functionality that any database-driven application needs to
have. CRUD apps are used in a wide variety of industries, including e-commerce, social media,
and customer relationship management (CRM).
1.1 Purpose
Laravel is a popular PHP framework that makes it easy to develop web applications. One of
the core features of Laravel is its support for CRUD operations. CRUD stands for Create,
Read, Update, and Delete. These are the four basic operations that are needed to manage data
in a database.
Laravel provides several features that make it easy to develop CRUD apps, including:
By using Laravel, developers can quickly and easily build CRUD apps without having to
write a lot of boilerplate code.
4
1.2 Scope
The scope of Laravel CRUD is quite broad, and it can be used to develop a wide variety of
web applications, including:
• E-commerce websites
• Content management systems (CMS)
• Customer relationship management (CRM) systems
• Project management systems
• To-do list apps
• Contact manager apps
• Product catalog apps
• Social media websites
• News websites
• Blogs
• Forums
• and more!
Laravel CRUD is a powerful tool that can be used to develop a wide variety of web
applications, and it is a good choice for developers of all skill levels.
• Quick and easy to develop: Laravel CRUD provides several features that make it easy
to develop web applications quickly and easily. For example, Laravel's Eloquent
ORM makes it easy to interact with databases, and Laravel's built-in routing and
controller system makes it easy to define routes for CRUD operations.
• Secure and scalable: Laravel CRUD is designed to be secure and scalable. Laravel's
built-in security features help to protect web applications from common attacks, and
Laravel's architecture makes it easy to scale applications to meet the needs of
growing businesses.
• Flexible and customizable: Laravel CRUD is a flexible and customizable framework.
Laravel provides several hooks and extension points that allow developers to
customize the framework to meet the specific needs of their web applications.
• Large community and support: Laravel has a large and active community of developers
who are always willing to help new users. Laravel also has several resources
available, such as documentation, tutorials, and video courses, that can help
developers learn more about the framework.
5
• CRM: Customer Relationship Management
• PHP: Hypertext Pre-processor
• SQL: Structured Query Language
• REST: Representational State Transfer
1.4 References
1.5 Overview
Laravel CRUD is a good choice for developing a wide variety of web applications, including
e-commerce websites, content management systems, customer relationship management
systems, and project management systems.
6
2. Product Description
Laravel CRUD App for Supermarket
Overview
This Laravel CRUD app is designed to help supermarkets manage their inventory, orders,
and customers. It is a powerful and flexible tool that can be customized to meet the specific
needs of any supermarket.
Features
The Laravel CRUD app for supermarkets includes the following features:
Inventory management: The app allows users to track their inventory levels, add new
products, and edit product information.
Order management: The app allows users to place and manage orders, and to track the
status of orders.
Customer management: The app allows users to create and manage customer accounts, and
to track customer purchase history.
Benefits
The Laravel CRUD app for supermarkets offers several benefits, including:
Increased efficiency: The app can help supermarkets to be more efficient by automating tasks
such as inventory management and order processing.
Reduced errors: The app can help to reduce errors by providing users with a consistent and
easy-to-use interface for managing data.
Improved customer service: The app can help supermarkets to improve customer service by
providing them with a way to track customer purchase history and to place orders on behalf
of customers.
How to Use
The Laravel CRUD app for supermarkets is easy to use. Users can simply log in to the app
and start managing their inventory, orders, and customers. The app provides a user-friendly
interface that makes it easy to add, edit, and delete data.
Customization
The Laravel CRUD app for supermarkets is customizable to meet the specific needs of any
supermarket. Developers can add new features, change the look and feel of the app, and
integrate the app with other systems.
7
Conclusion
The Laravel CRUD app for supermarkets is a powerful and flexible tool that can help
supermarkets to be more efficient, reduce errors, and improve customer service. It is a good
choice for supermarkets of all sizes.
Problem: A supermarket needs a way to manage its inventory, products, and sales. The
current system is manual and time-consuming, and it is difficult to track data accurately.
Solution: A Laravel CRUD app can provide a centralized solution for managing all of the
supermarket's data. The app can be used to create, read, update, and delete product
information, inventory levels, and sales data. The app can also be used to generate reports on
inventory levels, sales trends, and other important metrics.
A Laravel CRUD app for a supermarket can have the following product functions:
Create:
• Create new products with details including product name, description, price, quantity,
category, image, etc.
• Create variations of products with different sizes, colours, flavours, etc.
• Create product bundles and promotions.
Read:
• View a list of all products in the supermarket.
• View the details of a specific product, including its variations and bundles.
• Search for products by name, category, price, etc.
• View the sales history of a product.
Update:
• Update the details of a product, including its name, description, price, quantity,
category, image, etc.
• Update the details of a product variation, such as its size, color, flavor, price, etc.
• Update the details of a product bundle or promotion.
• Update the sales price of a product.
Delete:
• Delete a product from the supermarket.
• Delete a product variation from a product.
• Delete a product bundle or promotion.
The Laravel CRUD app for a supermarket can be customized to meet the specific needs of the
supermarket. For example, the app can be integrated with the supermarket's point-of-sale
8
system to automate the sales process. The app can also be integrated with the supermarket's
loyalty program to allow customers to earn and redeem rewards for their purchases.
2.3 User Characteristics
Access control: The app should provide different access levels for different user groups. For
example, store managers should have access to all the features of the app, while cashiers
should only have access to the features that they need to perform their jobs.
Ease of use: The app should be easy to use and navigate for all users, regardless of their
technical expertise.
Performance: The app should be able to handle many users and transactions simultaneously.
Security: The app should be secure and protect user data from unauthorized access.
Scalability: The app should be able to scale to meet the needs of a growing supermarket.
The specific requirements and dependencies for a Laravel CRUD app will vary depending on
the specific needs of the app. However, there are some general requirements and
dependencies that are common to all Laravel CRUD apps.
Requirements:
Laravel framework
PHP interpreter (version 7.3 or higher)
MySQL database (version 5.7 or higher)
Composer dependency manager
Dependencies:
Eloquent ORM
Laravel routing system
Laravel controller system
Laravel view system
The specific requirements and dependencies for a Laravel CRUD app for a supermarket will
vary depending on the size and complexity of the supermarket.
9
3. Code and Functionality
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
Use App\Models\Product;
return view('products.index',[
'products' => Product::latest()-> paginate(5)]);
}
//validate data
$request -> validate([
'name' => 'required',
'description' => 'required',
'image' => 'required|mimes:jpeg,png,jpg,gif|max:10000'
]);
$product ->save();
return back()->withSuccess('Product created successfully!');
10
public function edit($id){
$product = Product::where('id',$id)->first();
return view('products.edit',['product' => $product]);
//validate data
$request -> validate([
'name' => 'required',
'description' => 'required',
'image' => 'nullable|mimes:jpeg,png,jpg,gif|max:10000'
]);
$product = Product::where('id',$id)->first();
$product ->save();
return back()->withSuccess('Product updated successfully!');
11
To use the Laravel paginator, you first need to get the results of your database query. You
can do this using the Eloquent ORM or the Query Builder. Once you have the results of your
query, you can use the paginate () method to paginate the results.
The paginate () method takes two arguments: the number of results to display per page and
the current page number. If the current page number is not specified, the paginator will
assume that the current page is the first page.
App.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Laravel CRUD With Image</title>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script
>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js">
</script>
</head>
<body>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link text-light" href="/">Products</a>
</li>
</ul>
</nav>
@if($message = Session::get('success'))
<div class="alert alert-success alert-block">
<strong>{{$message}}</strong>
</div>
@endif
12
@yield('main')
</body>
</html>
Inside the view folder two folders are created named public and layouts, in the layouts code
the code that is reused in the web page is saved under the name app.blade.php
Product Folder
Inside the product folder under the view there is index.blade.php, create.blade.php,
edit.blade.php
Index.balde.php
@extends('layouts.app')
@section('main')
<div class="container">
<div class="text-right">
<a href="products/create" class="btn btn-dark mt-2">New Products</a>
</div>
13
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</td>
</td>
</tr>
@endforeach
</tbody>
</table>
{{$products -> links()}}
<!-- Pagination -->
</div>
@endsection
Creat.blade.php
@extends('layouts.app')
@section('main')
<div class="container">
<div class="row justify-content-center">
<div calss="col-sm-8">
<div class="card mt-3 p-3">
<form method="POST" action="/products/store" enctype="multipart/form-
data">
@csrf
<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control"
value="{{old('name')}}">
@if($errors->has('name'))
<span class="text-danger">{{ $errors->first('name') }}</span>
@endif
</div>
<div class="form-group">
<label>Description</label>
<textarea class="form-control" rows="4" name="description"
value="{{old('description')}}"></textarea>
@if($errors->has('description'))
<span class="text-danger">{{ $errors->first('description') }}</span>
@endif
</div>
<div class="form-group">
<label>Image</label>
<input type="file" name="image" class="form-control"
value="{{old('image')}}"/>
14
@if($errors->has('image'))
<span class="text-danger">{{ $errors->first('image') }}</span>
@endif
</div>
</form>
</div>
</div>
</div>
</div>
@endsection
Show.blade.php
@extends ('layouts.app')
@section ('main')
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-8 mt-4">
<div class="card p-4">
<p>Name : <b>{{ $product->name }}</b></p>
<p>Description : <b>{{ $product->description }}</b></p>
<img src="/products/{{ $product->image }}" class="rounded"
width="100%"/>
</div>
</div>
</div>
</div>
@endsection
Edit.blade.php
@extends('layouts.app')
@section('main')
<div class="container">
<div class="row justify-content-center">
<div calss="col-sm-8">
<div class="card mt-3 p-3">
<h3 class="text-muted">Product Edit #{{$product->name}}</h3>
15
<form method="POST" action="/products/{{ $product->id }}/update"
enctype="multipart/form-data">
@csrf
@method ('PUT')
<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control"
value="{{old('name',$product->name)}}">
@if($errors->has('name'))
<span class="text-danger">{{ $errors->first('name') }}</span>
@endif
</div>
<div class="form-group">
<label>Description</label>
<textarea class="form-control" rows="4"
name="description">"{{old('description',$product->description)}}"</textarea>
@if($errors->has('description'))
<span class="text-danger">{{ $errors->first('description') }}</span>
@endif
</div>
<div class="form-group">
<label>Image</label>
<input type="file" name="image" class="form-control"
value="{{old('image')}}"/>
@if($errors->has('image'))
<span class="text-danger">{{ $errors->first('image') }}</span>
@endif
</div>
</form>
</div>
</div>
</div>
</div>
@endsection
16
3.2 Conclusion
A Laravel CRUD app can be a valuable tool for improving the efficiency and profitability of
a supermarket. It can help to streamline the process of managing products, inventory, sales,
and customers.
Here are some of the benefits of using a Laravel CRUD app for a supermarket:
Improved efficiency: A Laravel CRUD app can help to improve the efficiency of supermarket
operations by automating tasks such as product management, inventory tracking, and sales
reporting.
Reduced costs: A Laravel CRUD app can help to reduce the costs of running a supermarket
by automating tasks that would otherwise be performed manually.
Increased sales: A Laravel CRUD app can help to increase sales by providing customers
with a convenient and user-friendly way to browse and purchase products.
Improved customer satisfaction: A Laravel CRUD app can help to improve customer
satisfaction by providing a positive shopping experience.
Overall, a Laravel CRUD app is a good choice for supermarkets of all sizes. It can help to
improve efficiency, reduce costs, increase sales, and improve customer satisfaction.
17