Laravel implementation of backend for popular game called 'Minesweeper' made by Robert Donner.
OxiSweeperBackend implements application user interface and database for user authentication, authorization and record tracking.
OxiSweeperFrontend implements the Minesweeper game itself and routing for users depending of theirs role.
To run the project you need to have followed software installed:
- Clone the repository:
git clone https://github.com/karolstawowski/OxiSweeperBackend
- Create
.env
file based on.env.example
copy .env.example .env
-
Run Apache and MySQL server using Xampp
-
Create new database (default database name:
minesweeper
) -
Migrate the database:
php artisan migrate
- Seed the database with records:
php artisan db:seed
To run the project use
php artisan serve
command in the root directory of the repositorium.
- User enters log in/register page
- User logs in/creates new accout
- User is redirected to route based on role -
/game
or/dashboard
- User can log out, which redirects to
/login
page
When user logs in or registers, user token is being assigned. User token is stored on the client side in cookies.
Every time user enters any page, request for user role to backend is being sent. User role is stored in frontend application's context.
Unauthorized user is being redirected to allowed path. Unauthenticated user can access /login
path only.
CREATE TABLE `scores` (
`id` bigint(20) UNSIGNED NOT NULL PRIMARY KEY,
`score` int(11) NOT NULL,
`user_id` bigint(20) UNSIGNED NOT NULL FOREIGN KEY,
`difficulty_level` enum('1','2','3') COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `users` (
`id` bigint(20) UNSIGNED NOT NULL PRIMARY KEY,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`user_role_id` bigint(20) UNSIGNED NOT NULL DEFAULT 2 FOREIGN KEY,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `user_roles` (
`id` bigint(20) UNSIGNED NOT NULL PRIMARY KEY,
`role_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
- POST /register
- POST /login
- GET /users
- GET /scores
- GET /score/top/{user_token}/{difficulty_level}
- POST /role
- POST /user
- POST /score
- POST /logout
PHP, Laravel, Sanctum, Eloquent ORM.