This project was made with the purpose of learning how to use Laravel.
The students of business BTS at Lycée Léonard de Vinci in Melun had to create a pop-up store to sell beekeeping products.
I was in charge of the website, so I decided to use Laravel to learn how to use it.
To get a local copy up and running follow these simple steps.
- Clone the repo
git clone https://github.com/Lasauce6/VinciShop.git && cd VinciShop
- Install Composer packages
composer install
- Create a copy of your .env file
cp .env.example .env
- Generate an app encryption key
php artisan key:generate
- Create an empty database for our application
For Mysql:
mysql -u root -p
CREATE DATABASE the_name_of_your_database;
For Sqlite:
touch database/database.sqlite
- In the .env file, add database information to allow Laravel to connect to the database
For Mysql:
DB_CONNECTION=mysql
DB_HOST=your_host
DB_PORT=your_port
DB_DATABASE=the_name_of_your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
For Sqlite:
DB_CONNECTION=sqlite
DB_DATABASE=your_database_path
- Create the tables in the databases
For Mysql:
CREATE TABLE produits (
id INTEGER PRIMARY KEY,
nom TEXT NOT NULL,
description TEXT NOT NULL,
prix DECIMAL(5,2) NOT NULL,
image TEXT NOT NULL,
qte INTEGER NOT NULL
);
CREATE TABLE commandes (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
prenom VARCHAR(40) NOT NULL,
nom VARCHAR(40) NOT NULL,
email VARCHAR(40) NOT NULL,
panier TEXT NOT NULL,
total DECIMAL(5,2) NOT NULL,
updated_at DATE NOT NULL,
created_at DATE NOT NULL
);
For Sqlite:
CREATE TABLE produits (
id INTEGER PRIMARY KEY,
nom TEXT NOT NULL,
description TEXT NOT NULL,
prix DECIMAL(5,2) NOT NULL,
image TEXT NOT NULL,
qte INTEGER NOT NULL
);
CREATE TABLE commandes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
prenom VARCHAR(40) NOT NULL,
nom VARCHAR(40) NOT NULL,
email VARCHAR(40) NOT NULL,
panier TEXT NOT NULL,
total DECIMAL(5,2) NOT NULL,
updated_at DATE NOT NULL,
created_at DATE NOT NULL
);
- Migrate the database
php artisan migrate
- Start the local development server
php artisan serve
-
You can now access the server at http://localhost:8000
-
To create admin credentials, uncomment the function createCreds() in the file app/Http/Controllers/AdminController.php and modify it to your needs. Uncomment the line 27 in the file routes/web.php and access the page http://localhost:8000/admin/createCreds. Then, comment the function createCreds() and the line 27 in the file routes/web.php.