Update to Laravel 8

This commit is contained in:
Deon George 2021-06-28 11:06:44 +10:00
parent 84fa5f6546
commit d9c4aa5b92
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
30 changed files with 4604 additions and 5738 deletions

View File

@ -2,67 +2,40 @@
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* 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',
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param Exception $exception
* @return void
* @throws Exception
*/
public function report(Exception $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param Request $request
* @param Exception $exception
* @return Response
* @throws Exception
*/
public function render($request, Exception $exception)
{
// We'll render a 404 for any authorisation exceptions to hide the fact that the resource exists
if ($exception instanceof AuthorizationException) {
Log::error('Request not authorised',['user'=>Auth::user()->id,'request'=>$request->path()]);
if ($request->ajax())
return response()->json(['data'=>[]],200);
else
abort(404,'Not here...');
}
return parent::render($request, $exception);
}
}
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View File

@ -2,10 +2,10 @@
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
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
{

View File

@ -2,26 +2,31 @@
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
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* 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 = '/u/home';
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.
@ -30,51 +35,29 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
//
$this->configureRateLimiting();
parent::boot();
$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'));
});
}
/**
* Define the routes for the application.
* Configure the rate limiters for the application.
*
* @return void
*/
public function map()
protected function configureRateLimiting()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}

0
artisan Normal file → Executable file
View File

View File

