first init

This commit is contained in:
AVMG20 2021-06-05 11:26:32 +02:00
commit e5d638ee5e
237 changed files with 70317 additions and 0 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

69
.env.example Normal file
View file

@ -0,0 +1,69 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
PAYPAL_SANDBOX_SECRET=
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SECRET=
PAYPAL_CLIENT_ID=
PAYPAL_EMAIL=
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
DISCORD_REDIRECT_URI=http://localhost:8000/auth/callback
DISCORD_INVITE_URL=https://discord.gg/vrUYdxG4wZ
PTERODACTYL_TOKEN=
PTERODACTYL_URL=https://panel.bitsec.dev
PHPMYADMIN_URL=https://mysql.bitsec.dev
RECAPTCHA_SITE_KEY=YOUR_API_SITE_KEY
RECAPTCHA_SECRET_KEY=YOUR_API_SECRET_KEY
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

5
.gitattributes vendored Normal file
View file

@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

15
.gitignore vendored Normal file
View file

@ -0,0 +1,15 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/storage/credit_deduction_log
.env
.idea
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

13
.styleci.yml Normal file
View file

@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Arno VIsker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

185
README.md Normal file
View file

@ -0,0 +1,185 @@
# ControlPanel's Dashboard
ControlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that credits users hourly for each server they have and suspends them if they run out of credits.
This dashboard is built with Laravel as it offers a very robust and secure development environment.
I copied a part of pterodactyls documentation for the installation because it uses the same dependencies and covers this area pretty good.
## Dependencies
* PHP `7.4` or `8.0` (recommended) with the following extensions: `cli`, `openssl`, `gd`, `mysql`, `PDO`, `mbstring`, `tokenizer`, `bcmath`, `xml` or `dom`, `curl`, `zip`, and `fpm` if you are planning to use NGINX.
* MySQL `5.7.22` or higher (MySQL `8` recommended) **or** MariaDB `10.2` or higher.
* Redis (`redis-server`)
* A webserver (Apache, NGINX, Caddy, etc.)
* `curl`
* `tar`
* `unzip`
* `git`
* `composer` v2
### Example Dependency Installation
if you already have pterodactyl installed you can skip this step!
The commands below are simply an example of how you might install these dependencies. Please consult with your
operating system's package manager to determine the correct packages to install.
``` bash
# Add "add-apt-repository" command
apt -y install software-properties-common curl apt-transport-https ca-certificates gnupg
# Add additional repositories for PHP, Redis, and MariaDB
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
add-apt-repository -y ppa:chris-lea/redis-server
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
# Update repositories list
apt update
# Add universe repository if you are on Ubuntu 18.04
apt-add-repository universe
# Install Dependencies
apt -y install php8.0 php8.0-{cli,gd,mysql,pdo,mbstring,tokenizer,bcmath,xml,fpm,curl,zip} mariadb-server nginx tar unzip git redis-server
```
### Extra dependency used on this dashboard
you need to install this, use the appropriate php version (php -v)
```bash
sudo apt-get install php8.0-intl
```
### Installing Composer
if you already have pterodactyl installed you can skip this step!
Composer is a dependency manager for PHP that allows us to ship everything you'll need code wise to operate the Panel. You'll
need composer installed before continuing in this process.
``` bash
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
```
## Download Files
The first step in this process is to create the folder where the panel will live and then move ourselves into that
newly created folder. Below is an example of how to perform this operation.
``` bash
mkdir -p /var/www/dashboard
cd /var/www/dashboard
```
TEXT
``` bash
git clone https://github.com/ControlPanel-gg/dashboard.git ./
chmod -R 755 storage/* bootstrap/cache/
```
## Installation
Now that all of the files have been downloaded we need to configure some core aspects of the Panel.
You will need a database setup and a user with the correct permissions created for that database before
continuing any further.
First we will copy over our default environment settings file, install core dependencies, and then generate a
new application encryption key.
``` bash
cp .env.example .env
composer install
# Only run the command below if you are installing this Panel
php artisan key:generate --force
# you should create a symbolic link from public/storage to storage/app/public
php artisan storage:link
```
Back up your encryption key (APP_KEY in the `.env` file). It is used as an encryption key for all data that needs to be stored securely (e.g. api keys).
Store it somewhere safe - not just on your server. If you lose it all encrypted data is irrecoverable -- even if you have database backups.
### Environment Configuration
Simply edit the .env to your needs
Please do not forget to enter the database creds in here or the next step wont work
``` bash
nano .env
```
### Database Setup
Now we need to setup all of the base data for the Panel in the database you created earlier. **The command below
may take some time to run depending on your machine. Please _DO NOT_ exit the process until it is completed!** This
command will setup the database tables and then add all of the Nests & Eggs that power Pterodactyl.
``` bash
php artisan migrate --seed --force
```
### Add The First User
Currenly I haven't made a easy command for this so just enter your databse with phpmyadmin and create a new user with the role 'admin'
### Set Permissions
The last step in the installation process is to set the correct permissions on the Panel files so that the webserver can
use them correctly.
``` bash
# If using NGINX or Apache (not on CentOS):
chown -R www-data:www-data /var/www/dashboard/*
# If using NGINX on CentOS:
chown -R nginx:nginx /var/www/dashboard/*
# If using Apache on CentOS
chown -R apache:apache /var/www/dashboard/*
```
### Crontab Configuration
The first thing we need to do is create a new cronjob that runs every minute to process specific Dashboard tasks. like billing users hourly and suspending unpaid servers
```bash
* * * * * php /var/www/dashboard/artisan schedule:run >> /dev/null 2>&1
```
### Nginx
You should paste the contents of the file below, replacing <domain> with your domain name being used in a file called dashboard.conf and place it in /etc/nginx/sites-available/, or — if on CentOS, /etc/nginx/conf.d/.
```bash
server {
listen 80;
root /var/www/dashboard/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name YOUR.DOMAIN.COM;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
```
### Enable configuration
The final step is to enable your NGINX configuration and restart it.
```bash
# You do not need to symlink this file if you are using CentOS.
sudo ln -s /etc/nginx/sites-available/dashboard.conf /etc/nginx/sites-enabled/dashboard.conf
# Check for nginx errors
sudo nginx -t
# You need to restart nginx regardless of OS. only do this you haven't received any errors
systemctl restart nginx
```

175
app/Classes/Pterodactyl.php Normal file
View file

