Version 1.0 #102

Merged
FernandoJVideira merged 163 commits from develop into master 2026-01-03 14:49:00 +00:00
286 changed files with 24523 additions and 116 deletions
Showing only changes of commit a335e713ee - Show all commits
+78 -115
View File
@@ -1,138 +1,101 @@
# ---> Node # -------------------------
# Logs # Project-level .gitignore
logs # Root: DADProject
*.log # -------------------------
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html) # macOS
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json .DS_Store
# Runtime data # parcel / next / nuxt / vite / etc caches
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache .cache
.parcel-cache .parcel-cache
# Next.js build output
.next .next
out
# Nuxt.js build / generate output
.nuxt .nuxt
dist dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist .vuepress/dist
# vuepress v2.x temp and cache directory
.temp .temp
.cache
# vitepress build output
**/.vitepress/dist **/.vitepress/dist
# vitepress cache directory
**/.vitepress/cache **/.vitepress/cache
# Docusaurus cache and generated files
.docusaurus .docusaurus
# Serverless directories
.serverless/ .serverless/
# FuseBox cache
.fusebox/ .fusebox/
# DynamoDB Local files
.dynamodb/ .dynamodb/
# TernJS port file
.tern-port .tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test .vscode-test
# yarn v2
.yarn/cache .yarn/cache
.yarn/unplugged .yarn/unplugged
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# -------------------------
# Frontend: Vue (in frontend/)
# -------------------------
# Node deps and build output for the Vue app
/frontend/node_modules/
/frontend/dist/
/frontend/build/
/frontend/.cache/
/frontend/.vite/
/frontend/.serverless/
/frontend/.vscode/
# Vue / Vite / Vue CLI env files (local)
frontend/.env
frontend/.env.local
frontend/.env.*.local
# Misc frontend files that should be ignored
/frontend/public/hot
/frontend/public/storage
# -------------------------
# Backend: PHP / Laravel (in api/)
# -------------------------
/api/vendor/
/api/node_modules/
/api/vscode/
/api/.env
/api/.env.*.local
# Laravel storage and compiled files
/api/storage/
/api/storage/*.key
/api/public/storage
/api/bootstrap/cache/*.php
# Homestead / vagrant
/api/.vagrant
/api/Homestead.yaml
/api/Homestead.json
# composer
/api/.composer/
/api/.composer-cache
# Laravel specific tooling
/api/.phpunit.result.cache
# -------------------------
# Websockets: NodeJs (in websockets)
# -------------------------
/websockets/node_modules/
# -------------------------
# Other useful ignores
# -------------------------
# Generated environment files used by editors/OS
Thumbs.db
ehthumbs.db
Desktop.ini
# Logs and runtime files
*.log
*.tmp
*.temp
# Certificate/key files
*.pem
*.key
# If you have any local secrets or files not to track, add them here:
# /path/to/some/file
+253 -1
View File
@@ -1,2 +1,254 @@
# DADProject # DAD Project - Bisca Game Platform
## Overview
The DAD project aims to develop and deploy the **Bisca Game Platform** as a web application. The platform is a distributed system that provides users with the ability to play the traditional Portuguese card game Bisca in single-player and multiplayer modes, manage their coins, and track their gaming statistics.
The web client is implemented as a **Single-Page Application (SPA)** built with **Vue.js** and hosted on the designated internal school server. The backend system includes a database, a RESTful API server, and a WebSocket server for real-time multiplayer gameplay.
## Project Architecture
### Frontend
- **Technology**: Vue.js SPA
- **Purpose**: User interface for game play, user management, coin transactions, and statistics visualization
- **Features**: Real-time game updates via WebSockets, responsive design, player profiles, leaderboards
### Backend
- **RESTful API Server**: Handles user authentication, coin transactions, game history, leaderboards, and administrative operations
- **WebSocket Server**: Manages real-time multiplayer game communication, ensuring the server acts as the authoritative source for game state
- **Database**: Persists user data, game results, transactions, and platform statistics
## Constraints
The project must adhere to the following mandatory constraints:
1. **Single-Page Application (SPA)** - The application must be implemented exclusively as an SPA
2. **Vue.js Requirement** - The client application must be built with Vue.js
3. **Payment Gateway Integration** - All external coin purchases must be processed via the provided RESTful API (Payment Gateway Service)
4. **Deployment** - The application must be deployed on the designated internal school server and be accessible via a desktop web browser
5. **Backend Technologies** - Must be open-source or available as free external services
6. **Server Compatibility** - Backend technologies must be installable on or accessible from the designated server; if not supported, compliant alternatives must be selected
7. **Database Seeding** - The deployed application's database must be seeded with realistic data in both scale and content to simulate typical usage patterns
## Core Features
### 1. User Management
- **Registration**: Users register with email, nickname, name, password (minimum 3 characters), and optional photo/avatar
- **Authentication**: Email and password-based login
- **Profile Management**: View and update profile information, change password
- **Sign Out**: Users can end their session
- **Account Deletion**: Requires explicit confirmation; permanently forfeits all coins
- **Welcome Bonus**: New users receive 10 coins upon registration
- **Admin Accounts**: Created only by existing administrators; same profile capabilities as users but cannot delete their own accounts
### 2. Coins and Transactions
- **Coin Balance**: Users can view their current coin balance
- **Coin Purchases**: External purchases via Payment Gateway Service
- **Conversion Rate**: €1 = 10 coins (purchases in €1 increments)
- **Coin Earning**: Players earn coins through gameplay and bonuses
- **Transaction History**: All coin-related transactions (bonuses, purchases, spending, earnings) are logged
- **History Access**:
- Players view only their own transaction history
- Administrators have read-only access to all players' histories
- Administrators cannot create, modify, or delete transactions
### 3. Games and Matches
#### Game Variants
- **Bisca de 3**: Three-card hands
- **Bisca de 9**: Nine-card hands
#### Game Modes
- **Single-Player**: Against a bot (available to anonymous and registered users)
- **Multiplayer**: Against human opponents (available only to registered users)
- **Match**: Best-of series (up to 4 marks/wins) with two players
#### Game Rules
- Games and matches are limited to two players
- The bot follows game rules and attempts to win when playing second; otherwise plays its lowest-value card
- Official Bisca rules apply (as defined in the "Bisca Game" documentation)
#### Multiplayer Gameplay
- **Real-Time Communication**: WebSockets for live game updates
- **Server Authority**: The server is the source of truth for:
- Card dealing
- Turn order
- Valid moves
- Trick resolution
- Drawing from stock
- Scoring
- End-of-game/match conditions
- **Move Timer**: 20-second limit per move
- **Resignation**:
- Opponent awarded all remaining cards
- Game ends immediately
- If in a match, player forfeits all remaining games
- Scores computed accordingly
- **Persistent Results**: Game and match results with metadata are persisted for user history and administrative access
### 4. Game History and Leaderboards
#### Tracking
- **Scope**: Only multiplayer games and matches are tracked
- **Metadata**: Start/end timestamps, variant, outcome (win/loss/draw/forfeit), final points, marks (capote, bandeira), duration
#### History Access
- **Players**: View only their own multiplayer history
- **Administrators**: Read-only access to all players' histories and detailed records
- **Detailed Records**: Visible only to administrators and participating players
#### Leaderboards
- **Personal Leaderboards**: Visible only to the owner; summarize totals for game wins, match wins, capotes, and bandeiras (optionally segmented by variant)
- **Global Leaderboards**: Visible to all users including anonymous visitors; highlight top players by game and match wins, may include capotes and bandeiras
- **Tie-Breaking**: Earlier achievers rank higher in case of ties
### 5. Administration
#### Administrator Capabilities
- **Profile Management**: Same as regular users, except cannot delete their own accounts
- **Account Management**: Create new administrator accounts, remove any account except their own
- **Soft Deletion**: Player accounts with prior activity must be soft-deleted
- **User Monitoring**: View all users (players and administrators), block/unblock players
- **Read-Only Access**:
- All transactions
- All multiplayer games and matches
- Platform usage summaries and statistics
#### Administrator Access Control
- Cannot play games or hold coins
- New administrator accounts can only be created by existing administrators
### 6. Statistics and Reporting
#### Anonymous Users and Players
- Access only generic, anonymized aggregates:
- Total registered players
- Games and matches played
- Recent activity summaries
#### Administrators
- Full, non-anonymized access including:
- Purchases by period and player
- Game/match volumes
- User activity breakdowns
- Time-series data
#### Visualization
- Statistics available in both visual (charts) and textual/tabular forms
- Privacy for non-admin viewers is preserved
- Exact metrics and visualizations are team-defined
## Enhancement and Innovation Opportunities
To distinguish this project, consider implementing one or more of the following:
### Custom Features (Examples)
- Support for three or more players per game (optional extension while preserving two-player mode)
- Spectator mode for multiplayer games and matches
- Full playback of past games
- Custom card sets
- Extended bot capabilities (e.g., improved AI strategies)
- Integration of bots into multiplayer games
### Architecture and Performance Enhancements (Examples)
- Queue server or worker for asynchronous, long-running operations
- Horizontal scaling of the WebSocket server
- Session recovery after WebSocket or node failures
- Cache server implementation
- NoSQL database for specific use cases
- Search engine for game history or statistics
- Asynchronous messaging broker (e.g., Kafka, RabbitMQ)
- Distributed components for improved scalability and resilience
### Implementation Quality
- Use of technologies or techniques not covered in standard coursework
- Performance optimization with empirical benchmarks
- Improved architecture and code structure
- Enhanced implementation quality and documentation
**Note**: Credit is proportional to demonstrated impact with preference given to distributed capabilities that improve architecture, scalability, or resilience.
## Technology Stack
### Frontend
- Vue.js (mandatory)
- Vite (build tool)
- ESLint (code quality)
### Backend
- **API Server**: Open-source, student-selected technology
- **WebSocket Server**: Open-source, student-selected technology
- **Database**: Open-source, student-selected technology
- All must be compatible with the designated school server
### Supported Variants
- Laravel (PHP) for REST API
- Node.js for WebSocket server
## Project Structure
```
DADProject/
├── api/ # Laravel REST API backend
├── frontend/ # Vue.js SPA
├── websockets/ # WebSocket server
└── README.md # This file
```
## Getting Started
Refer to the individual `README.md` files in each directory for setup and deployment instructions:
- [API Documentation](./api/README.md)
- [Frontend Documentation](./frontend/README.md)
- [WebSocket Server Documentation](./websockets/README.md)
## Database Schema
The application's database includes the following primary entities:
- **Users**: Player and administrator accounts
- **Games**: Individual game records (both single-player and multiplayer)
- **Matches**: Match records (series of games)
- **Coin Transactions**: Purchase and spending history
- **Coin Transaction Types**: Transaction categorization
- **Coin Purchases**: External purchase records
- **Leaderboard Data**: Aggregated player statistics
For detailed schema information, refer to the database migrations in the `api/database/migrations/` directory.
## Key Business Rules
1. **Coin System**:
- New users receive 10 welcome coins
- Conversion rate: €1 = 10 coins
- Coin purchases are made in €1 increments
- All transactions are logged and immutable (except soft-deleted accounts)
2. **Game Rules**:
- Two-player games only (in standard mode)
- Bot cannot be played in multiplayer
- 20-second move timer in multiplayer
- Resignation forfeits remaining games in a match
3. **Account Management**:
- Administrators cannot be created via public registration
- Administrators cannot delete their own accounts
- Account deletion requires explicit confirmation
- Soft deletion preserves historical data for deleted player accounts
4. **Leaderboard Ranking**:
- Multiplayer games and matches only
- Ties resolved by earlier achievement date
## Notes for Developers
- The WebSocket server acts as the authoritative source for all game state in multiplayer games
- Ensure proper error handling and recovery for WebSocket disconnections
- All coin transactions must be atomic and immutable
- Database must be seeded with realistic, varied data
- Privacy and data protection must be maintained throughout
## License
This project is part of the EI DAD 2025/26 course.
+18
View File
@@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
[compose.yaml]
indent_size = 4
+65
View File
@@ -0,0 +1,65 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
# PHP_CLI_SERVER_WORKERS=4
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
# CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
+11
View File
@@ -0,0 +1,11 @@
* text=auto eol=lf
*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
+24
View File
@@ -0,0 +1,24 @@
*.log
.DS_Store
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/.fleet
/.idea
/.nova
/.phpunit.cache
/.vscode
/.zed
/auth.json
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
Homestead.json
Homestead.yaml
Thumbs.db
+59
View File
@@ -0,0 +1,59 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
<p align="center">
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
### Premium Partners
- **[Vehikl](https://vehikl.com)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
- **[Redberry](https://redberry.international/laravel-development)**
- **[Active Logic](https://activelogic.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required',
]);
if (! Auth::attempt($request->only('email', 'password'))) {
throw ValidationException::withMessages([
'email' => ['The provided credentials are incorrect.'],
]);
}
$user = Auth::user();
$token = $user->createToken('auth-token')->plainTextToken;
return response()->json([
'user' => $user,
'token' => $token,
]);
}
public function logout(Request $request)
{
$request->user()->currentAccessToken()->delete();
return response()->json([
'message' => 'Logged out successfully',
]);
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}
@@ -0,0 +1,87 @@
<?php
namespace App\Http\Controllers;
use App\Models\Game;
use Illuminate\Http\Request;
class GameController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$query = Game::query()->with(['winner']);
if ($request->has('type') && in_array($request->type, ['3', '9'])) {
$query->where('type', $request->type);
}
if ($request->has('status') && in_array($request->status, ['Pending', 'Playing', 'Ended', 'Interrupted'])) {
$query->where('status', $request->status);
}
// Sorting
$sortField = $request->input('sort_by', 'began_at');
$sortDirection = $request->input('sort_direction', 'desc');
$allowedSortFields = [
'began_at',
'ended_at',
'total_time',
'type',
'status'
];
if (in_array($sortField, $allowedSortFields)) {
$query->orderBy($sortField, $sortDirection === 'asc' ? 'asc' : 'desc');
}
// Pagination
$perPage = $request->input('per_page', 15);
$games = $query->paginate($perPage);
return response()->json([
'data' => $games->items(),
'meta' => [
'current_page' => $games->currentPage(),
'last_page' => $games->lastPage(),
'per_page' => $games->perPage(),
'total' => $games->total()
]
]);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(Game $game)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Game $game)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Game $game)
{
//
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Game extends Model
{
public function winner()
{
return $this->belongsTo(User::class, "winner_user_id");
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable, HasApiTokens;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
use Illuminate\Foundation\Application;
use Symfony\Component\Console\Input\ArgvInput;
define('LARAVEL_START', microtime(true));
// Register the Composer autoloader...
require __DIR__.'/vendor/autoload.php';
// Bootstrap Laravel and handle the command...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$status = $app->handleCommand(new ArgvInput);
exit($status);
+19
View File
@@ -0,0 +1,19 @@
<?php
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
//
})
->withExceptions(function (Exceptions $exceptions): void {
//
})->create();
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+58
View File
@@ -0,0 +1,58 @@
<?php return array (
'laravel/pail' =>
array (
'providers' =>
array (
0 => 'Laravel\\Pail\\PailServiceProvider',
),
),
'laravel/sail' =>
array (
'providers' =>
array (
0 => 'Laravel\\Sail\\SailServiceProvider',
),
),
'laravel/sanctum' =>
array (
'providers' =>
array (
0 => 'Laravel\\Sanctum\\SanctumServiceProvider',
),
),
'laravel/tinker' =>
array (
'providers' =>
array (
0 => 'Laravel\\Tinker\\TinkerServiceProvider',
),
),
'nesbot/carbon' =>
array (
'providers' =>
array (
0 => 'Carbon\\Laravel\\ServiceProvider',
),
),
'nunomaduro/collision' =>
array (
'providers' =>
array (
0 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
),
),
'nunomaduro/termwind' =>
array (
'providers' =>
array (
0 => 'Termwind\\Laravel\\TermwindServiceProvider',
),
),
'pestphp/pest-plugin-laravel' =>
array (
'providers' =>
array (
0 => 'Pest\\Laravel\\PestServiceProvider',
),
),
);
+262
View File
@@ -0,0 +1,262 @@
<?php return array (
'providers' =>
array (
0 => 'Illuminate\\Auth\\AuthServiceProvider',
1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
2 => 'Illuminate\\Bus\\BusServiceProvider',
3 => 'Illuminate\\Cache\\CacheServiceProvider',
4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
5 => 'Illuminate\\Concurrency\\ConcurrencyServiceProvider',
6 => 'Illuminate\\Cookie\\CookieServiceProvider',
7 => 'Illuminate\\Database\\DatabaseServiceProvider',
8 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
9 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
10 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
11 => 'Illuminate\\Hashing\\HashServiceProvider',
12 => 'Illuminate\\Mail\\MailServiceProvider',
13 => 'Illuminate\\Notifications\\NotificationServiceProvider',
14 => 'Illuminate\\Pagination\\PaginationServiceProvider',
15 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
16 => 'Illuminate\\Pipeline\\PipelineServiceProvider',
17 => 'Illuminate\\Queue\\QueueServiceProvider',
18 => 'Illuminate\\Redis\\RedisServiceProvider',
19 => 'Illuminate\\Session\\SessionServiceProvider',
20 => 'Illuminate\\Translation\\TranslationServiceProvider',
21 => 'Illuminate\\Validation\\ValidationServiceProvider',
22 => 'Illuminate\\View\\ViewServiceProvider',
23 => 'Laravel\\Pail\\PailServiceProvider',
24 => 'Laravel\\Sail\\SailServiceProvider',
25 => 'Laravel\\Sanctum\\SanctumServiceProvider',
26 => 'Laravel\\Tinker\\TinkerServiceProvider',
27 => 'Carbon\\Laravel\\ServiceProvider',
28 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
29 => 'Termwind\\Laravel\\TermwindServiceProvider',
30 => 'Pest\\Laravel\\PestServiceProvider',
31 => 'App\\Providers\\AppServiceProvider',
),
'eager' =>
array (
0 => 'Illuminate\\Auth\\AuthServiceProvider',
1 => 'Illuminate\\Cookie\\CookieServiceProvider',
2 => 'Illuminate\\Database\\DatabaseServiceProvider',
3 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
4 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
5 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
6 => 'Illuminate\\Notifications\\NotificationServiceProvider',
7 => 'Illuminate\\Pagination\\PaginationServiceProvider',
8 => 'Illuminate\\Session\\SessionServiceProvider',
9 => 'Illuminate\\View\\ViewServiceProvider',
10 => 'Laravel\\Pail\\PailServiceProvider',
11 => 'Laravel\\Sanctum\\SanctumServiceProvider',
12 => 'Carbon\\Laravel\\ServiceProvider',
13 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
14 => 'Termwind\\Laravel\\TermwindServiceProvider',
15 => 'Pest\\Laravel\\PestServiceProvider',
16 => 'App\\Providers\\AppServiceProvider',
),
'deferred' =>
array (
'Illuminate\\Broadcasting\\BroadcastManager' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Contracts\\Broadcasting\\Factory' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Contracts\\Broadcasting\\Broadcaster' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Contracts\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Contracts\\Bus\\QueueingDispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Bus\\BatchRepository' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Bus\\DatabaseBatchRepository' => 'Illuminate\\Bus\\BusServiceProvider',
'cache' => 'Illuminate\\Cache\\CacheServiceProvider',
'cache.store' => 'Illuminate\\Cache\\CacheServiceProvider',
'cache.psr6' => 'Illuminate\\Cache\\CacheServiceProvider',
'memcached.connector' => 'Illuminate\\Cache\\CacheServiceProvider',
'Illuminate\\Cache\\RateLimiter' => 'Illuminate\\Cache\\CacheServiceProvider',
'Illuminate\\Foundation\\Console\\AboutCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Cache\\Console\\ClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Cache\\Console\\ForgetCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ClearCompiledCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Auth\\Console\\ClearResetsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConfigCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConfigClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConfigShowCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\DbCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\MonitorCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\PruneCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\ShowCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\TableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\WipeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\DownCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EnvironmentCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EnvironmentDecryptCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EnvironmentEncryptCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EventCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EventClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EventListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Concurrency\\Console\\InvokeSerializedClosureCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\KeyGenerateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\OptimizeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\OptimizeClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\PackageDiscoverCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Cache\\Console\\PruneStaleTagsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ListFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\FlushFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ForgetFailedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\ListenCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\MonitorCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\PruneBatchesCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\PruneFailedJobsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RestartCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RetryCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\RetryBatchCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\WorkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RouteListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\DumpCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Seeds\\SeedCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleFinishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleRunCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleClearCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleTestCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleWorkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleInterruptCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\ShowModelCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\StorageLinkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\StorageUnlinkCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\UpCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ViewCacheCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ViewClearCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ApiInstallCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\BroadcastingInstallCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Cache\\Console\\CacheTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\CastMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ChannelListCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ChannelMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ClassMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ComponentMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConfigMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConfigPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ConsoleMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Routing\\Console\\ControllerMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\DocsCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EnumMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EventGenerateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\EventMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ExceptionMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Factories\\FactoryMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\InterfaceMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\JobMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\JobMiddlewareMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\LangPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ListenerMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\MailMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Routing\\Console\\MiddlewareMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ModelMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\NotificationMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Notifications\\Console\\NotificationTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ObserverMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\PolicyMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ProviderMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\FailedTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\TableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Queue\\Console\\BatchesTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RequestMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ResourceMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\RuleMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ScopeMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Seeds\\SeederMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Session\\Console\\SessionTableCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ServeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\StubPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\TestMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\TraitMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\VendorPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Foundation\\Console\\ViewMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migration.repository' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migration.creator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Migrations\\Migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\MigrateCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\FreshCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\InstallCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\RefreshCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\ResetCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\RollbackCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\StatusCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Database\\Console\\Migrations\\MigrateMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'composer' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Concurrency\\ConcurrencyManager' => 'Illuminate\\Concurrency\\ConcurrencyServiceProvider',
'hash' => 'Illuminate\\Hashing\\HashServiceProvider',
'hash.driver' => 'Illuminate\\Hashing\\HashServiceProvider',
'mail.manager' => 'Illuminate\\Mail\\MailServiceProvider',
'mailer' => 'Illuminate\\Mail\\MailServiceProvider',
'Illuminate\\Mail\\Markdown' => 'Illuminate\\Mail\\MailServiceProvider',
'auth.password' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
'auth.password.broker' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
'Illuminate\\Contracts\\Pipeline\\Hub' => 'Illuminate\\Pipeline\\PipelineServiceProvider',
'pipeline' => 'Illuminate\\Pipeline\\PipelineServiceProvider',
'queue' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.connection' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.failer' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.listener' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.worker' => 'Illuminate\\Queue\\QueueServiceProvider',
'redis' => 'Illuminate\\Redis\\RedisServiceProvider',
'redis.connection' => 'Illuminate\\Redis\\RedisServiceProvider',
'translator' => 'Illuminate\\Translation\\TranslationServiceProvider',
'translation.loader' => 'Illuminate\\Translation\\TranslationServiceProvider',
'validator' => 'Illuminate\\Validation\\ValidationServiceProvider',
'validation.presence' => 'Illuminate\\Validation\\ValidationServiceProvider',
'Illuminate\\Contracts\\Validation\\UncompromisedVerifier' => 'Illuminate\\Validation\\ValidationServiceProvider',
'Laravel\\Sail\\Console\\InstallCommand' => 'Laravel\\Sail\\SailServiceProvider',
'Laravel\\Sail\\Console\\PublishCommand' => 'Laravel\\Sail\\SailServiceProvider',
'command.tinker' => 'Laravel\\Tinker\\TinkerServiceProvider',
),
'when' =>
array (
'Illuminate\\Broadcasting\\BroadcastServiceProvider' =>
array (
),
'Illuminate\\Bus\\BusServiceProvider' =>
array (
),
'Illuminate\\Cache\\CacheServiceProvider' =>
array (
),
'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider' =>
array (
),
'Illuminate\\Concurrency\\ConcurrencyServiceProvider' =>
array (
),
'Illuminate\\Hashing\\HashServiceProvider' =>
array (
),
'Illuminate\\Mail\\MailServiceProvider' =>
array (
),
'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider' =>
array (
),
'Illuminate\\Pipeline\\PipelineServiceProvider' =>
array (
),
'Illuminate\\Queue\\QueueServiceProvider' =>
array (
),
'Illuminate\\Redis\\RedisServiceProvider' =>
array (
),
'Illuminate\\Translation\\TranslationServiceProvider' =>
array (
),
'Illuminate\\Validation\\ValidationServiceProvider' =>
array (
),
'Laravel\\Sail\\SailServiceProvider' =>
array (
),
'Laravel\\Tinker\\TinkerServiceProvider' =>
array (
),
),
);
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
App\Providers\AppServiceProvider::class,
];
+55
View File
@@ -0,0 +1,55 @@
services:
laravel.test:
build:
context: "./vendor/laravel/sail/runtimes/8.4"
dockerfile: Dockerfile
args:
WWWGROUP: "${WWWGROUP}"
image: "sail-8.4/app"
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "${APP_PORT:-80}:80"
environment:
WWWUSER: "${WWWUSER}"
LARAVEL_SAIL: 1
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
IGNITION_LOCAL_SITES_PATH: "${PWD}"
volumes:
- ".:/var/www/html"
networks:
- sail
depends_on:
- mysql
mysql:
image: "mysql/mysql-server:8.0"
ports:
- "${FORWARD_DB_PORT:-3306}:3306"
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}"
MYSQL_PASSWORD: "${DB_PASSWORD}"
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_EXTRA_OPTIONS: "${MYSQL_EXTRA_OPTIONS:-}"
volumes:
- "sail-mysql:/var/lib/mysql"
- "./vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh"
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- "-p${DB_PASSWORD}"
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
+91
View File
@@ -0,0 +1,91 @@
{
"$schema": "https://getcomposer.org/schema.json",
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": [
"laravel",
"framework"
],
"license": "MIT",
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.24",
"laravel/sail": "^1.48",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"pestphp/pest": "^4.1",
"pestphp/pest-plugin-laravel": "^4.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"setup": [
"composer install",
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan key:generate",
"@php artisan migrate --force",
"npm install",
"npm run build"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
],
"test": [
"@php artisan config:clear --ansi",
"@php artisan test"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"pre-package-uninstall": [
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
+9391
View File
File diff suppressed because it is too large Load Diff
+126
View File
@@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];
+115
View File
@@ -0,0 +1,115 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option defines the default authentication "guard" and password
| reset "broker" for your application. You may change these values
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => env('AUTH_GUARD', 'web'),
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| which utilizes session storage plus the Eloquent user provider.
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication guards have a user provider, which defines how the
| users are actually retrieved out of your database or other storage
| system used by the application. Typically, Eloquent is utilized.
|
| If you have multiple user tables or models you may configure multiple
| providers to represent the model / table. These providers may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\User::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| These configuration options specify the behavior of Laravel's password
| reset functionality, including the table utilized for token storage
| and the user provider that is invoked to actually retrieve users.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the number of seconds before a password confirmation
| window expires and users are asked to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
];
+117
View File
@@ -0,0 +1,117 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache store that will be used by the
| framework. This connection is utilized if another isn't explicitly
| specified when running a cache operation inside the application.
|
*/
'default' => env('CACHE_STORE', 'database'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "array", "database", "file", "memcached",
| "redis", "dynamodb", "octane",
| "failover", "null"
|
*/
'stores' => [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'connection' => env('DB_CACHE_CONNECTION'),
'table' => env('DB_CACHE_TABLE', 'cache'),
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
'octane' => [
'driver' => 'octane',
],
'failover' => [
'driver' => 'failover',
'stores' => [
'database',
'array',
],
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
| stores, there might be other applications using the same cache. For
| that reason, you may prefix every cache key to avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
];
+183
View File
@@ -0,0 +1,183 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for database operations. This is
| the connection which will be utilized unless another connection
| is explicitly specified when you execute a query / statement.
|
*/
'default' => env('DB_CONNECTION', 'sqlite'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Below are all of the database connections defined for your application.
| An example configuration is provided for each database system which
| is supported by Laravel. You're free to add / remove connections.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
'busy_timeout' => null,
'journal_mode' => null,
'synchronous' => null,
'transaction_mode' => 'DEFERRED',
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DB_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run on the database.
|
*/
'migrations' => [
'table' => 'migrations',
'update_date_on_publish' => true,
],
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as Memcached. You may define your connection settings here.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
'persistent' => env('REDIS_PERSISTENT', false),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
'max_retries' => env('REDIS_MAX_RETRIES', 3),
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
],
],
];
+80
View File
@@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application for file storage.
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Below you may configure as many filesystem disks as necessary, and you
| may even configure multiple disks for the same driver. Examples for
| most supported storage drivers are configured here for reference.
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app/private'),
'serve' => true,
'throw' => false,
'report' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
'report' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
'report' => false,
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
+132
View File
@@ -0,0 +1,132 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Processor\PsrLogMessageProcessor;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that is utilized to write
| messages to your logs. The value provided here should match one of
| the channels present in the list of "channels" configured below.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Deprecations Log Channel
|--------------------------------------------------------------------------
|
| This option controls the log channel that should be used to log warnings
| regarding deprecated PHP and library features. This allows you to get
| your application ready for upcoming major versions of dependencies.
|
*/
'deprecations' => [
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
],
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Laravel
| utilizes the Monolog PHP logging library, which includes a variety
| of powerful log handlers and formatters that you're free to use.
|
| Available drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog", "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
'level' => env('LOG_LEVEL', 'critical'),
'replace_placeholders' => true,
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
],
'processors' => [PsrLogMessageProcessor::class],
],
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'handler_with' => [
'stream' => 'php://stderr',
],
'formatter' => env('LOG_STDERR_FORMATTER'),
'processors' => [PsrLogMessageProcessor::class],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
'replace_placeholders' => true,
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];
+118
View File
@@ -0,0 +1,118 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send all email
| messages unless another mailer is explicitly specified when sending
| the message. All additional mailers can be configured within the
| "mailers" array. Examples of each type of mailer are provided.
|
*/
'default' => env('MAIL_MAILER', 'log'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers that can be used
| when delivering an email. You may specify which one you're using for
| your mailers below. You may also add additional mailers if needed.
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
| "postmark", "resend", "log", "array",
| "failover", "roundrobin"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
],
'ses' => [
'transport' => 'ses',
],
'postmark' => [
'transport' => 'postmark',
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
// 'client' => [
// 'timeout' => 5,
// ],
],
'resend' => [
'transport' => 'resend',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
'failover' => [
'transport' => 'failover',
'mailers' => [
'smtp',
'log',
],
'retry_after' => 60,
],
'roundrobin' => [
'transport' => 'roundrobin',
'mailers' => [
'ses',
'postmark',
],
'retry_after' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all emails sent by your application to be sent from
| the same address. Here you may specify a name and address that is
| used globally for all emails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
];
+129
View File
@@ -0,0 +1,129 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue supports a variety of backends via a single, unified
| API, giving you convenient access to each backend using identical
| syntax for each. The default queue connection is defined below.
|
*/
'default' => env('QUEUE_CONNECTION', 'database'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection options for every queue backend
| used by your application. An example configuration is provided for
| each backend supported by Laravel. You're also free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
| "deferred", "background", "failover", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'connection' => env('DB_QUEUE_CONNECTION'),
'table' => env('DB_QUEUE_TABLE', 'jobs'),
'queue' => env('DB_QUEUE', 'default'),
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
'after_commit' => false,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
'queue' => env('BEANSTALKD_QUEUE', 'default'),
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
'block_for' => 0,
'after_commit' => false,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'default'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'after_commit' => false,
],
'redis' => [
'driver' => 'redis',
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
'block_for' => null,
'after_commit' => false,
],
'deferred' => [
'driver' => 'deferred',
],
'background' => [
'driver' => 'background',
],
'failover' => [
'driver' => 'failover',
'connections' => [
'database',
'deferred',
],
],
],
/*
|--------------------------------------------------------------------------
| Job Batching
|--------------------------------------------------------------------------
|
| The following options configure the database and table that store job
| batching information. These options can be updated to any database
| connection and table which has been defined by your application.
|
*/
'batching' => [
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'job_batches',
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control how and where failed jobs are stored. Laravel ships with
| support for storing failed jobs in a simple file or in a database.
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'sqlite'),
'table' => 'failed_jobs',
],
];
+38
View File
@@ -0,0 +1,38 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Mailgun, Postmark, AWS and more. This file provides the de facto
| location for this type of information, allowing packages to have
| a conventional file to locate the various service credentials.
|
*/
'postmark' => [
'key' => env('POSTMARK_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'slack' => [
'notifications' => [
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
];
+217
View File
@@ -0,0 +1,217 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option determines the default session driver that is utilized for
| incoming requests. Laravel supports a variety of storage options to
| persist session data. Database storage is a great default choice.
|
| Supported: "file", "cookie", "database", "memcached",
| "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'database'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to expire immediately when the browser is closed then you may
| indicate that via the expire_on_close configuration option.
|
*/
'lifetime' => (int) env('SESSION_LIFETIME', 120),
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it's stored. All encryption is performed
| automatically by Laravel and you may use the session like normal.
|
*/
'encrypt' => env('SESSION_ENCRYPT', false),
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When utilizing the "file" session driver, the session files are placed
| on disk. The default storage location is defined here; however, you
| are free to provide another location where they should be stored.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION'),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table to
| be used to store sessions. Of course, a sensible default is defined
| for you; however, you're welcome to change this to another table.
|
*/
'table' => env('SESSION_TABLE', 'sessions'),
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using one of the framework's cache driven session backends, you may
| define the cache store which should be used to store the session data
| between requests. This must match one of your defined cache stores.
|
| Affects: "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE'),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the session cookie that is created by
| the framework. Typically, you should not need to change this value
| since doing so does not grant a meaningful security improvement.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application, but you're free to change this when necessary.
|
*/
'path' => env('SESSION_PATH', '/'),
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| This value determines the domain and subdomains the session cookie is
| available to. By default, the cookie will be available to the root
| domain and all subdomains. Typically, this shouldn't be changed.
|
*/
'domain' => env('SESSION_DOMAIN'),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you when it can't be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. It's unlikely you should disable this option.
|
*/
'http_only' => env('SESSION_HTTP_ONLY', true),
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| will set this value to "lax" to permit secure cross-site requests.
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => env('SESSION_SAME_SITE', 'lax'),
/*
|--------------------------------------------------------------------------
| Partitioned Cookies
|--------------------------------------------------------------------------
|
| Setting this value to true will tie the cookie to the top-level site for
| a cross-site context. Partitioned cookies are accepted by the browser
| when flagged "secure" and the Same-Site attribute is set to "none".
|
*/
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
];
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,258 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
// Administrator, Player
$table->enum('type', ['A', 'P'])->default('P');
// Nickname - must be unique
$table->string('nickname', 20)->nullable()->unique();
// User access is blocked
$table->boolean('blocked')->default(false);
// User Photo/Avatar
$table->string('photo_avatar_filename')->nullable();
// Brain Coin Balance
$table->integer('coins_balance')->default(0);
// Users can be deleted with "soft deletes"
$table->softDeletes();
// custom data
$table->json('custom')->nullable();
});
// NOTE: Only multiplayer matches are registered
Schema::create('matches', function (Blueprint $table) {
$table->id();
// Type of games in the match (Bisca dos 3; Bisca dos 9)
$table->enum('type', ['3', '9'])->default('3');
// Player 1 (usually, creates the match)
$table->unsignedBigInteger('player1_user_id');
$table->foreign('player1_user_id')->references('id')->on('users');
// Player 2 (usually, joins the match)
$table->unsignedBigInteger('player2_user_id');
$table->foreign('player2_user_id')->references('id')->on('users');
// Winner (null when not ended)
$table->unsignedBigInteger('winner_user_id')->nullable();
$table->foreign('winner_user_id')->references('id')->on('users');
// Loser (null when not ended)
$table->unsignedBigInteger('loser_user_id')->nullable();
$table->foreign('loser_user_id')->references('id')->on('users');
// Match status
// Pending - Match is waiting for players
// Playing - Match is in progress
// Ended - Match is over
// Interrupted - Match was interrupted due to technical issues (not finished; no winner)
// Note: depending of the project's implementation, some status may never be used
$table->enum('status', ['Pending', 'Playing', 'Ended', 'Interrupted']);
// The stake for this match
$table->integer('stake')->default(3);
// Moment when the match began
$table->dateTime('began_at')->nullable();
// Moment when the match ended
$table->dateTime('ended_at')->nullable();
// Match total time (in seconds) = ended_at - began_at
$table->decimal('total_time', 8, 2)->nullable();
// After the match ended, the total marks for player 1
$table->integer('player1_marks')->nullable();
// After the game ended, the total marks for player 2
$table->integer('player2_marks')->nullable();
// After the match ended, the sum of points for player 1 (all games)
$table->integer('player1_points')->nullable();
// After the match ended, the sum of points for player 2 (all games)
$table->integer('player2_points')->nullable();
// custom data
$table->json('custom')->nullable();
});
// NOTE: Only multiplayer games are registered
Schema::create('games', function (Blueprint $table) {
$table->id();
// Type of game (Bisca dos 3; Bisca dos 9)
$table->enum('type', ['3', '9'])->default('3');
// Player 1 (usually, creates the game)
$table->unsignedBigInteger('player1_user_id');
$table->foreign('player1_user_id')->references('id')->on('users');
// Player 2 (usually, joins the game)
$table->unsignedBigInteger('player2_user_id');
$table->foreign('player2_user_id')->references('id')->on('users');
// True when the game has ended with a draw
$table->boolean('is_draw')->default(false);
// Winner (null when not ended, or when a draw)
$table->unsignedBigInteger('winner_user_id')->nullable();
$table->foreign('winner_user_id')->references('id')->on('users');
// Loser (null when not ended, or when a draw)
$table->unsignedBigInteger('loser_user_id')->nullable();
$table->foreign('loser_user_id')->references('id')->on('users');
// Match (null for standalone games)
$table->unsignedBigInteger('match_id')->nullable();
$table->foreign('match_id')->references('id')->on('matches');
// Game status: 'Pending', 'Playing', 'Ended', or 'Interrupted'.
// Pending: waiting for players
// Playing: in progress
// Ended: finished
// Interrupted: stopped due to technical issues (unfinished; no winner)
// Note: depending on the projects implementation, some statuses may never be used.
$table->enum('status', ['Pending', 'Playing', 'Ended', 'Interrupted']);
// Moment when the game began
$table->dateTime('began_at')->nullable();
// Moment when the game ended
$table->dateTime('ended_at')->nullable();
// Game total time (in seconds) = ended_at - began_at
$table->decimal('total_time', 8, 2)->nullable();
// After the game ended, the total of points for player 1
$table->integer('player1_points')->nullable();
// After the game ended, the total of points for player 2
$table->integer('player2_points')->nullable();
// custom data
$table->json('custom')->nullable();
});
Schema::create('coin_transaction_types', function (Blueprint $table) {
$table->id();
$table->string('name', 40);
// Credit - increase coins
// Debit - decrease coins
$table->enum('type', ['C', 'D']);
// Transaction Types can be deleted with "soft deletes"
$table->softDeletes();
// custom data
$table->json('custom')->nullable();
});
// Add default coin_transaction_types
DB::table('coin_transaction_types')->insert([
['name' => 'Bonus', 'type' => 'C'], // id = 1
['name' => 'Coin purchase', 'type' => 'C'], // id = 2
['name' => 'Game fee', 'type' => 'D'], // id = 3
['name' => 'Match stake', 'type' => 'D'], // id = 4
['name' => 'Game payout', 'type' => 'C'], // id = 5
['name' => 'Match payout', 'type' => 'C'], // id = 6
]);
Schema::create('coin_transactions', function (Blueprint $table) {
$table->id();
// Datetime of the coin transaction
$table->dateTime('transaction_datetime');
// User associated with the transaction
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
// Match associated with the transaction (optional - it can be null)
$table->unsignedBigInteger('match_id')->nullable();
$table->foreign('match_id')->references('id')->on('matches');
// Game associated with the transaction (optional - it can be null)
$table->unsignedBigInteger('game_id')->nullable();
$table->foreign('game_id')->references('id')->on('games');
// Type of the transaction
$table->unsignedBigInteger('coin_transaction_type_id');
$table->foreign('coin_transaction_type_id')->references('id')->on('coin_transaction_types');
// Amount of the transaction (coins)
// Positive -> increments the total amount of brain coins (Credit)
// Negative -> decrements the total amount of brain coins (Debit)
$table->integer('coins');
// custom data
$table->json('custom')->nullable();
});
Schema::create('coin_purchases', function (Blueprint $table) {
$table->id();
// Datetime of the coin purchase
$table->dateTime('purchase_datetime');
// User associated with the purchase
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
// Coin Transaction associated with this purchase
// One to One relation (purchase must have a coin transaction)
$table->unsignedBigInteger('coin_transaction_id')->unique();
$table->foreign('coin_transaction_id')->references('id')->on('coin_transactions');
// Amount of the purchase (real money in euros)
$table->decimal('euros', 8, 2);
// Purchases will involve a payment with a type and a reference
// MBWAY - Phone number with 9 digits
// PAYPAL - eMail
// IBAN - bank transfer (2 letters + 23 digits)
// MB - Multibanco payment - entity number (5 digits) + Reference (9 digits))
// VISA - Visa card number (16 digits)
$table->enum('payment_type', ['MBWAY', 'PAYPAL', 'IBAN', 'MB', 'VISA']);
$table->string('payment_reference', 30);
// custom data
$table->json('custom')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::drop('coin_purchases');
Schema::drop('coin_transactions');
Schema::drop('coin_transaction_types');
Schema::drop('games');
Schema::drop('matches');
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('deleted_at');
$table->dropColumn('custom');
$table->dropColumn('coins_balance');
$table->dropColumn('photo_avatar_filename');
$table->dropColumn('blocked');
$table->dropColumn('nickname');
$table->dropColumn('type');
});
}
};
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
public static $startDate;
public static $dbInsertBlockSize = 500;
// public static $seedType = "small";
//public static $seedType = "full";
//public static $seedLanguage = "pt_PT";
public static $seedLanguage = "en_US";
public function run(): void
{
$this->command->info("-----------------------------------------------");
$this->command->info("START of database seeder");
$this->command->info("-----------------------------------------------");
self::$startDate = Carbon::now()->subMonths(14);
self::$seedLanguage = $this->command->choice('What is the language for users\' names?', ['pt_PT', 'en_US'], 0);
if (DB::getDriverName() === 'sqlite') {
DB::statement('PRAGMA foreign_keys = OFF');
} else {
DB::statement('SET foreign_key_checks=0');
// No permissions to change global setting. Change the session setting only
//DB::statement("SET @@global.time_zone = '+00:00'");
DB::statement("SET time_zone = '+00:00'");
}
DB::table('users')->delete();
DB::table('matches')->delete();
DB::table('games')->delete();
DB::table('coin_purchases')->delete();
DB::table('coin_transactions')->delete();
DB::table('coin_transaction_types')->delete();
if (DB::getDriverName() === 'sqlite') {
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'users'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'matches'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'games'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_purchases'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_transactions'");
DB::statement("DELETE FROM sqlite_sequence WHERE name = 'coin_transaction_types'");
} else {
DB::statement('ALTER TABLE users AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE matches AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE games AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_purchases AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_transactions AUTO_INCREMENT = 0');
DB::statement('ALTER TABLE coin_transaction_types AUTO_INCREMENT = 0');
}
$this->command->info("-----------------------------------------------");
$this->call(TransactionTypesSeeder::class);
$this->call(UsersSeeder::class);
$this->call(InitialTransactionsSeeder::class);
$this->call(GamesSeeder::class);
$this->call(GamesTransactionsSeeder::class);
if (DB::getDriverName() === 'sqlite') {
DB::statement('PRAGMA foreign_keys = ON');
} else {
DB::statement('SET foreign_key_checks=1');
}
$this->command->info("-----------------------------------------------");
$this->command->info("END of database seeder");
$this->command->info("-----------------------------------------------");
}
}
+214
View File
@@ -0,0 +1,214 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Illuminate\Container\Attributes\Database;
class GamesSeeder extends Seeder
{
private $ratioStandaloneToMatch = 15;
private function calculateRandomSeconds($filteredCollection)
{
$totalPlayers = $filteredCollection->count() + 1;
return (12 * 60 * 60) / $totalPlayers + rand(0, 2000);
}
private function nextGameDateTime(&$d, $filteredPlayers, $withinSameMatch = false) {
if ($withinSameMatch) {
$deltaSegundos = rand(300, 900);
} else {
$deltaSegundos = $this->calculateRandomSeconds($filteredPlayers);
}
$d->addSeconds($deltaSegundos);
}
public function run(): void
{
$this->command->info("Games seeder - Start");
$start = DB::table('users')->where('type', 'P')->min('created_at');
$allPlayers = DB::table('users')->where('type', 'P')->get();
$sortedPlayers = $allPlayers->sortBy('created_at')->values();
$d = new \Carbon\Carbon($start);
$d = $d->addDay();
$now = \Carbon\Carbon::now();
$this->command->info("Starting to create games");
$games = [];
$matches = [];
$i = 0;
$filteredPlayers = null;
$filteredPlayersIds = null;
$nextCreatedAt = null;
while ($d->lte($now)) {
$i++;
if (($filteredPlayers === null) || ($nextCreatedAt === null) ||
($d->gte($nextCreatedAt))
) {
$filteredPlayers = $allPlayers->filter(function ($value) use ($d) {
return $d->gt($value->created_at);
});
$nextCreatedAtPlayer = $sortedPlayers->first(function ($value) use ($d) {
return $d->lte($value->created_at);
});
$nextCreatedAt = $nextCreatedAtPlayer ? $nextCreatedAtPlayer->created_at : new \Carbon\Carbon('9999-12-31');
$filteredPlayersIds = $filteredPlayers->pluck('id')->toArray();
}
// Only creates games or matches when there are enough players
if ($filteredPlayersIds === null || empty($filteredPlayersIds) || count($filteredPlayersIds) <2) {
$this->nextGameDateTime($d, $filteredPlayers);
continue;
}
$userIdKeys = array_rand($filteredPlayersIds, 2);
$userIDPlayer1 = $filteredPlayersIds[$userIdKeys[0]];
$userIDPlayer2 = $filteredPlayersIds[$userIdKeys[1]];
if ($userIDPlayer1 == $userIDPlayer2) {
$this->nextGameDateTime($d, $filteredPlayers);
continue;
}
$match = null;
if (rand(1, $this->ratioStandaloneToMatch) === 1) {
$match = $this->newMatch($filteredPlayers, $userIDPlayer1, $userIDPlayer2, $d);
$playersMarks = [0, 0];
$playersPoints = [0, 0];
while($playersMarks[0] < 4 && $playersMarks[1] <4) {
$newGame = $this->newGame($filteredPlayers, $match, $userIDPlayer1, $userIDPlayer2, $d);
$games[] = $newGame;
$playersPoints[0] += $newGame['player1_points'];
$playersPoints[1] += $newGame['player2_points'];
if ($newGame['player1_points'] > $newGame['player2_points']) {
if ($newGame['player1_points'] >= 120) {
$playersMarks[0]+= 4;
} elseif ($newGame['player1_points'] >= 91) {
$playersMarks[0] += 2;
} else {
$playersMarks[0]++;
}
} elseif ($newGame['player2_points'] > $newGame['player1_points']) {
if ($newGame['player2_points'] >= 120) {
$playersMarks[1]+= 4;
} elseif ($newGame['player2_points'] >= 91) {
$playersMarks[1] += 2;
} else {
$playersMarks[1]++;
}
}
}
$this->updateMatchWinner($match, $playersMarks[0], $playersMarks[1], $playersPoints[0], $playersPoints[1], $d);
$matches[] = $match;
} else {
$newGame = $this->newGame($filteredPlayers, $match, $userIDPlayer1, $userIDPlayer2, $d);
$games[] = $newGame;
}
if ($i >= DatabaseSeeder::$dbInsertBlockSize) {
if (!empty($matches)) {
DB::table('matches')->insert($matches);
$this->command->info("Saved " . count($matches) . " matches at date " . $d->format('Y-m-d H:i:s'));
}
if (!empty($games)) {
DB::table('games')->insert($games);
$this->command->info("Saved " . count($games) . " games at date " . $d->format('Y-m-d H:i:s'));
}
$i = 0;
$games = [];
$matches = [];
}
//$this->nextGameDateTime($d, $filteredPlayers);
}
if (!empty($matches)) {
DB::table('matches')->insert($matches);
$this->command->info("Saved " . count($matches) . " matches at date " . $d->format('Y-m-d H:i:s'));
}
if (!empty($games)) {
DB::table('games')->insert($games);
$this->command->info("Saved " . count($games) . " games at date " . $d->format('Y-m-d H:i:s'));
}
$this->command->info("Games seeder - End");
}
private $matchID = 0;
private function newMatch($filteredPlayers,$user1, $user2, $d)
{
$this->matchID++;
$this->nextGameDateTime($d, $filteredPlayers);
return [
'id' => $this->matchID,
'type' => random_int(1,2) == 1 ? '3' : '9',
'player1_user_id' => $user1,
'player2_user_id' => $user2,
'winner_user_id' => null,
'loser_user_id' => null,
'status' => 'Ended',
'stake' => random_int(1,4) > 1 ? 3 : random_int(4,100),
'began_at' => $d->copy(),
'ended_at' => null,
'total_time' => null,
'player1_marks' => null,
'player2_marks' => null,
'player1_points' => null,
'player2_points' => null,
'custom' => null
];
}
private function updateMatchWinner(&$match, $player1Marks, $player2Marks, $totalPlayers1, $totalPlayers2, $d)
{
$match['player1_marks'] = $player1Marks;
$match['player2_marks'] = $player2Marks;
$match['player1_points'] = $totalPlayers1;
$match['player2_points'] = $totalPlayers2;
$match['ended_at'] = $d->copy();
$match['total_time'] = $match['began_at']->diffInSeconds($match['ended_at']);
$match['winner_user_id'] = $player1Marks > $player2Marks ? $match['player1_user_id'] : ($player2Marks > $player1Marks ? $match['player2_user_id'] : null);
$match['loser_user_id'] = $player1Marks > $player2Marks ? $match['player2_user_id'] : ($player2Marks > $player1Marks ? $match['player1_user_id'] : null);
}
private $gameID = 0;
private function newGame($filteredPlayers, $match, $user1, $user2, $d)
{
$this->gameID++;
$this->nextGameDateTime($d, $filteredPlayers, $match != null);
$begin_d = $d->copy();
$pointsUser1 = 60;
$pointsUser2 = 60;
// if random == 1 it is a draw
if (random_int(1,30) > 1) {
$pointsUser1 = rand(0, 120);
$pointsUser2 = 120 - $pointsUser1;
}
$duration = random_int(200, 900);
$d->addSeconds($duration);
return [
'id' => $this->gameID,
'type' => $match ? $match['type'] : (random_int(1, 2) == 1 ? '3' : '9'),
'match_id' => $match ? $match['id'] : null,
'player1_user_id' => $user1,
'player2_user_id' => $user2,
'is_draw' => $pointsUser1 == $pointsUser2,
'winner_user_id' => $pointsUser1 > $pointsUser2 ? $user1 : ($pointsUser2 > $pointsUser1 ? $user2 : null),
'loser_user_id' => $pointsUser1 < $pointsUser2 ? $user1 : ($pointsUser2 < $pointsUser1 ? $user2 : null),
'status' => 'Ended',
'began_at' => $begin_d,
'ended_at' => $d->copy(),
'total_time' => $duration,
'player1_points' => $pointsUser1,
'player2_points' => $pointsUser2,
'custom' => null
];
}
}
@@ -0,0 +1,265 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class GamesTransactionsSeeder extends Seeder
{
private $faker = null;
private $users = null;
public function run(): void
{
$this->command->info("Create game related Transactions");
$this->faker = \Faker\Factory::create(DatabaseSeeder::$seedLanguage);
$this->users = DB::table('users')->orderBy('id', 'asc')->get();
$games = DB::table('games')->whereNull('match_id')->orderBy('began_at', 'asc')->get();
$matches = DB::table('matches')->orderBy('began_at', 'asc')->get();
$coin_purchases = [];
$coin_transactions = [];
$i = 0;
while($games->count() > 0 || $matches->count() > 0) {
$firstGame = $games->first();
$firstMatch = $matches->first();
$isGameFirst = false;
if ($firstGame && $firstMatch) {
$isGameFirst = $firstGame->began_at < $firstMatch->began_at;
} elseif ($firstGame && !$firstMatch) {
$isGameFirst = true;
} elseif (!$firstGame && $firstMatch) {
$isGameFirst = false;
}
if ($isGameFirst) {
$this->handleGame($coin_purchases, $coin_transactions, $firstGame);
$games->shift();
} else {
$this->handleMatch($coin_purchases, $coin_transactions, $firstMatch);
$matches->shift();
}
$i++;
if ($i >= DatabaseSeeder::$dbInsertBlockSize) {
$this->command->info("Block of coin purchases and transactions");
if (!empty($coin_transactions)) {
DB::table('coin_transactions')->insert($coin_transactions);
$this->command->info("Saved " . count($coin_transactions) . " coin transactions");
}
if (!empty($coin_purchases)) {
DB::table('coin_purchases')->insert($coin_purchases);
$this->command->info("Saved " . count($coin_purchases) . " coin purchases");
}
$i = 0;
$coin_purchases = [];
$coin_transactions = [];
}
}
$this->command->info("Last block of coin purchases and transactions");
if (!empty($coin_transactions)) {
DB::table('coin_transactions')->insert($coin_transactions);
$this->command->info("Saved " . count($coin_transactions) . " coin transactions");
}
if (!empty($coin_purchases)) {
DB::table('coin_purchases')->insert($coin_purchases);
$this->command->info("Saved " . count($coin_purchases) . " coin purchases");
}
$this->updateAllUsersBalance();
$this->command->info("Game related Transactions Created Successfully.");
}
private function getTimeStampFromDB($strDateFromDB, $minusOneSecond = false)
{
if ($minusOneSecond) {
return date("Y-m-d H:i:s", strtotime($strDateFromDB . " - 1 second"));
}
return date("Y-m-d H:i:s", strtotime($strDateFromDB));
}
private function getRandomPayment($user, &$type, &$ref): void
{
$type = $this->faker->randomElement(['MBWAY', 'PAYPAL', 'IBAN', 'MB', 'VISA']);
switch ($type) {
case 'MBWAY':
$ref = rand(910000000, 999999999);
break;
case 'PAYPAL':
$ref = $user->email;
break;
case 'IBAN':
$ref = 'PT' . rand(5000000000000, 9999999999999) . rand(1000000000, 9999999999);
break;
case 'MB':
$ref = rand(10000, 99999) . '-' . rand(100000000, 999999999);
break;
case 'VISA':
$ref = rand(40000000, 49999999) . rand(10000000, 99999999);
break;
}
}
private $purchaseID = null;
private function addPurchase(&$coin_purchases, &$coin_transactions, &$user, $time, $eurosAmount)
{
$this->purchaseID++;
$coins = $eurosAmount * 10;
$newCoinTransaction = $this->addCoinTransaction($coin_transactions, $user, $coins, 2, $time, null, null);
$this->getRandomPayment($user, $paymentType, $paymentRef);
$coin_purchases[] = [
'id' => $this->purchaseID,
'purchase_datetime' => $time,
'user_id' => $user->id,
'coin_transaction_id' => $newCoinTransaction['id'],
'euros' => $eurosAmount,
'payment_type' => $paymentType,
'payment_reference' => $paymentRef,
'custom' => null,
];
}
private $transactionID = 0;
private function addCoinTransaction(&$coin_transactions, &$user, $coins, $type, $time, $game_id = null, $match_id = null)
{
if ($this->transactionID == null) {
$this->transactionID = DB::table('coin_transactions')->max('id');
}
// Types of coin transactions:
// 1 - Bonus
// 2 - Coin purchase
// 3 - Game fee - requires game_id
// 4 - Match stake - requires match_id
// 5 - Game payout - requires game_id
// 6 - Match payout - requires match_id
if(($type == 3 || $type == 5) && $game_id === null) {
throw new \Exception("Game ID is required for coin transaction type $type");
}
if(($type == 4 || $type == 6) && $match_id === null) {
throw new \Exception("Match ID is required for coin transaction type $type");
}
$this->transactionID++;
$coins = abs($coins);
if (in_array($type, [3, 4])) {
$coins *= -1;
}
$newCoinTransaction = [
'id' => $this->transactionID,
'transaction_datetime' => $time,
'user_id' => $user->id,
'match_id' => $match_id, // nullable
'game_id' => $game_id, // nullable
'coin_transaction_type_id' => $type,
'coins' => $coins,
'custom' => null,
];
$coin_transactions[] = $newCoinTransaction;
$user->coins_balance += $coins;
return $newCoinTransaction;
}
private function calculateGamePayouts($game)
{
$payouts = [0, 0];
if ($game->player1_points == $game->player2_points) {
$payouts = [1, 1];
} elseif ($game->player1_points == 120) {
$payouts = [6, 0];
} elseif ($game->player2_points == 120) {
$payouts = [0, 6];
} elseif ($game->player1_points >= 91) {
$payouts = [4, 0];
} elseif ($game->player2_points >= 91) {
$payouts = [0, 4];
} elseif ($game->player1_points >= 61) {
$payouts = [3, 0];
} elseif ($game->player2_points >= 61) {
$payouts = [0, 3];
} else { // this condition should never be reached
$payouts = [0, 0];
}
return $payouts;
}
private function calculateMatchPayouts($match)
{
$payouts = [0, 0];
if ($match->winner_user_id == $match->player1_user_id) {
$payouts = [$match->stake * 2 - 1, 0];
} elseif ($match->winner_user_id == $match->player2_user_id) {
$payouts = [0, $match->stake * 2 - 1];
}
return $payouts;
}
private function handleGame(&$coin_purchases, &$coin_transactions, $game)
{
$player1 = $this->users->where('id', $game->player1_user_id)->first();
$player2 = $this->users->where('id', $game->player2_user_id)->first();
// not enough coins to play - must purchase before the game
$timeOneSecondBefore = $this->getTimeStampFromDB($game->began_at, true);
if ($player1->coins_balance < 2) {
$this->addPurchase($coin_purchases, $coin_transactions, $player1, $timeOneSecondBefore, random_int(1, 10));
}
// not enough coins to play - must purchase before the game
if ($player2->coins_balance < 2) {
$this->addPurchase($coin_purchases, $coin_transactions, $player2, $timeOneSecondBefore, random_int(1, 10));
}
$this->addCoinTransaction($coin_transactions, $player1, -2, 3, $this->getTimeStampFromDB($game->began_at, false), $game->id);
$this->addCoinTransaction($coin_transactions, $player2, -2, 3, $this->getTimeStampFromDB($game->began_at, false), $game->id);
$payouts = $this->calculateGamePayouts($game);
if ($payouts[0] > 0) {
$this->addCoinTransaction($coin_transactions, $player1, $payouts[0], 5, $this->getTimeStampFromDB($game->ended_at, false), $game->id);
}
if ($payouts[1] > 0) {
$this->addCoinTransaction($coin_transactions, $player2, $payouts[1], 5, $this->getTimeStampFromDB($game->ended_at, false), $game->id);
}
}
private function handleMatch(&$coin_purchases, &$coin_transactions, $match)
{
$player1 = $this->users->where('id', $match->player1_user_id)->first();
$player2 = $this->users->where('id', $match->player2_user_id)->first();
// not enough coins to play - must purchase before the match
$timeOneSecondBefore = $this->getTimeStampFromDB($match->began_at, true);
if ($player1->coins_balance < $match->stake) {
$requiredCoins = $match->stake - $player1->coins_balance;
$euros = ceil(($requiredCoins + 3) / 10);
$this->addPurchase($coin_purchases, $coin_transactions, $player1, $timeOneSecondBefore, $euros);
}
// not enough coins to play - must purchase before the match
if ($player2->coins_balance < $match->stake) {
$requiredCoins = $match->stake - $player2->coins_balance;
$euros = ceil(($requiredCoins + 3) / 10);
$this->addPurchase($coin_purchases, $coin_transactions, $player2, $timeOneSecondBefore, $euros);
}
$this->addCoinTransaction($coin_transactions, $player1, $match->stake * -1, 4, $this->getTimeStampFromDB($match->began_at, false), null, $match->id);
$this->addCoinTransaction($coin_transactions, $player2, $match->stake * -1, 4, $this->getTimeStampFromDB($match->began_at, false), null, $match->id);
$payouts = $this->calculateMatchPayouts($match);
if ($payouts[0] > 0) {
$this->addCoinTransaction($coin_transactions, $player1, $payouts[0], 6, $this->getTimeStampFromDB($match->ended_at, false), null, $match->id);
}
if ($payouts[1] > 0) {
$this->addCoinTransaction($coin_transactions, $player2, $payouts[1], 6, $this->getTimeStampFromDB($match->ended_at, false), null, $match->id);
}
}
private function updateAllUsersBalance()
{
$this->command->info("Update users balances...");
foreach ($this->users as $user) {
DB::table('users')->where('id', $user->id)->update(['coins_balance' => $user->coins_balance]);
}
$this->command->info("All users balances updated.");
}
}
@@ -0,0 +1,62 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use stdClass;
class InitialTransactionsSeeder extends Seeder
{
private $allPlayers;
private $sizeOfSaveBlock = 200;
private $valueOfInitialBonus = 10;
public function run(): void
{
$this->allPlayers = DB::table('users')->where('type', 'P')->get();
$this->command->info("Create initial Bonuses transactions");
$i = $this->sizeOfSaveBlock;
$dataBlock = [];
foreach ($this->allPlayers as $player) {
if ($i <= 0) {
$this->saveDataBlock($dataBlock);
$i = $this->sizeOfSaveBlock;
$dataBlock = [];
}
$dataBlock[] = $this->createBonusTransaction($player);
$i--;
}
if (!empty($dataBlock)) {
$this->saveDataBlock($dataBlock);
}
$this->updateAllPlayerBalances();
}
private function saveDataBlock($dataBlock): void
{
$size = count($dataBlock);
DB::table('coin_transactions')->insert($dataBlock);
$this->command->info("Saved $size initial bonuses transactions");
}
private function createBonusTransaction($player): array
{
return [
'transaction_datetime' => $player->created_at,
'user_id' => $player->id,
'match_id' => null,
'game_id' => null,
'coin_transaction_type_id' => 1,
'coins' => $this->valueOfInitialBonus,
'custom' => null,
];
}
private function updateAllPlayerBalances(): void
{
DB::table('users')->where('type', 'P')->update(['coins_balance' => $this->valueOfInitialBonus]);
$this->command->info("Updated all players initial Balance");
}
}
+149
View File
@@ -0,0 +1,149 @@
<?php
namespace Database\Seeders;
use Illuminate\Support\Facades\File;
trait SeederUtils
{
private static $used_emails = [];
public function randomString(int $length = 10): string
{
return substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, $length);
}
public function integerAsStringWithPadding(int $num, int $length = 10): string
{
return str_pad((string) $num, $length, '0', STR_PAD_LEFT);
}
public function randomIntegerAsStringWithPadding(int $min = 0, int $max = 100, int $length = 10): string
{
return $this->integerAsStringWithPadding($this->mt_rand($min, $max), $length);
}
public function randomDecimal(float $min, float $max, int $decimals = 2): float
{
$factor = pow(10, $decimals);
return mt_rand($min * $factor, $max * $factor) / $factor;
}
public function getFileNameFromString($str, $extension)
{
return str_replace(' ', '_', strtolower($this->stripAccents($str))) . ".$extension";
}
public function stripAccents($stripAccents)
{
$from = 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ';
$to = 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY';
$keys = array();
$values = array();
preg_match_all('/./u', $from, $keys);
preg_match_all('/./u', $to, $values);
$mapping = array_combine($keys[0], $values[0]);
return strtr($stripAccents, $mapping);
}
public function strtr_utf8($str, $from, $to)
{
$keys = array();
$values = array();
preg_match_all('/./u', $from, $keys);
preg_match_all('/./u', $to, $values);
$mapping = array_combine($keys[0], $values[0]);
return strtr($str, $mapping);
}
public function randomName($faker, &$gender, &$fullname, &$email, $allowRepeated = false)
{
$gender = $gender ?? $faker->randomElement(['male', 'female']);
$firstname = $faker->firstName($gender);
$lastname = $faker->lastName();
$secondname = mt_rand(1, 3) == 2 ? "" : " " . $faker->firstName($gender);
$number_middlenames = $faker->randomElement([0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3]);
$middlenames = "";
for ($i = 0; $i < $number_middlenames; $i++) {
$middlenames .= " " . $faker->lastName();
}
$fullname = $firstname . $secondname . $middlenames . " " . $lastname;
$email = strtolower($this->stripAccents($firstname) . "." . $this->stripAccents($lastname) . "@mail.pt");
if (!$allowRepeated) {
$i = 2;
while (in_array($email, self::$used_emails)) {
$email = strtolower($this->stripAccents($firstname) . "." . $this->stripAccents($lastname) . "." . $i ."@mail.pt");
$i++;
if ($i > 10) {
$this->command->error("Repeated email - not possible to create a unique email for $fullname!");
exit(1);
}
}
}
self::$used_emails[] = $email;
$gender = $gender == 'male' ? 'M' : 'F';
}
public function ramdomPaymentMethod($email, &$paymentType, &$paymentReference)
{
$paymentType = $this->faker->randomElement(['Visa', 'PayPal', 'MB WAY']);
$paymentReference = match ($paymentType) {
'Visa' => mt_rand(4, 6) .
$this->faker->randomNumber($nbDigits = 8, $strict = true) .
$this->faker->randomNumber($nbDigits = 7, $strict = true),
'PayPal' => $email,
'MB WAY' => '9' . $this->faker->randomNumber($nbDigits = 8, $strict = true)
};
}
public function cleanStorageFolder($folder, $public = true)
{
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
if (File::exists($storagePath)) {
File::deleteDirectory($storagePath);
}
if (!File::exists(storage_path("app"))) {
File::makeDirectory(storage_path("app"));
}
if ($public) {
if (!File::exists(storage_path("app/public"))) {
File::makeDirectory(storage_path("app/public"));
}
} else {
if (!File::exists(storage_path("app/private"))) {
File::makeDirectory(storage_path("app/private"));
}
}
File::makeDirectory($storagePath);
}
public function copyFileToStorage($originalFolder, $originalFileName, $folder, $id = null, $public = true)
{
$originalFullName = database_path("seeders/$originalFolder") . '/' . $originalFileName;
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
$prefix = $id ? $this->integerAsStringWithPadding($id, 5) . '_' : '';
$ext = pathinfo($originalFullName, PATHINFO_EXTENSION);
$newFileName = $prefix . $this->randomString(10) . '.' . $ext;
if (!File::exists($storagePath)) {
File::makeDirectory($storagePath);
}
if (File::exists($originalFullName)) {
File::copy($originalFullName, "$storagePath/$newFileName");
return $newFileName;
}
return null;
}
public function directCopyFileToStorage($originalFolder, $originalFileName, $folder, $public = true)
{
$originalFullName = database_path("seeders/$originalFolder") . '/' . $originalFileName;
$storagePath = $public ? storage_path("app/public/$folder") : storage_path("app/private/$folder");
if (!File::exists($storagePath)) {
File::makeDirectory($storagePath);
}
File::copy($originalFullName, "$storagePath/$originalFileName");
return $originalFileName;
}
}
@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class TransactionTypesSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$this->command->line("Creating Coin Transaction Types.");
// Add default coin_transaction_types
DB::table('coin_transaction_types')->insert([
['id' => 1, 'name' => 'Bonus', 'type' => 'C'], // id = 1
['id' => 2, 'name' => 'Coin purchase', 'type' => 'C'], // id = 2
['id' => 3, 'name' => 'Game fee', 'type' => 'D'], // id = 3
['id' => 4, 'name' => 'Match stake', 'type' => 'D'], // id = 4
['id' => 5, 'name' => 'Game payout', 'type' => 'C'], // id = 5
['id' => 6, 'name' => 'Match payout', 'type' => 'C'], // id = 6
]);
$this->command->line("Coin Transaction Types Created Successfully.");
}
}
+173
View File
@@ -0,0 +1,173 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Faker\Factory;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use stdClass;
class UsersSeeder extends Seeder
{
use SeederUtils;
private $faker = null;
private $files_M = [];
private $files_F = [];
public static $hashPasword = "";
public static $dbUsers = null;
public static $fixedUsers = [
['type' => 'A', 'name' => 'First Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'A', 'name' => 'Second Administrator', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'A', 'name' => 'Third Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'A', 'name' => 'Forth Administrator', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
['type' => 'P', 'name' => 'Player A', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'P', 'name' => 'Player B', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => false],
['type' => 'P', 'name' => 'Player C', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'P', 'name' => 'Player D', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
['type' => 'P', 'name' => 'Player E', 'email' => '[email protected]', 'gender' => 'F', 'softdelete' => false],
['type' => 'P', 'name' => 'Player F', 'email' => '[email protected]', 'gender' => 'M', 'softdelete' => true],
];
public static $userTypes = [
'A' => 10,
'P' => 500];
public function run(): void
{
$this->command->line("Creating Users.");
self::$hashPasword = bcrypt('123');
//$this->faker = Factory::create('pt_PT');
$this->faker = Factory::create(DatabaseSeeder::$seedLanguage);
$this->cleanStorageFolder('photos_avatars');
$this->addUsersToDatabase();
$this->addPhotoFiles();
DB::table('users')->where('type', 'A')->update(['nickname' => null]);
self::$dbUsers = DB::table('users')->orderBy('id')->get();
$this->command->line("Users Created Successfully.");
}
private function addUsersToDatabase()
{
$this->command->line("Adding users to the database");
$usersAdded = Self::$fixedUsers;
foreach (self::$userTypes as $userType => $totalUsers) {
for ($i = 0; $i < $totalUsers; $i++) {
$gender = null;
$name = null;
$email = null;
$this->randomName($this->faker, $gender, $name, $email, false);
$usersAdded[] = [
'type' => $userType,
'name' => $name,
'email' => $email,
'gender' => $gender,
'softdelete' => random_int(1, 20) == 1,
];
}
}
$createdDate = DatabaseSeeder::$startDate->copy()->addMinutes(mt_rand(20000, 100000));
foreach ($usersAdded as $key => $user) {
$usersAdded[$key]['password'] = self::$hashPasword;
$createdDate = $createdDate->copy()->addMinutes(mt_rand(10, 60));
$usersAdded[$key]['created_at'] = $createdDate;
$usersAdded[$key]['email_verified_at'] = $createdDate->copy()->addMinutes(mt_rand(1, 9));
if (random_int(1, 7) > 1) {
$usersAdded[$key]['updated_at'] = $createdDate->copy()->addMinutes(mt_rand(10, 10000));
} else {
$usersAdded[$key]['updated_at'] = $createdDate;
}
$usersAdded[$key]['nickname'] = ($user['gender'] == 'M' ? 'Mickey' : 'Minnie') . ($key + 1) ;
$usersAdded[$key]['blocked'] = false;
$usersAdded[$key]['photo_avatar_filename'] = null;
$usersAdded[$key]['coins_balance'] = 0;
$usersAdded[$key]['deleted_at'] = null;
if ($usersAdded[$key]['softdelete']) {
$usersAdded[$key]['deleted_at'] = $createdDate->copy()->addMinutes(mt_rand(10001, 100000));
}
}
$arrayToStore = [];
foreach ($usersAdded as $user) {
unset($user['gender']);
unset($user['softdelete']);
$arrayToStore[] = $user;
if (count($arrayToStore) >= DatabaseSeeder::$dbInsertBlockSize) {
DB::table('users')->insert($arrayToStore);
$this->command->line("Created " . count($arrayToStore) . " users");
$arrayToStore = [];
}
}
if (count($arrayToStore) >= 1) {
DB::table('users')->insert($arrayToStore);
$this->command->line("Created " . count($arrayToStore) . " users");
}
$this->command->line("Total users created: " . DB::table('users')->count());
self::$dbUsers = DB::table('users')->get();
print_r(self::$dbUsers);
}
private function addPhotoFiles()
{
$this->command->line("Copying users' photos");
$this->fillPhotoFilesNames();
$total = count($this->files_M) + count($this->files_F);
$sortedUsers = self::$dbUsers->sortBy(function (stdClass $user) {
if ($user->id <= 10 ) {
return $user->id;
}
return match($user->type) {
'A' => 20 + $user->id,
'P' => 1000 + $user->id,
default => ($user->id < 50) ? 2000 + $user->id : 3000 + mt_rand(0, 100000),
};
});
$i = 0;
foreach($sortedUsers as $user) {
$originalFilename = str_starts_with($user->nickname, 'Mickey') ? array_shift($this->files_M) : array_shift($this->files_F);
if (!$originalFilename) {
if ((count($this->files_M) == 0) && (count($this->files_F) == 0))
break;
}
if ($originalFilename) {
$originalFilename = basename($originalFilename);
$newFileName = $this->copyFileToStorage('photos', $originalFilename, 'photos_avatars', $user->id);
$user->photo_avatar_filename = $newFileName;
DB::table('users')->where('id', $user->id)->update(['photo_avatar_filename' => $user->photo_avatar_filename]);
$i++;
if ($i % 10 == 0) {
$this->command->line("User photo $i/$total copied");
}
}
}
$this->command->line("Total of $total user's photos were copied!");
$this->directCopyFileToStorage('photos', 'anonymous.png', 'photos_avatars');
$this->command->line("Image for user with no associated photo was copied!");
}
private function fillPhotoFilesNames()
{
$allFiles = collect(File::files(database_path('seeders/photos')));
foreach ($allFiles as $f) {
if (strpos($f->getPathname(), 'm_')) {
$this->files_M[] = $f->getPathname();
} else if (strpos($f->getPathname(), 'w_')) {
$this->files_F[] = $f->getPathname();
}
}
shuffle($this->files_M);
shuffle($this->files_F);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 KiB

Some files were not shown because too many files have changed in this diff Show More