@ -2,37 +2,39 @@
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"keywords": [ "framework", "laravel" ],
"license": "MIT",
"require": {
"php": "^7.2",
"php": "^7.4|^8.0",
"barryvdh/laravel-snappy": "^0.4.6",
"beyondcode/laravel-websockets": "^1.3",
"clarkeash/doorman": "^4.0",
"clarkeash/doorman": "^6.0",
"doctrine/dbal": "^2.10",
"eduardokum/laravel-mail-auto-embed": "^1.0",
"fideloper/proxy": "^4.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"hmazter/laravel-schedule-list": "^2.1",
"intervention/image": "^2.5",
"laravel/framework": "^6.4",
"laravel/passport": "^8.2",
"laravel/socialite": "^4.2",
"leenooks/laravel": "^6.0",
"laravel/framework": "^8.12",
"laravel/passport": "^10.1",
"laravel/socialite": "^5.2",
"laravel/ui": "^3.2",
"leenooks/laravel": "^9.0",
"rennokki/laravel-eloquent-query-cache": "^2.6",
"romanzipp/laravel-queue-monitor": "^2.0",
"repat/laravel-job-models": "^0.5.1",
"paypal/paypal-checkout-sdk": "^1.0",
"spatie/laravel-demo-mode": "^2.5",
"spinen/laravel-quickbooks-client": "^3.1"
"spinen/laravel-quickbooks-client": "^4.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"facade/ignition": "1.11.1",
"fzaninotto/faker": "^1.4",
"laravel/tinker": "^1.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
"barryvdh/laravel-debugbar": "^3.5",
"barryvdh/laravel-ide-helper": "^2.10",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
@ -46,12 +48,10 @@
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {

7172
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -210,6 +210,7 @@ return [
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Date' => Illuminate\Support\Facades\Date::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
@ -240,6 +241,7 @@ return [
],
// @todo This needs to move.
'invoice_inadvance'=>30,
'font' => 'Noto Sans TC',

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

@ -44,13 +44,13 @@ return [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
@ -59,12 +59,12 @@ return [
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
'level' => env('LOG_LEVEL', 'critical'),
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
@ -74,6 +74,7 @@ return [
'stderr' => [
'driver' => 'monolog',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
@ -83,12 +84,12 @@ return [
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],
'null' => [

View File

@ -2,27 +2,17 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
"production": "mix --production"
},
"devDependencies": {
"cross-env": "^5.2.1",
"laravel-mix": "^5.0.1",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^8.0.0"
},
"dependencies": {
"axios": "^0.19",
"bootstrap": "^4.4.1",
"jquery": "^3.4.1",
"laravel-echo": "^1.6.1",
"lodash": "^4.17.13",
"popper.js": "^1.16.0",
"pusher-js": "^5.0.3"
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14"
}
}

View File

@ -14,7 +14,7 @@
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

File diff suppressed because one or more lines are too long

6
public/css/app.css vendored

File diff suppressed because one or more lines are too long

39
public/css/fixes.css vendored
View File

@ -1,20 +1,29 @@
body {
font-size: 0.85em;
}
/* Fixes for data tables */
/* Fix pagination buttons */
.dataTables_wrapper .dataTables_paginate .paginate_button {
padding: 0em 0em;
margin-left: 0px;
border: 0px solid;
padding: 0 0;
margin-left: 0;
border: 0 solid;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
border: 0px solid;
border: 0 solid;
background: #fff;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:active {
box-shadow: 0 0 0px #fff;
box-shadow: 0 0 0 #fff;
background-color: #fff;
}
.dataTables_scrollHeadInner {
width: 100% !important;
}
/* Remove multiple sorting images on tables */
table.dataTable thead .sorting_asc {
background-image: none !important;
}
@ -27,6 +36,12 @@ table.dataTable thead .sorting {
background-image: none !important;
}
/* Fix textcolor on navbar focus */
.form-control.form-control-navbar:focus {
color: #111;
background-color: white;
}
/* Remove blue border from chrome on buttons */
/* Remove outline for non-keyboard :focus */
*:focus:not(.focus-visible) {
@ -35,9 +50,11 @@ table.dataTable thead .sorting {
}
/* Optional: Customize .focus-visible */
/*
.focus-visible {
outline-color: lightgreen;
}
*/
*:disabled {
cursor: not-allowed;
@ -51,10 +68,14 @@ table.dataTable thead .sorting {
cursor: pointer;
}
.tag-selected {
color: orange;
}
.tag-selected:hover {
cursor: pointer;
}
.card-header h3.card-title {
font-size: 1.0rem;
}
body {
font-size: 0.85em;
}

View File

@ -1,23 +1,33 @@
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
require __DIR__.'/../storage/framework/maintenance.php';
}
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/
@ -25,36 +35,21 @@ require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
| Run The Application
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Kernel::class);
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response);

File diff suppressed because one or more lines are too long

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +0,0 @@
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 434 KiB

28
public/web.config Normal file
View File

@ -0,0 +1,28 @@
<!--
Rewrites requires Microsoft URL Rewrite Module for IIS
Download: https://www.microsoft.com/en-us/download/details.aspx?id=47337
Debug Help: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

View File

@ -1,4 +1,3 @@
window.$ = window.jQuery = require('jquery');
window._ = require('lodash');
/**
@ -17,19 +16,13 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
* allows your team to easily build robust real-time web applications.
*/
/*
import Echo from 'laravel-echo';
// import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
// window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
disableStats: true,
encrypted: true,
});
*/
require('bootstrap');
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// forceTLS: true
// });

View File

@ -1,5 +1,7 @@
<?php
use App\Http\Controllers\{HomeController,WelcomeController};
/*
|--------------------------------------------------------------------------
| Web Routes
@ -31,6 +33,7 @@ Route::group(['middleware'=>['theme:adminlte-be','auth','role:wholesaler'],'pref
Route::get('service/{o}','AdminHomeController@service');
Route::post('service/{o}','AdminHomeController@service_update');
Route::get('report/products','Wholesale\ReportController@products');
Route::get('payment/add','PaymentController@add');
//Route::get('accounting/connect','AccountingController@connect');
});
@ -50,7 +53,7 @@ Route::group(['middleware'=>['theme:adminlte-be','auth','role:reseller'],'prefix
// Our User Routes
Route::group(['middleware'=>['theme:adminlte-be','auth'],'prefix'=>'u'],function() {
Route::get('home','UserHomeController@home');
Route::get('home',[HomeController::class,'home']);
Route::get('home/{o}','UserHomeController@home')
->where('o','[0-9]+')
->middleware('can:view,o');
@ -88,7 +91,7 @@ Route::group(['middleware'=>['theme:adminlte-be'],'prefix'=>'u'],function() {
// Frontend Routes (Non-Authed Users)
Route::group(['middleware'=>['theme:metronic-fe']],function() {
Route::get('/','WelcomeController@index');
Route::get('/',[WelcomeController::class,'home']);
Route::get('order','OrderController@index');
Route::post('order','OrderController@submit');
});
@ -104,4 +107,4 @@ Route::get('search','SearchController@search');
Route::get('pay/paypal/authorise','PaypalController@authorise');
Route::get('pay/paypal/cancel','PaypalController@cancel');
Route::get('pay/paypal/capture','PaypalController@capture');
Route::get('pay/paypal/capture','PaypalController@capture');