@ -0,0 +1,175 @@
<?php
namespace App\Classes;
use App\Models\Egg;
use App\Models\Location;
use App\Models\Nest;
use App\Models\Node;
use App\Models\Server;
use Exception;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
class Pterodactyl
{
/**
* @param Node $node
* @return array|mixed|null
*/
public static function getFreeAllocations(Node $node)
{
$response = self::getAllocations($node);
$freeAllocations = [];
foreach ($response['data'] as $allocation) {
if (!$allocation['attributes']['assigned']) array_push($freeAllocations, $allocation);
}
return $freeAllocations;
}
/**
* @return null
* @throws Exception
*/
public static function getNests()
{
$response = self::client()->get('/application/nests');
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
/**
* @param Nest $nest
* @return mixed
* @throws Exception
*/
public static function getEggs(Nest $nest)
{
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables");
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
/**
* @return mixed
* @throws Exception
*/
public static function getNodes()
{
$response = self::client()->get('/application/nodes');
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
/**
* @return mixed
* @throws Exception
*/
public static function getLocations()
{
$response = self::client()->get('/application/locations');
if ($response->failed()) throw self::getException();
return $response->json()['data'];
}
/**
* @param Node $node
* @return mixed
*/
public static function getFreeAllocationId(Node $node)
{
return self::getFreeAllocations($node)[0]['attributes']['id'];
}
/**
* @param Node $node
* @throws Exception
*/
public static function getAllocations(Node $node)
{
$response = self::client()->get("/application/nodes/{$node->id}/allocations");
if ($response->failed()) throw self::getException();
return $response->json();
}
/**
* @return PendingRequest
*/
public static function client()
{
return Http::withHeaders([
'Authorization' => 'Bearer ' . env('PTERODACTYL_TOKEN', false),
'Content-type' => 'application/json',
'Accept' => 'Application/vnd.pterodactyl.v1+json',
])->baseUrl(env('PTERODACTYL_URL') . '/api');
}
/**
* @param String $route
* @return string
*/
public static function url(string $route): string
{
return env('PTERODACTYL_URL') . $route;
}
/**
* @param Server $server
* @param Egg $egg
* @param Node $node
* @return Response
*/
public static function createServer(Server $server , Egg $egg , Node $node)
{
return self::client()->post("/application/servers", [
"name" => $server->name,
"external_id" => $server->id,
"user" => $server->user->pterodactyl_id,
"egg" => $egg->id,
"docker_image" => $egg->docker_image,
"startup" => $egg->startup,
"environment" => $egg->getEnvironmentVariables(),
"limits" => [
"memory" => $server->product->memory,
"swap" => $server->product->swap,
"disk" => $server->product->disk,
"io" => $server->product->io,
"cpu" => $server->product->cpu
],
"feature_limits" => [
"databases" => $server->product->databases,
"backups" => $server->product->backups,
"allocations" => 1
],
"allocation" => [
"default" => Pterodactyl::getFreeAllocationId($node)
]
]);
}
public static function suspendServer(Server $server){
$response = self::client()->post("/application/servers/$server->pterodactyl_id/suspend");
if ($response->failed()) throw self::getException();
return $response;
}
public static function unSuspendServer(Server $server){
$response = self::client()->post("/application/servers/$server->pterodactyl_id/unsuspend");
if ($response->failed()) throw self::getException();
return $response;
}
/**
* @return Exception
*/
private static function getException(): Exception
{
return new Exception('Request Failed, is pterodactyl set-up correctly?');
}
}

View file

@ -0,0 +1,82 @@
<?php
namespace App\Console\Commands;
use App\Classes\Pterodactyl;
use App\Models\Server;
use Carbon\Carbon;
use Illuminate\Console\Command;
class ChargeCreditsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'credits:charge';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Charge all users with active servers';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return string
*/
public function handle()
{
Server::chunk(10, function ($servers) {
/** @var Server $server */
foreach ($servers as $server) {
//ignore suspended servers
if ($server->isSuspended()) {
echo Carbon::now()->isoFormat('LLL') . " Ignoring suspended server";
continue;
}
//vars
$user = $server->user;
$price = ($server->product->price / 30) / 24;
//remove credits or suspend server
if ($user->credits >= $price) {
$user->decrement('credits', $price);
//log
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Removed " . number_format($price, 2, '.', '') . " from user (" . $user->name . ") for server (" . $server->name . ")\n";
} else {
$response = Pterodactyl::client()->post("/application/servers/{$server->pterodactyl_id}/suspend");
if ($response->successful()) {
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Suspended server (" . $server->name . ") from user (" . $user->name . ")\n";
$server->update(['suspended' => now()]);
} else {
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] CRITICAL ERROR! Unable to suspend server (" . $server->name . ") from user (" . $user->name . ")\n";
dump($response->json());
}
}
}
});
return 'Charged credits for existing servers!\n';
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Models\Server;
use App\Models\User;
use App\Notifications\ServerCreationError;
use Illuminate\Console\Command;
class notify extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'notify:user {id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send test notifications to this user';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @param int $id
* @return int
*/
public function handle()
{
User::findOrFail($this->argument('id'))->notify(new ServerCreationError(Server::all()[0]));
return 'message send';
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class sendEmailVerification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:send {user}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
echo $this->argument('user');
User::find($this->argument('user'))->get()[0]->sendEmailVerificationNotification();
return 0;
}
}

48
app/Console/Kernel.php Normal file
View file

@ -0,0 +1,48 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Storage;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('credits:charge')->hourly();
$schedule->command('queue:work --once')->everyMinute();
//log cronjob activity
$schedule->call(function () {
Storage::disk('logs')->put('cron.log' , "Last activity from cronjobs - " . now());
})->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
require base_path('routes/console.php');
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View file

@ -0,0 +1,106 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
use Spatie\Activitylog\Models\Activity;
class ActivityLogController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index(Request $request)
{
$cronLogs = Storage::disk('logs')->exists('cron.log') ? Storage::disk('logs')->get('cron.log') : null;
if ($request->input('search')) {
$query = Activity::whereHasMorph('causer' , [User::class] , function($query) use ($request) {
$query->where('name', 'like' , "%{$request->input('search')}%");
})->orderBy('created_at' , 'desc')->paginate(20);
} else {
$query = Activity::orderBy('created_at' , 'desc')->paginate(20);
}
return view('admin.activitylogs.index')->with([
'logs' => $query,
'cronlogs' => $cronLogs
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -0,0 +1,123 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Configuration;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ConfigurationController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index()
{
return view('admin.configurations.index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param Configuration $configuration
* @return Response
*/
public function show(Configuration $configuration)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Configuration $configuration
* @return Response
*/
public function edit(Configuration $configuration)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Configuration $configuration
* @return Response
*/
public function update(Request $request, Configuration $configuration)
{
//
}
/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function updatevalue(Request $request)
{
$configuration = Configuration::findOrFail($request->input('key'));
$request->validate([
'key' => 'required|string|max:191',
'value' => 'required|string|max:191',
]);
$configuration->update($request->all());
return redirect()->route('admin.configurations.index')->with('success', 'configuration has been updated!');
}
/**
* Remove the specified resource from storage.
*
* @param Configuration $configuration
* @return Response
*/
public function destroy(Configuration $configuration)
{
//
}
public function datatable()
{
$query = Configuration::query();
return datatables($query)
->addColumn('actions', function (Configuration $configuration) {
return '<button data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $configuration->key . '\',\'' . $configuration->value . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
})
->editColumn('created_at', function (Configuration $configuration) {
return $configuration->created_at ? $configuration->created_at->diffForHumans() : '';
})
->rawColumns(['actions'])
->make();
}
}

View file

@ -0,0 +1,146 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Egg;
use App\Models\Nest;
use Exception;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class NestsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View
*/
public function index()
{
return view('admin.nests.index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param Nest $nest
* @return Response
*/
public function show(Nest $nest)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Nest $nest
* @return Response
*/
public function edit(Nest $nest)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Nest $nest
* @return RedirectResponse
*/
public function update(Request $request, Nest $nest)
{
$disabled = !!is_null($request->input('disabled'));
$nest->update(['disabled' => $disabled]);
return redirect()->back()->with('success', 'Nest updated');
}
/**
* Remove the specified resource from storage.
*
* @param Nest $nest
* @return Response
*/
public function destroy(Nest $nest)
{
//
}
/**
*
* @throws Exception
*/
public function sync(){
Egg::query()->delete();
Nest::query()->delete();
Nest::syncNests();
Egg::syncEggs();
return redirect()->back()->with('success', 'Nests and Eggs have been synced');
}
/**
* @param Request $request
* @return JsonResponse|mixed
* @throws Exception
*/
public function dataTable(Request $request)
{
$query = Nest::with(['eggs']);
$query->select('nests.*');
return datatables($query)
->addColumn('eggs', function (Nest $nest) {
return $nest->eggs()->count();
})
->addColumn('actions', function (Nest $nest) {
$checked = $nest->disabled == false ? "checked" : "";
return '
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.nests.update', $nest->id) . '">
' . csrf_field() . '
' . method_field("PATCH") . '
<div class="custom-control custom-switch">
<input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$nest->id.'">
<label class="custom-control-label" for="switch'.$nest->id.'"></label>
</div>
</form>
';
})
->editColumn('created_at' , function (Nest $nest) {
return $nest->created_at ? $nest->created_at->diffForHumans() : '';
})
->rawColumns(['actions'])
->make();
}
}

View file

@ -0,0 +1,144 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Location;
use App\Models\Node;
use Exception;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class NodeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View
*/
public function index()
{
return view('admin.nodes.index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param Node $node
* @return Response
*/
public function show(Node $node)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Node $node
* @return Response
*/
public function edit(Node $node)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Node $node
* @return RedirectResponse
*/
public function update(Request $request, Node $node)
{
$disabled = !!is_null($request->input('disabled'));
$node->update(['disabled' => $disabled]);
return redirect()->back()->with('success', 'Node updated');
}
/**
* Remove the specified resource from storage.
*
* @param Node $node
* @return Response
*/
public function destroy(Node $node)
{
//
}
/**
*
* @throws Exception
*/
public function sync(){
Node::query()->delete();
Location::query()->delete();
Node::syncNodes();
return redirect()->back()->with('success', 'Locations and Nodes have been synced');
}
/**
* @param Request $request
* @return JsonResponse|mixed
* @throws Exception
*/
public function dataTable(Request $request)
{
$query = Node::with(['location']);
$query->select('nodes.*');
return datatables($query)
->addColumn('location', function (Node $node) {
return $node->location->name;
})
->addColumn('actions', function (Node $node) {
$checked = $node->disabled == false ? "checked" : "";
return '
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.nodes.update', $node->id) . '">
' . csrf_field() . '
' . method_field("PATCH") . '
<div class="custom-control custom-switch">
<input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$node->id.'">
<label class="custom-control-label" for="switch'.$node->id.'"></label>
</div>
</form>
';
})
->editColumn('created_at' , function (Node $node) {
return $node->created_at ? $node->created_at->diffForHumans() : '';
})
->rawColumns(['actions'])
->make();
}
}

View file

@ -0,0 +1,188 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Payment;
use App\Models\PaypalProduct;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\ProductionEnvironment;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
use PayPalHttp\HttpException;
class PaymentController extends Controller
{
protected $allowedAmounts = [
'87',
'350',
'1000',
'2000',
'4000'
];
public function index(){
return view('admin.payments.index')->with([
'payments' => Payment::paginate(15)
]);
}
/**
* @param Request $request
* @param PaypalProduct $paypalProduct
* @return Application|Factory|View
*/
public function checkOut(Request $request, PaypalProduct $paypalProduct)
{
return view('store.checkout')->with([
'product' => $paypalProduct
]);
}
/**
* @param Request $request
* @param PaypalProduct $paypalProduct
* @return RedirectResponse
*/
public function pay(Request $request , PaypalProduct $paypalProduct)
{
$request = new OrdersCreateRequest();
$request->prefer('return=representation');
$request->body = [
"intent" => "CAPTURE",
"purchase_units" => [
[
"reference_id" => uniqid(),
"amount" => [
"value" => $paypalProduct->price,
"currency_code" => strtoupper($paypalProduct->currency_code)
]
]
],
"application_context" => [
"cancel_url" => route('payment.cancel'),
"return_url" => route('payment.success', ['product' => $paypalProduct->id]),
'brand_name' => config('app.name', 'Laravel') ,
]
];
try {
// Call API with your client and get a response for your call
$response = $this->getPayPalClient()->execute($request);
return redirect()->away($response->result->links[1]->href);
// If call returns body in response, you can get the deserialized version from the result attribute of the response
} catch (HttpException $ex) {
echo $ex->statusCode;
dd(json_decode($ex->getMessage()));
}
}
/**
* @return PayPalHttpClient
*/
protected function getPayPalClient()
{
$environment = env('APP_ENV') == 'local'
? new SandboxEnvironment($this->getClientId(), $this->getClientSecret())
: new ProductionEnvironment($this->getClientId(), $this->getClientSecret());
return new PayPalHttpClient($environment);
}
/**
* @return string
*/
protected function getClientId()
{
return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID');
}
/**
* @return string
*/
protected function getClientSecret()
{
return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_SECRET') : env('PAYPAL_SECRET');
}
/**
* @param Request $laravelRequest
*/
public function success(Request $laravelRequest)
{
$paypalProduct = PaypalProduct::findOrFail($laravelRequest->input('product'));
$request = new OrdersCaptureRequest($laravelRequest->input('token'));
$request->prefer('return=representation');
try {
// Call API with your client and get a response for your call
$response = $this->getPayPalClient()->execute($request);
if ($response->statusCode == 201 || $response->statusCode == 200) {
//update credits
Auth::user()->increment('credits', $paypalProduct->quantity);
//update server limit
if (Auth::user()->server_limit < 10) {
Auth::user()->update(['server_limit' => 10]);
}
//update role
if (Auth::user()->role == 'member') {
Auth::user()->update(['role' => 'client']);
}
//store payment
Payment::create([
'user_id' => Auth::user()->id,
'payment_id' => $response->result->id,
'payer_id' => $laravelRequest->input('PayerID'),
'type' => 'Credits',
'status' => $response->result->status,
'amount' => $paypalProduct->quantity,
'price' => $paypalProduct->price,
'payer' => json_encode($response->result->payer),
]);
//redirect back to home
return redirect()->route('home')->with('success', 'Credits have been increased!');
}
// If call returns body in response, you can get the deserialized version from the result attribute of the response
if (env('APP_ENV') == 'local') {
dd($response);
} else {
abort(500);
}
} catch (HttpException $ex) {
if (env('APP_ENV') == 'local') {
echo $ex->statusCode;
dd($ex->getMessage());
} else {
abort(422);
}
}
}
/**
* @param Request $request
*/
public function cancel(Request $request)
{
return redirect()->route('store.index')->with('success', 'Payment Canceled');
}
}

View file

@ -0,0 +1,181 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Models\PaypalProduct;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Illuminate\Validation\Rule;
class PaypalProductController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index(Request $request)
{
$isPaypalSetup = false;
if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
return view('admin.store.index' , [
'isPaypalSetup' => $isPaypalSetup
]);
}
/**
* Show the form for creating a new resource.
*
* @return Application|Factory|View|Response
*/
public function create()
{
return view('admin.store.create', [
'currencyCodes' => config('currency_codes')
]);
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request)
{
$request->validate([
"disabled" => "nullable",
"type" => "required|string",
"currency_code" => ["required", "string", "max:3", Rule::in(config('currency_codes'))],
"price" => "required|regex:/^\d+(\.\d{1,2})?$/",
"quantity" => "required|numeric",
"description" => "required|string|max:60",
"display" => "required|string|max:60",
]);
$disabled = !is_null($request->input('disabled'));
PaypalProduct::create(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.store.index')->with('success', 'store item has been created!');
}
/**
* Display the specified resource.
*
* @param PaypalProduct $paypalProduct
* @return Response
*/
public function show(PaypalProduct $paypalProduct)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param PaypalProduct $paypalProduct
* @return Application|Factory|View|Response
*/
public function edit(PaypalProduct $paypalProduct)
{
return view('admin.store.edit', [
'currencyCodes' => config('currency_codes'),
'paypalProduct' => $paypalProduct
]);
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param PaypalProduct $paypalProduct
* @return RedirectResponse
*/
public function update(Request $request, PaypalProduct $paypalProduct)
{
$request->validate([
"disabled" => "nullable",
"type" => "required|string",
"currency_code" => ["required", "string", "max:3", Rule::in(config('currency_codes'))],
"price" => "required|regex:/^\d+(\.\d{1,2})?$/",
"quantity" => "required|numeric|max:100000000",
"description" => "required|string|max:60",
"display" => "required|string|max:60",
]);
$disabled = !is_null($request->input('disabled'));
$paypalProduct->update(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.store.index')->with('success', 'store item has been updated!');
}
/**
* @param Request $request
* @param PaypalProduct $paypalProduct
* @return RedirectResponse
*/
public function disable(Request $request, PaypalProduct $paypalProduct)
{
$paypalProduct->update(['disabled' => !$paypalProduct->disabled]);
return redirect()->route('admin.store.index')->with('success', 'product has been updated!');
}
/**
* Remove the specified resource from storage.
*
* @param PaypalProduct $paypalProduct
* @return RedirectResponse
*/
public function destroy(PaypalProduct $paypalProduct)
{
$paypalProduct->delete();
return redirect()->back()->with('success', 'store item has been removed!');
}
public function dataTable()
{
$query = PaypalProduct::query();
return datatables($query)
->addColumn('actions', function (PaypalProduct $paypalProduct) {
return '
<a data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.store.edit', $paypalProduct->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.destroy', $paypalProduct->id) . '">
' . csrf_field() . '
' . method_field("DELETE") . '
<button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
</form>
';
})
->addColumn('disabled', function (PaypalProduct $paypalProduct) {
$checked = $paypalProduct->disabled == false ? "checked" : "";
return '
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.disable', $paypalProduct->id) . '">
' . csrf_field() . '
' . method_field("PATCH") . '
<div class="custom-control custom-switch">
<input ' . $checked . ' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch' . $paypalProduct->id . '">
<label class="custom-control-label" for="switch' . $paypalProduct->id . '"></label>
</div>
</form>
';
})
->editColumn('created_at', function (PaypalProduct $paypalProduct) {
return $paypalProduct->created_at ? $paypalProduct->created_at->diffForHumans() : '';
})
->editColumn('price', function (PaypalProduct $paypalProduct) {
return $paypalProduct->formatCurrency();
})
->rawColumns(['actions', 'disabled'])
->make();
}
}

View file

@ -0,0 +1,197 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Product;
use Exception;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ProductController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View
*/
public function index()
{
return view('admin.products.index');
}
/**
* Show the form for creating a new resource.
*
* @return Application|Factory|View
*/
public function create()
{
return view('admin.products.create');
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request)
{
$request->validate([
"name" => "required|max:30",
"price" => "required|numeric|max:1000000|min:0",
"memory" => "required|numeric|max:1000000|min:5",
"cpu" => "required|numeric|max:1000000|min:5",
"swap" => "required|numeric|max:1000000|min:0",
"description" => "required",
"disk" => "required|numeric|max:1000000|min:5",
"io" => "required|numeric|max:1000000|min:0",
"databases" => "required|numeric|max:1000000|min:0",
"backups" => "required|numeric|max:1000000|min:0",
"allocations" => "required|numeric|max:1000000|min:0",
"disabled" => "nullable",
]);
$disabled = !is_null($request->input('disabled'));
Product::create(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.products.index')->with('success', 'product has been created!');
}
/**
* Display the specified resource.
*
* @param Product $product
* @return Application|Factory|View
*/
public function show(Product $product)
{
return view('admin.products.show', [
'product' => $product
]);
}
/**
* Show the form for editing the specified resource.
*
* @param Product $product
* @return Application|Factory|View
*/
public function edit(Product $product)
{
return view('admin.products.edit', [
'product' => $product
]);
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Product $product
* @return RedirectResponse
*/
public function update(Request $request, Product $product): RedirectResponse
{
$request->validate([
"name" => "required|max:30",
"price" => "required|numeric|max:1000000|min:0",
"memory" => "required|numeric|max:1000000|min:5",
"cpu" => "required|numeric|max:1000000|min:5",
"swap" => "required|numeric|max:1000000|min:0",
"description" => "required",
"disk" => "required|numeric|max:1000000|min:5",
"io" => "required|numeric|max:1000000|min:0",
"databases" => "required|numeric|max:1000000|min:0",
"backups" => "required|numeric|max:1000000|min:0",
"allocations" => "required|numeric|max:1000000|min:0",
"disabled" => "nullable",
]);
$disabled = !is_null($request->input('disabled'));
$product->update(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.products.index')->with('success', 'product has been updated!');
}
/**
* @param Request $request
* @param Product $product
* @return RedirectResponse
*/
public function disable(Request $request, Product $product) {
$product->update(['disabled' => !$product->disabled]);
return redirect()->route('admin.products.index')->with('success', 'product has been updated!');
}
/**
* Remove the specified resource from storage.
*
* @param Product $product
* @return RedirectResponse
*/
public function destroy(Product $product)
{
$servers = $product->servers()->count();
if ($servers > 0) {
return redirect()->back()->with('error', "Product cannot be removed while it's linked to {$servers} servers");
}
$product->delete();
return redirect()->back()->with('success', 'product has been removed!');
}
/**
* @return JsonResponse|mixed
* @throws Exception|Exception
*/
public function dataTable()
{
$query = Product::with(['servers']);
return datatables($query)
->addColumn('actions', function (Product $product) {
return '
<a data-content="Show" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.products.show', $product->id) . '" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
<a data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.products.edit', $product->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.products.destroy', $product->id) . '">
' . csrf_field() . '
' . method_field("DELETE") . '
<button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
</form>
';
})
->addColumn('servers', function (Product $product) {
return $product->servers()->count();
})
->addColumn('disabled', function (Product $product) {
$checked = $product->disabled == false ? "checked" : "";
return '
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.products.disable', $product->id) . '">
' . csrf_field() . '
' . method_field("PATCH") . '
<div class="custom-control custom-switch">
<input '.$checked.' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch'.$product->id.'">
<label class="custom-control-label" for="switch'.$product->id.'"></label>
</div>
</form>
';
})
->editColumn('created_at', function (Product $product) {
return $product->created_at ? $product->created_at->diffForHumans() : '';
})
->rawColumns(['actions', 'disabled'])
->make();
}
}

View file

@ -0,0 +1,165 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Classes\Pterodactyl;
use App\Classes\PterodactylWrapper;
use App\Http\Controllers\Controller;
use App\Models\Server;
use Exception;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ServerController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index()
{
return view('admin.servers.index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param Server $server
* @return Response
*/
public function show(Server $server)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Server $server
* @return Response
*/
public function edit(Server $server)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Server $server
* @return Response
*/
public function update(Request $request, Server $server)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param Server $server
* @return RedirectResponse|Response
*/
public function destroy(Server $server)
{
$server->delete();
return redirect()->back()->with('success', 'server has been removed!');
}
/**
* @param Server $server
* @return RedirectResponse
*/
public function toggleSuspended(Server $server){
try {
$server->isSuspended() ? $server->unSuspend() : $server->suspend();
} catch (Exception $exception) {
return redirect()->back()->with('error', $exception->getMessage());
}
return redirect()->back()->with('success', 'server has been updated!');
}
/**
* @return JsonResponse|mixed
* @throws Exception
*/
public function dataTable(Request $request)
{
$query = Server::with(['user', 'product', 'egg']);
if ($request->has('product')) $query->where('product_id', '=', $request->input('product'));
if ($request->has('user')) $query->where('user_id', '=', $request->input('user'));
$query->select('servers.*');
return datatables($query)
->addColumn('user', function (Server $server) {
return '<a href="' . route('admin.users.show', $server->user->id) . '">' . $server->user->name . '</a>';
})
->addColumn('resources', function (Server $server) {
return $server->product->description;
})
->addColumn('actions', function (Server $server) {
$suspendColor = $server->isSuspended() ? "btn-success" : "btn-warning";
$suspendIcon = $server->isSuspended() ? "fa-play-circle" : "fa-pause-circle";
$suspendText = $server->isSuspended() ? "Unsuspend" : "Suspend";
return '
<form class="d-inline" method="post" action="' . route('admin.servers.togglesuspend', $server->id) . '">
' . csrf_field() . '
<button data-content="'.$suspendText.'" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm '.$suspendColor.' text-white mr-1"><i class="far '.$suspendIcon.'"></i></button>
</form>
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.servers.destroy', $server->id) . '">
' . csrf_field() . '
' . method_field("DELETE") . '
<button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
</form>
';
})
->addColumn('status', function (Server $server) {
$labelColor = $server->isSuspended() ? 'text-danger' : 'text-success';
return '<i class="fas ' . $labelColor . ' fa-circle mr-2"></i>';
})
->editColumn('created_at', function (Server $server) {
return $server->created_at ? $server->created_at->diffForHumans() : '';
})
->editColumn('suspended', function (Server $server) {
return $server->suspended ? $server->suspended->diffForHumans() : '';
})
->editColumn('name', function (Server $server) {
return '<a class="text-info" target="_blank" href="' . env('PTERODACTYL_URL', 'http://localhost') . '/admin/servers/view/' . $server->pterodactyl_id . '">' . $server->name . '</a>';
})
->rawColumns(['user', 'actions', 'status', 'name'])
->make();
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
class SettingsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index()
{
return view('admin.settings.index');
}
public function updateIcons(Request $request){
$request->validate([
'favicon' => 'required',
'icon' => 'required',
]);
//store favicon
$favicon = $request->input('favicon');
$favicon = json_decode($favicon);
$favicon = explode(",",$favicon->output->image)[1];
Storage::disk('public')->put('favicon.ico' , base64_decode($favicon));
//store dashboard icon
$icon = $request->input('icon');
$icon = json_decode($icon);
$icon = explode(",",$icon->output->image)[1];
Storage::disk('public')->put('icon.png' , base64_decode($icon));
return redirect()->route('admin.settings.index')->with('success', 'Icons updated!');
}
}

View file

@ -0,0 +1,214 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @param Request $request
* @return Application|Factory|View|Response
*/
public function index(Request $request)
{
return view('admin.users.index');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param User $user
* @return Application|Factory|View|Response
*/
public function show(User $user)
{
return view('admin.users.show')->with([
'user' => $user
]);
}
/**
* Show the form for editing the specified resource.
*
* @param User $user
* @return Application|Factory|View|Response
*/
public function edit(User $user)
{
return view('admin.users.edit')->with([
'user' => $user
]);
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param User $user
* @return RedirectResponse
*/
public function update(Request $request, User $user)
{
$request->validate([
"name" => "required|string|min:4|max:30",
"email" => "required|string|email",
"credits" => "required|numeric|min:0|max:1000000",
"server_limit" => "required|numeric|min:0|max:1000000",
"role" => Rule::in(['admin', 'mod', 'client', 'member']),
]);
$user->update($request->all());
return redirect()->route('admin.users.index')->with('success', 'User updated!');
}
/**
* Remove the specified resource from storage.
*
* @param User $user
* @return RedirectResponse
*/
public function destroy(User $user)
{
$user->delete();
return redirect()->back()->with('success', 'user has been removed!');
}
/**
* @param Request $request
* @param User $user
* @return RedirectResponse
*/
public function loginAs(Request $request, User $user)
{
$request->session()->put('previousUser', Auth::user()->id);
Auth::login($user);
return redirect()->route('home');
}
/**
* @param Request $request
* @return RedirectResponse
*/
public function logBackIn(Request $request)
{
Auth::loginUsingId($request->session()->get('previousUser'), true);
$request->session()->remove('previousUser');
return redirect()->route('admin.users.index');
}
/**
* @param User $user
* @return RedirectResponse
*/
public function reSendVerificationEmail(User $user)
{
if ($user->hasVerifiedEmail())
return redirect()->back()->with('error', 'User has already verified there email');
$user->sendEmailVerificationNotification();
return redirect()->back()->with('success', 'User has been emailed again!');
}
/**
*
* @throws \Exception
*/
public function dataTable()
{
$query = User::with(['discordUser', 'servers'])->select('users.*');
return datatables($query)
->addColumn('avatar', function (User $user) {
return '<img width="28px" height="28px" class="rounded-circle ml-1" src="' . $user->getAvatar() . '">';
})
->addColumn('credits', function (User $user) {
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
})
->addColumn('usage', function (User $user) {
return '<i class="fas fa-coins mr-2"></i> ' . $user->creditUsage();
})
->addColumn('verified', function (User $user) {
return $user->getVerifiedStatus();
})
->addColumn('servers', function (User $user) {
return $user->servers->count();
})
->addColumn('discordId', function (User $user) {
return $user->discordUser ? $user->discordUser->id : '';
})
->addColumn('last_seen', function (User $user) {
return $user->last_seen ? $user->last_seen->diffForHumans() : '';
})
->addColumn('actions', function (User $user) {
return '
<a data-content="Resend verification" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.reSendVerificationEmail', $user->id) . '" class="btn btn-sm text-white btn-light mr-1"><i class="far fa-envelope"></i></a>
<a data-content="Login as user" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.loginas', $user->id) . '" class="btn btn-sm btn-primary mr-1"><i class="fas fa-sign-in-alt"></i></a>
<a data-content="Show" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.show', $user->id) . '" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-eye"></i></a>
<a data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.users.edit', $user->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.users.destroy', $user->id) . '">
' . csrf_field() . '
' . method_field("DELETE") . '
<button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
</form>
';
})
->editColumn('role', function (User $user) {
switch ($user->role) {
case 'admin' :
$badgeColor = 'badge-danger';
break;
case 'mod' :
$badgeColor = 'badge-info';
break;
case 'client' :
$badgeColor = 'badge-success';
break;
default :
$badgeColor = 'badge-secondary';
break;
}
return '<span class="badge ' . $badgeColor . '">' . $user->role . '</span>';
})
->orderColumn('last_seen', function ($query, $order) {
$query->orderBy('last_seen', $order);
})
->rawColumns(['avatar', 'credits', 'role', 'usage', 'actions', 'last_seen'])
->make(true);
}
}

View file

@ -0,0 +1,79 @@
<?php
//
//namespace App\Http\Controllers\Api;
//
//use App\Http\Controllers\Controller;
//use App\Models\DiscordUser;
//use App\Models\User;
//use Illuminate\Contracts\Foundation\Application;
//use Illuminate\Contracts\Routing\ResponseFactory;
//use Illuminate\Http\Request;
//use Illuminate\Http\Response;
//use Illuminate\Validation\Rule;
//
//class UserController extends Controller
//{
// /**
// * Display a listing of the resource.
// *
// * @return Response
// */
// public function index(Request $request)
// {
// return User::paginate($request->query('per_page') ?? 50);
// }
//
//
// /**
// * Display the specified resource.
// *
// * @param int $id
// * @return User
// */
// public function show(int $id)
// {
// $discordUser = DiscordUser::find($id);
// return $discordUser ? $discordUser->user : User::findOrFail($id);
// }
//
//
// /**
// * Update the specified resource in storage.
// *
// * @param Request $request
// * @param int $id
// * @return User
// */
// public function update(Request $request, int $id)
// {
// $discordUser = DiscordUser::find($id);
// $user = $discordUser ? $discordUser->user : User::findOrFail($id);
//
// $request->validate([
// "name" => "sometimes|string|min:4|max:30",
// "email" => "sometimes|string|email",
// "credits" => "sometimes|numeric|min:0|max:1000000",
// "server_limit" => "sometimes|numeric|min:0|max:1000000",
// "role" => ['sometimes', Rule::in(['admin', 'mod', 'client', 'member'])],
// ]);
//
// $user->update($request->all());
//
// return $user;
// }
//
// /**
// * Remove the specified resource from storage.
// *
// * @param int $id
// * @return Application|ResponseFactory|Response|void
// */
// public function destroy(int $id)
// {
// $discordUser = DiscordUser::find($id);
// $user = $discordUser ? $discordUser->user : User::findOrFail($id);
//
// $user->delete();
// return response($user, 200);
// }
//}

View file

@ -0,0 +1,49 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Configuration;
use App\Models\DiscordUser;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
class VerifyController extends Controller
{
/**
* @param Request $request
* @return JsonResponse
* @throws ValidationException
*/
public function verify(Request $request){
$request->validate([
'user_id' => 'required|exists:discord_users,id'
] , [
'exists' => "You have not linked your account to our site"
]);
$discordUser = DiscordUser::findOrFail($request->input('user_id'));
if(is_null($discordUser->user)){
throw ValidationException::withMessages([
'user_id' => ['User does not exist']
]);
}
if (!is_null($discordUser->user->discord_verified_at)) {
throw ValidationException::withMessages([
'user_id' => ['Already verified!']
]);
}
$discordUser->user->update([
'discord_verified_at' => now()
]);
$discordUser->user->increment('credits' , Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD'));
$discordUser->user->increment('server_limit' , Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD'));
return response()->json($discordUser , 200);
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View file

@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}

View file

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Classes\Pterodactyl;
use App\Http\Controllers\Controller;
use App\Models\Configuration;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
//check if ip has already made an account
$data['ip'] = session()->get('ip') ?? request()->ip();
if (User::where('ip', '=', request()->ip())->exists()) session()->put('ip', request()->ip());
//check if registered cookie exists as extra defense
if (isset($_COOKIE['4b3403665fea6'])) {
$data['registered'] = true;
}
return Validator::make($data, [
'name' => ['required', 'string', 'max:30', 'min:4', 'alpha_num', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:64', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
'g-recaptcha-response' => ['recaptcha'],
'ip' => ['unique:users'],
'registered' => ['nullable', 'boolean', 'in:true']
], [
'ip.unique' => "You have already made an account with us! Please contact support if you think this is incorrect.",
'registered.in' => "You have already made an account with us! Please contact support if you think this is incorrect."
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User|\Illuminate\Http\RedirectResponse
*/
protected function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'credits' => Configuration::getValueByKey('INITIAL_CREDITS'),
'server_limit' => Configuration::getValueByKey('INITIAL_SERVER_LIMIT'),
'password' => Hash::make($data['password']),
]);
$response = Pterodactyl::client()->post('/application/users', [
"external_id" => (string)$user->id,
"username" => $user->name,
"email" => $user->email,
"first_name" => $user->name,
"last_name" => $user->name,
"password" => $data['password'],
"root_admin" => false,
"language" => "en"
]);
if ($response->failed()) {
$user->delete();
redirect()->route('register')->with('error', 'pterodactyl error');
return $user;
}
$user->update([
'pterodactyl_id' => $response->json()['attributes']['id']
]);
return $user;
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\DiscordUser;
use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite;
class SocialiteController extends Controller
{
public function redirect()
{
return Socialite::driver('discord')->redirect();
}
public function callback()
{
if (Auth::guest()) return abort(500);
$discord = Socialite::driver('discord')->user();
$discordUser = DiscordUser::find($discord->id);
if (is_null($discordUser)) DiscordUser::create(array_merge($discord->user, ['user_id' => Auth::user()->id]));
else $discordUser->update($discord->user);
return redirect()->route('profile.index')->with('success', 'Discord account linked!');
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View file

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @param Request $request
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
//set cookie as extra layer of defense against users that make multiple accounts
setcookie('4b3403665fea6' , base64_encode(1) , time() + (20 * 365 * 24 * 60 * 60));
$useage = 0;
foreach (Auth::user()->Servers as $server){
$useage += $server->product->price;
}
return view('home')->with([
'useage' => $useage
]);
}
}

View file

@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
class NotificationController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
{
$notifications = Auth::user()->notifications()->paginate();
return view('notifications.index')->with([
'notifications' => $notifications
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param string $id
* @return Factory|View
*/
public function show($id)
{
$notification = Auth::user()->notifications()->findOrFail($id);
$notification->markAsRead();
return view('notifications.show')->with([
'notification' => $notification
]);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -0,0 +1,149 @@
<?php
namespace App\Http\Controllers;
use App\Models\Configuration;
use App\Models\User;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
{
return view('profile.index')->with([
'user' => Auth::user(),
'discord_verify_command' => Configuration::getValueByKey('DISCORD_VERIFY_COMMAND')
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return RedirectResponse
*/
public function update(Request $request, int $id)
{
//prevent other users from editing a user
if ($id != Auth::user()->id) dd(401);
$user = User::findOrFail($id);
//update password if necessary
if (!is_null($request->input('new_password'))){
//validate password request
$request->validate([
'current_password' => [
'required' ,
function ($attribute, $value, $fail) use ($user) {
if (!Hash::check($value, $user->password)) {
$fail('The '.$attribute.' is invalid.');
}
},
],
'new_password' => 'required|string|min:8',
'new_password_confirmation' => 'required|same:new_password'
]);
//update password
$user->update([
'password' => Hash::make($request->input('new_password')),
]);
}
//validate request
$request->validate([
'name' => 'required|min:4|max:30|alpha_num|unique:users,name,'.$id.',id',
'email' => 'required|email|max:64|unique:users,email,'.$id.',id',
'avatar' => 'nullable'
]);
//update avatar
if(!is_null($request->input('avatar'))){
$avatar = json_decode($request->input('avatar'));
if ($avatar->input->size > 3000000) abort(500);
$user->update([
'avatar' => $avatar->output->image,
]);
} else {
$user->update([
'avatar' => null,
]);
}
//update name and email
$user->update([
'name' => $request->input('name'),
'email' => $request->input('email'),
]);
return redirect()->route('profile.index')->with('success' , 'profile updated');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -0,0 +1,173 @@
<?php
namespace App\Http\Controllers;
use App\Classes\Pterodactyl;
use App\Models\Configuration;
use App\Models\Egg;
use App\Models\Location;
use App\Models\Nest;
use App\Models\Node;
use App\Models\Product;
use App\Models\Server;
use App\Notifications\ServerCreationError;
use Exception;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class ServerController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
{
return view('servers.index')->with([
'servers' => Auth::user()->Servers
]);
}
/**
* Show the form for creating a new resource.
*
* @return Factory|View|RedirectResponse
*/
public function create()
{
//limit
if (Auth::user()->Servers->count() >= Auth::user()->server_limit) {
return redirect()->route('servers.index')->with('error', "You've already reached your server limit!");
}
//minimum credits
if (Auth::user()->credits <= Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)) {
return redirect()->route('servers.index')->with('error', "You do not have the required amount of credits to create a new server!");
}
return view('servers.create')->with([
'products' => Product::where('disabled' , '=' , false)->orderBy('price', 'asc')->get(),
'locations' => Location::whereHas('nodes' , function ($query) {
$query->where('disabled' , '=' , false);
})->get(),
'nests' => Nest::where('disabled' , '=' , false)->get(),
]);
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request)
{
$request->validate([
"name" => "required|max:191",
"description" => "nullable|max:191",
"node_id" => "required|exists:nodes,id",
"egg_id" => "required|exists:eggs,id",
"product_id" => "required|exists:products,id",
]);
//limit validation
if (Auth::user()->servers()->count() >= Auth::user()->server_limit) {
return redirect()->route('servers.index')->with('error', 'Server limit reached!');
}
//minimum credits
if (Auth::user()->credits <= Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)) {
return redirect()->route('servers.index')->with('error', "You do not have the required amount of credits to create a new server!");
}
//create server
$egg = Egg::findOrFail($request->input('egg_id'));
$server = Auth::user()->servers()->create($request->all());
$node = Node::findOrFail($request->input('node_id'));
//create server on pterodactyl
$response = Pterodactyl::createServer($server , $egg , $node);
if (is_null($response)) return $this->serverCreationFailed($server);
if ($response->failed()) return $this->serverCreationFailed($server);
//update server with pterodactyl_id
$server->update([
'pterodactyl_id' => $response->json()['attributes']['id'],
'identifier' => $response->json()['attributes']['identifier']
]);
return redirect()->route('servers.index')->with('success', 'server created');
}
/**
* Quick Fix
* @param Server $server
* @return RedirectResponse
*/
private function serverCreationFailed(Server $server): RedirectResponse
{
$server->delete();
Auth::user()->notify(new ServerCreationError($server));
return redirect()->route('servers.index')->with('error', 'No allocations satisfying the requirements for automatic deployment were found.');
}
/**
* Display the specified resource.
*
* @param Server $server
* @return Response
*/
public function show(Server $server)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Server $server
* @return Response
*/
public function edit(Server $server)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Server $server
* @return Response
*/
public function update(Request $request, Server $server)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param Server $server
* @return RedirectResponse
* @throws Exception
*/
public function destroy(Server $server)
{
$server->delete();
return redirect()->route('servers.index')->with('success', 'server removed');
}
}

View file

@ -0,0 +1,95 @@
<?php
namespace App\Http\Controllers;
use App\Models\PaypalProduct;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class StoreController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index()
{
$isPaypalSetup = false;
if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
return view('store.index')->with([
'products' => PaypalProduct::where('disabled' , '=' , false)->orderBy('price' , 'asc')->get(),
'isPaypalSetup' => $isPaypalSetup
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

70
app/Http/Kernel.php Normal file
View file

@ -0,0 +1,70 @@
<?php
namespace App\Http;
use App\Http\Middleware\isAdmin;
use App\Http\Middleware\LastSeen;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
LastSeen::class
],
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'admin' => isAdmin::class
];
}

View file

@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,40 @@
<?php
namespace App\Http\Middleware;
use Closure;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LastSeen
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (env('APP_ENV' , 'local') == 'local'){
return $next($request);
}
if (!Auth::check()) {
return $next($request);
}
if ($request->session()->has('previousUser')) {
return $next($request);
}
Auth::user()->update([
'last_seen' => now(),
'ip' => $request->ip()
]);
return $next($request);
}
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null ...$guards
* @return mixed
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class isAdmin
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (Auth::user() && Auth::user()->role == 'admin') {
return $next($request);
}
return redirect(RouteServiceProvider::HOME);
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\Listeners;
use App\Models\Configuration;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class Verified
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
$event->user->increment('server_limit' , Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
$event->user->increment('credits' , Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
}
}

View file

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Configuration extends Model
{
use HasFactory;
public $primaryKey = 'key';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'key',
'value',
'type',
];
/**
* @param string $key
* @param $default
* @return mixed
*/
public static function getValueByKey(string $key , $default = null)
{
$configuration = self::find($key);
return $configuration ? $configuration->value : $default;
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Activitylog\Traits\LogsActivity;
class DiscordUser extends Model
{
use HasFactory;
protected $guarded = [];
public $incrementing = false;
/**
* @return BelongsTo
*/
public function user(){
return $this->belongsTo(User::class);
}
/**
* @return string
*/
public function getAvatar(){
return "https://cdn.discordapp.com/avatars/" . $this->id . "/" . $this->avatar . ".png";
}
}

80
app/Models/Egg.php Normal file
View file

@ -0,0 +1,80 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Egg extends Model
{
use HasFactory;
public $incrementing = false;
protected $fillable = [
'id',
'nest_id',
'name',
'description',
'docker_image',
'startup',
'environment',
];
/**
* @return BelongsTo
*/
public function nest()
{
return $this->belongsTo(Nest::class, 'id', 'nest_id');
}
/**
* @return array
*/
public function getEnvironmentVariables()
{
$array = [];
foreach (json_decode($this->environment) as $variable) {
foreach ($variable as $key => $value){
$array[$key] = $value;
}
}
return $array;
}
public static function syncEggs(){
Nest::all()->each(function (Nest $nest) {
$eggs = Pterodactyl::getEggs($nest);
foreach ($eggs as $egg){
$array = [];
$environment = [];
$array['id'] = $egg['attributes']['id'];
$array['nest_id'] = $egg['attributes']['nest'];
$array['name'] = $egg['attributes']['name'];
$array['description'] = $egg['attributes']['description'];
$array['docker_image'] = $egg['attributes']['docker_image'];
$array['startup'] = $egg['attributes']['startup'];
//get environment variables
foreach ($egg['attributes']['relationships']['variables']['data'] as $variable){
$environment[$variable['attributes']['env_variable']] = $variable['attributes']['default_value'];
}
$array['environment'] = json_encode([$environment]);
self::firstOrCreate(['id' => $array['id']] , $array);
}
});
}
}

42
app/Models/Location.php Normal file
View file

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
use HasFactory;
public $incrementing = false;
public $guarded = [];
public function nodes(){
return $this->hasMany(Node::class , 'location_id' , 'id');
}
/**
* Sync locations with pterodactyl panel
* @throws Exception
*/
public static function syncLocations(){
$locations = Pterodactyl::getLocations();
$locations = array_map(function($val) {
return array(
'id' => $val['attributes']['id'],
'name' => $val['attributes']['short'],
'description' => $val['attributes']['long']
);
}, $locations);
foreach ($locations as $location) {
self::firstOrCreate(['id' => $location['id']] , $location);
}
}
}

35
app/Models/Nest.php Normal file
View file

@ -0,0 +1,35 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Nest extends Model
{
use HasFactory;
public $incrementing = false;
public $fillable = [
'id',
'name',
'description',
'disabled',
];
public function eggs(){
return $this->hasMany(Egg::class);
}
public static function syncNests(){
self::query()->delete();
$nests = Pterodactyl::getNests();
foreach ($nests as $nest) {
self::firstOrCreate(['id' => $nest['attributes']['id']] , array_merge($nest['attributes'] , ['disabled' => '1']));
}
}
}

51
app/Models/Node.php Normal file
View file

@ -0,0 +1,51 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Node extends Model
{
use HasFactory;
public $incrementing = false;
public $guarded = [];
/**
* @return BelongsTo
*/
public function location(): BelongsTo
{
return $this->belongsTo(Location::class);
}
/**
* @throws Exception
*/
public static function syncNodes(){
Location::syncLocations();
$nodes = Pterodactyl::getNodes();
$nodes = array_map(function($node) {
return array(
'id' => $node['attributes']['id'],
'location_id' => $node['attributes']['location_id'],
'name' => $node['attributes']['name'],
'description' => $node['attributes']['description'],
'disabled' => '1'
);
}, $nodes);
foreach ($nodes as $node) {
self::firstOrCreate(['id' => $node['id']] , $node);
}
}
}

54
app/Models/Payment.php Normal file
View file

@ -0,0 +1,54 @@
<?php
namespace App\Models;
use Hidehalo\Nanoid\Client;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Activitylog\Traits\LogsActivity;
class Payment extends Model
{
use HasFactory;
use LogsActivity;
public $incrementing = false;
/**
* @var string[]
*/
protected $fillable = [
'id',
'user_id',
'payment_id',
'payer_id',
'payer',
'status',
'type',
'amount',
'price',
];
public static function boot() {
parent::boot();
static::creating(function(Payment $payment) {
$client = new Client();
$payment->{$payment->getKeyName()} = $client->generateId($size = 8);
});
}
/**
* @return BelongsTo
*/
public function User(){
return $this->belongsTo(User::class);
}
public function Price()
{
return number_format($this->price, 2, '.', '');
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Hidehalo\Nanoid\Client;
use Illuminate\Database\Eloquent\Model;
use NumberFormatter;
use Spatie\Activitylog\Traits\LogsActivity;
class PaypalProduct extends Model
{
use LogsActivity;
/**
* @var bool
*/
public $incrementing = false;
/**
* @var string[]
*/
protected $fillable = [
"type",
"price",
"description",
"display",
"currency_code",
"quantity",
"disabled",
];
public static function boot()
{
parent::boot();
static::creating(function (PaypalProduct $paypalProduct) {
$client = new Client();
$paypalProduct->{$paypalProduct->getKeyName()} = $client->generateId($size = 21);
});
}
public function formatCurrency($locale = 'en_US')
{
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
return $formatter->formatCurrency($this->price, $this->currency_code);
}
}

37
app/Models/Product.php Normal file
View file

@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Hidehalo\Nanoid\Client;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Activitylog\Traits\LogsActivity;
class Product extends Model
{
use HasFactory, LogsActivity;
public $incrementing = false;
protected $guarded = ['id'];
public static function boot() {
parent::boot();
static::creating(function(Product $product) {
$client = new Client();
$product->{$product->getKeyName()} = $client->generateId($size = 21);
});
}
/**
* @return BelongsTo
*/
public function servers(): BelongsTo
{
return $this->belongsTo(Server::class , 'id' , 'product_id');
}
}

159
app/Models/Server.php Normal file
View file

@ -0,0 +1,159 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use Exception;
use GuzzleHttp\Promise\PromiseInterface;
use Hidehalo\Nanoid\Client;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Http\Client\Response;
use Spatie\Activitylog\Traits\LogsActivity;
/**
* Class Server
* @package App\Models
*/
class Server extends Model
{
use HasFactory;
use LogsActivity;
/**
* @var bool
*/
public $incrementing = false;
/**
* @var string[]
*/
protected static $ignoreChangedAttributes = ['pterodactyl_id' , 'identifier' , 'updated_at'];
/**
* @var string[]
*/
protected static $logAttributes = ['name', 'description'];
/**
* @var string[]
*/
protected $fillable = [
"name",
"description",
"suspended",
"identifier",
"product_id",
"pterodactyl_id",
];
/**
* @var string[]
*/
protected $dates = [
'suspended'
];
/**
*
*/
public static function boot() {
parent::boot();
static::creating(function(Server $server) {
$client = new Client();
$server->{$server->getKeyName()} = $client->generateId($size = 21);
});
static::deleting(function(Server $server) {
Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
});
}
/**
* @return bool
*/
public function isSuspended(){
return !is_null($this->suspended);
}
/**
* @return PromiseInterface|Response
*/
public function getPterodactylServer(){
return Pterodactyl::client()->get("/application/servers/{$this->pterodactyl_id}");
}
/**
*
* @throws Exception
*/
public function suspend(){
$response = Pterodactyl::suspendServer($this);
if ($response->successful()) {
$this->update([
'suspended' => now()
]);
}
return $this;
}
/**
* @throws Exception
*/
public function unSuspend()
{
$response = Pterodactyl::unSuspendServer($this);
if ($response->successful()) {
$this->update([
'suspended' => null
]);
}
return $this;
}
/**
* @return HasOne
*/
public function product(){
return $this->hasOne(Product::class , 'id' , 'product_id');
}
/**
* @return HasOne
*/
public function nest(){
return $this->hasOne(Nest::class , 'id' , 'nest_id');
}
/**
* @return HasOne
*/
public function egg(){
return $this->hasOne(Egg::class , 'id' , 'egg_id');
}
/**
* @return HasOne
*/
public function location(){
return $this->hasOne(Location::class , 'id' , 'location_id');
}
/**
* @return BelongsTo
*/
public function user(){
return $this->belongsTo(User::class , 'user_id' , 'id');
}
}

143
app/Models/User.php Normal file
View file

@ -0,0 +1,143 @@
<?php
namespace App\Models;
use App\Classes\Pterodactyl;
use App\Notifications\Auth\QueuedVerifyEmail;
use App\Notifications\WelcomeMessage;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Activitylog\Traits\CausesActivity;
use Spatie\Activitylog\Traits\LogsActivity;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable, LogsActivity, CausesActivity;
protected static $logAttributes = ['name', 'email'];
protected static $ignoreChangedAttributes = [
'remember_token',
'credits',
'updated_at',
'server_limit',
'last_seen',
'ip',
'pterodactyl_id'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'ip',
'mac',
'last_seen',
'role',
'credits',
'email',
'server_limit',
'password',
'pterodactyl_id',
'discord_verified_at',
'avatar'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
'last_seen' => 'datetime',
];
public static function boot()
{
parent::boot();
static::created(function (User $user) {
$user->notify(new WelcomeMessage($user));
});
static::deleting(function (User $user) {
$user->servers()->chunk(10 , function ($servers) {
foreach ($servers as $server) {
$server->delete();
}
});
$user->payments()->chunk(10 , function ($payments) {
foreach ($payments as $payment) {
$payment->delete();
}
});
Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}");
});
}
public function sendEmailVerificationNotification()
{
$this->notify(new QueuedVerifyEmail);
}
public function credits()
{
return number_format($this->credits, 2, '.', '');
}
public function getAvatar(){
return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
}
public function creditUsage()
{
$usage = 0;
foreach ($this->Servers as $server){
$usage += $server->product->price;
}
return number_format($usage, 2, '.', '');
}
public function getVerifiedStatus(){
$status = '';
if ($this->hasVerifiedEmail()) $status .= 'email ';
if ($this->discordUser()->exists()) $status .= 'discord';
$status = str_replace(' ' , '/' , $status);
return $status;
}
public function discordUser(){
return $this->hasOne(DiscordUser::class);
}
public function servers()
{
return $this->hasMany(Server::class);
}
public function payments()
{
return $this->hasMany(Payment::class);
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace App\Notifications\Auth;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
class QueuedVerifyEmail extends VerifyEmail implements ShouldQueue
{
use Queueable;
}

View file

@ -0,0 +1,57 @@
<?php
namespace App\Notifications;
use App\Models\Server;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class ServerCreationError extends Notification
{
use Queueable;
/**
* @var Server
*/
private $server;
/**
* Create a new notification instance.
*
* @param Server $server
*/
public function __construct(Server $server)
{
$this->server = $server;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'title' => "Server Creation Error",
'content' => "
<p>Hello <strong>{$this->server->User->name}</strong>, An unexpected error has occurred...</p>
<p>There was a problem creating your server on our pterodactyl panel. There are likely no allocations or rooms left on the selected node. Please contact one of our support members through our discord server to get this resolved asap!</p>
<p>We thank you for your patience and our deepest apologies for this inconvenience.</p>
<p>".config('app.name', 'Laravel')."</p>
",
];
}
}

View file

@ -0,0 +1,61 @@
<?php
namespace App\Notifications;
use App\Models\Configuration;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class WelcomeMessage extends Notification
{
use Queueable;
/**
* @var User
*/
private $user;
/**
* Create a new notification instance.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['database'];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
'title' => "Getting started!",
'content' => "
<p>Hello <strong>{$this->user->name}</strong>, Welcome to our dashboard!</p>
<h5>Verification</h5>
<p>Please verify your email address to get " . Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_EMAIL') . " extra credits and increase your server limit to " . Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . "<br />You can also verify your discord account to get another " . Configuration::getValueByKey('CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " credits and to increase your server limit again with " . Configuration::getValueByKey('SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . "</p>
<h5>Information</h5>
<p>This dashboard can be used to create and delete servers.<br /> These servers can be used and managed thru our pterodactyl panel.<br /> If you have any questions, please join our Discord and #create-a-ticket.</p>
<p>We hope you can enjoy this hosting experience and if you have any suggestions please let us know!</p>
<p>Regards,<br />" . config('app.name', 'Laravel') . "</p>
",
];
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Paginator::useBootstrap();
Schema::defaultStringLength(191);
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use App\Listeners\Verified;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use SocialiteProviders\Manager\SocialiteWasCalled;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
SocialiteWasCalled::class => [
// ... other providers
'SocialiteProviders\\Discord\\DiscordExtendSocialite@handle',
],
'Illuminate\Auth\Events\Verified' => [
Verified::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}

View file

@ -0,0 +1,63 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}

53
artisan Normal file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

55
bootstrap/app.php Normal file
View file

@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

0
composer Normal file
View file

73
composer.json Normal file
View file

@ -0,0 +1,73 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"biscolab/laravel-recaptcha": "^5.0",
"doctrine/dbal": "^3.1",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"hidehalo/nanoid-php": "^1.1",
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.2",
"paypal/paypal-checkout-sdk": "^1.0",
"paypal/rest-api-sdk-php": "^1.14",
"socialiteproviders/discord": "^4.1",
"spatie/laravel-activitylog": "^3.16",
"yajra/laravel-datatables-oracle": "~9.0",
"ext-intl": "*"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"mpociot/laravel-apidoc-generator": "^4.8",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}

8570
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

236
config/app.php Normal file
View file

@ -0,0 +1,236 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'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
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Biscolab\ReCaptcha\ReCaptchaServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Yajra\DataTables\DataTablesServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
// 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'ReCaptcha' => Biscolab\ReCaptcha\Facades\ReCaptcha::class,
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
],
];

117
config/auth.php Normal file
View file

@ -0,0 +1,117 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];

64
config/broadcasting.php Normal file
View file

@ -0,0 +1,64 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

106
config/cache.php Normal file
View file

@ -0,0 +1,106 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| 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: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "null"
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],
'file' => [
'driver' => 'file',
'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' => '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'),
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
];

34
config/cors.php Normal file
View file

@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*', 'sanctum/csrf-cookie'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];

View file

@ -0,0 +1,5 @@
<?php
return [
"AUD", "BRL", "CAD", "CNY", "CZK", "DKK", "EUR", "HKD", "HUF", "ILS", "JPY", "MYR", "MXN", "TWD", "NZD", "NOK", "PHP", "PLN", "GBP", "RUB", "SGD", "SEK", "CHF", "THB", "USD",
];

147
config/database.php Normal file
View file

@ -0,0 +1,147 @@
<?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 all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'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('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
/*
|--------------------------------------------------------------------------
| 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 in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| 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 APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
],
],
];

78
config/filesystems.php Normal file
View file

@ -0,0 +1,78 @@
<?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. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'logs' => [
'driver' => 'local',
'root' => storage_path('logs'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'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'),
],
],
/*
|--------------------------------------------------------------------------
| 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'),
],
];

52
config/hashing.php Normal file
View file

@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
],
];

104
config/logging.php Normal file
View file

@ -0,0 +1,104 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

110
config/mail.php Normal file
View file

@ -0,0 +1,110 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| 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 to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array"
|
*/
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails 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 e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];

89
config/queue.php Normal file
View file

@ -0,0 +1,89 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
],
'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', 'your-queue-name'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

159
config/recaptcha.php Normal file
View file

@ -0,0 +1,159 @@
<?php
/**
* Copyright (c) 2017 - present
* LaravelGoogleRecaptcha - recaptcha.php
* author: Roberto Belotti - roby.belotti@gmail.com
* web : robertobelotti.com, github.com/biscolab
* Initial version created on: 12/9/2018
* MIT license: https://github.com/biscolab/laravel-recaptcha/blob/master/LICENSE
*/
/**
* To configure correctly please visit https://developers.google.com/recaptcha/docs/start
*/
return [
/**
*
* The site key
* get site key @ www.google.com/recaptcha/admin
*
*/
'api_site_key' => env('RECAPTCHA_SITE_KEY', ''),
/**
*
* The secret key
* get secret key @ www.google.com/recaptcha/admin
*
*/
'api_secret_key' => env('RECAPTCHA_SECRET_KEY', ''),
/**
*
* ReCATCHA version
* Supported: "v2", "invisible", "v3",
*
* get more info @ https://developers.google.com/recaptcha/docs/versions
*
*/
'version' => 'v2',
/**
*
* The curl timout in seconds to validate a recaptcha token
* @since v3.5.0
*
*/
'curl_timeout' => 10,
/**
*
* IP addresses for which validation will be skipped
*
*/
'skip_ip' => [],
/**
*
* Default route called to check the Google reCAPTCHA token
* @since v3.2.0
*
*/
'default_validation_route' => 'biscolab-recaptcha/validate',
/**
*
* The name of the parameter used to send Google reCAPTCHA token to verify route
* @since v3.2.0
*
*/
'default_token_parameter_name' => 'token',
/**
*
* The default Google reCAPTCHA language code
* It has no effect with v3
* @see https://developers.google.com/recaptcha/docs/language
* @since v3.6.0
*
*/
'default_language' => null,
/**
*
* The default form ID. Only for "invisible" reCAPTCHA
* @since v4.0.0
*
*/
'default_form_id' => 'biscolab-recaptcha-invisible-form',
/**
*
* Deferring the render can be achieved by specifying your onload callback function and adding parameters to the JavaScript resource.
* It has no effect with v3 and invisible
* @see https://developers.google.com/recaptcha/docs/display#explicit_render
* @since v4.0.0
* Supported true, false
*
*/
'explicit' => false,
/**
*
* Set API domain. You can use "www.recaptcha.net" in case "www.google.com" is not accessible.
* (no check will be made on the entered value)
* @see https://developers.google.com/recaptcha/docs/faq#can-i-use-recaptcha-globally
* @since v4.3.0
* Default 'www.google.com' (ReCaptchaBuilder::DEFAULT_RECAPTCHA_API_DOMAIN)
*
*/
'api_domain' => 'www.google.com',
/**
*
* g-recaptcha tag attributes and grecaptcha.render parameters (v2 only)
* @see https://developers.google.com/recaptcha/docs/display#render_param
* @since v4.0.0
*/
'tag_attributes' => [
/**
* The color theme of the widget.
* Supported "light", "dark"
*/
'theme' => 'dark',
/**
* The size of the widget.
* Supported "normal", "compact"
*/
'size' => 'normal',
/**
* The tabindex of the widget and challenge.
* If other elements in your page use tabindex, it should be set to make user navigation easier.
*/
'tabindex' => 0,
/**
* The name of your callback function, executed when the user submits a successful response.
* The g-recaptcha-response token is passed to your callback.
* DO NOT SET "biscolabOnloadCallback"
*/
'callback' => null,
/**
* The name of your callback function, executed when the reCAPTCHA response expires and the user needs to re-verify.
* DO NOT SET "biscolabOnloadCallback"
*/
'expired-callback' => null,
/**
* The name of your callback function, executed when reCAPTCHA encounters an error (usually network connectivity) and cannot continue until connectivity is restored.
* If you specify a function here, you are responsible for informing the user that they should retry.
* DO NOT SET "biscolabOnloadCallback"
*/
'error-callback' => null,
]
];

43
config/services.php Normal file
View file

@ -0,0 +1,43 @@
<?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.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'discord' => [
'client_id' => env('DISCORD_CLIENT_ID'),
'client_secret' => env('DISCORD_CLIENT_SECRET'),
'redirect' => env('DISCORD_REDIRECT_URI'),
// optional
'allow_gif_avatars' => (bool)env('DISCORD_AVATAR_GIF', true),
'avatar_default_extension' => env('DISCORD_EXTENSION_DEFAULT', 'jpg'), // only pick from jpg, png, webp
],
];

201
config/session.php Normal file
View file

@ -0,0 +1,201 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| 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 immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 240),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'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', null),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| While using one of the framework's cache driven session backends you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
| Affects: "apc", "dynamodb", "memcached", "redis"
|
*/
'store' => env('SESSION_STORE', null),
/*
|--------------------------------------------------------------------------
| 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 cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(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 are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| 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 if it can not 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. You are free to modify this option if needed.
|
*/
'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" since this is a secure default value.
|
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => 'lax',
];

36
config/view.php Normal file
View file

@ -0,0 +1,36 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

2
database/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.sqlite
*.sqlite-journal

View file

@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use App\Models\DiscordUser;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class DiscordUserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = DiscordUser::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'id' => $this->faker->numberBetween(186902438396035072 , 986902438396035072),
'user_id' => function () {
return User::factory()->create()->id;
},
'username' => $this->faker->userName,
'avatar' => $this->faker->uuid,
'discriminator' => $this->faker->randomNumber(4),
'email' => $this->faker->safeEmail,
'verified' => $this->faker->boolean,
'public_flags' => $this->faker->randomNumber(1),
'locale' => Str::random(2),
'mfa_enabled' => $this->faker->boolean,
'premium_type' => $this->faker->randomNumber(1),
];
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
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.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

View file

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View file

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLocationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('locations', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('locations');
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNodesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nodes', function (Blueprint $table) {
$table->id();
$table->foreignId('location_id')->references('id')->on('locations');
$table->string('name');
$table->string('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nodes');
}
}

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