mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-30 00:41:53 +08:00 
			
		
		
		
	update: laravel 7
This commit is contained in:
		| @@ -2,8 +2,8 @@ | ||||
|  | ||||
| namespace App\Exceptions; | ||||
|  | ||||
| use Exception; | ||||
| use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||||
| use Throwable; | ||||
|  | ||||
| class Handler extends ExceptionHandler | ||||
| { | ||||
| @@ -29,10 +29,12 @@ class Handler extends ExceptionHandler | ||||
|     /** | ||||
|      * Report or log an exception. | ||||
|      * | ||||
|      * @param \Exception $exception | ||||
|      * @param  \Throwable  $exception | ||||
|      * @return void | ||||
|      * | ||||
|      * @throws \Throwable | ||||
|      */ | ||||
|     public function report(Exception $exception) | ||||
|     public function report(Throwable $exception) | ||||
|     { | ||||
|         parent::report($exception); | ||||
|     } | ||||
| @@ -40,16 +42,14 @@ class Handler extends ExceptionHandler | ||||
|     /** | ||||
|      * Render an exception into an HTTP response. | ||||
|      * | ||||
|      * @param \Illuminate\Http\Request $request | ||||
|      * @param \Exception $exception | ||||
|      * @return \Illuminate\Http\Response | ||||
|      * @param  \Illuminate\Http\Request  $request | ||||
|      * @param  \Throwable  $exception | ||||
|      * @return \Symfony\Component\HttpFoundation\Response | ||||
|      * | ||||
|      * @throws \Throwable | ||||
|      */ | ||||
|     public function render($request, Exception $exception) | ||||
|     public function render($request, Throwable $exception) | ||||
|     { | ||||
|         if($exception instanceof \Illuminate\Http\Exceptions\ThrottleRequestsException) { | ||||
|             abort(429, '请求频繁,请稍后再试'); | ||||
|         } | ||||
|         return parent::render($request, $exception); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -36,16 +36,16 @@ class ServerController extends Controller | ||||
|         $current = $request->input('current') ? $request->input('current') : 1; | ||||
|         $pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10; | ||||
|         $serverLogModel = ServerLog::where('user_id', $request->session()->get('id')) | ||||
|             ->orderBy('created_at', 'DESC'); | ||||
|             ->orderBy('log_at', 'DESC'); | ||||
|         switch ($type) { | ||||
|             case 0: | ||||
|                 $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d'))); | ||||
|                 $serverLogModel->where('log_at', '>=', strtotime(date('Y-m-d'))); | ||||
|                 break; | ||||
|             case 1: | ||||
|                 $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d')) - 604800); | ||||
|                 $serverLogModel->where('log_at', '>=', strtotime(date('Y-m-d')) - 604800); | ||||
|                 break; | ||||
|             case 2: | ||||
|                 $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-1'))); | ||||
|                 $serverLogModel->where('log_at', '>=', strtotime(date('Y-m-1'))); | ||||
|         } | ||||
|         $total = $serverLogModel->count(); | ||||
|         $res = $serverLogModel->forPage($current, $pageSize) | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Coupon extends Model | ||||
|     protected $table = 'v2_coupon'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -8,4 +8,8 @@ class InviteCode extends Model | ||||
| { | ||||
|     protected $table = 'v2_invite_code'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Knowledge extends Model | ||||
|     protected $table = 'v2_knowledge'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class MailLog extends Model | ||||
|     protected $table = 'v2_mail_log'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Notice extends Model | ||||
|     protected $table = 'v2_notice'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Order extends Model | ||||
|     protected $table = 'v2_order'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Payment extends Model | ||||
|     protected $table = 'v2_payment'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Plan extends Model | ||||
|     protected $table = 'v2_plan'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Server extends Model | ||||
|     protected $table = 'v2_server'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -8,4 +8,8 @@ class ServerGroup extends Model | ||||
| { | ||||
|     protected $table = 'v2_server_group'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class ServerLog extends Model | ||||
| { | ||||
|     protected $table = 'v2_server_log'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class ServerShadowsocks extends Model | ||||
|     protected $table = 'v2_server_shadowsocks'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class ServerStat extends Model | ||||
|     protected $table = 'v2_server_stat'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class ServerTrojan extends Model | ||||
|     protected $table = 'v2_server_trojan'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class StatOrder extends Model | ||||
|     protected $table = 'v2_stat_order'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class StatServer extends Model | ||||
|     protected $table = 'v2_stat_server'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class Ticket extends Model | ||||
|     protected $table = 'v2_ticket'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class TicketMessage extends Model | ||||
|     protected $table = 'v2_ticket_message'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -9,4 +9,8 @@ class User extends Model | ||||
|     protected $table = 'v2_user'; | ||||
|     protected $dateFormat = 'U'; | ||||
|     protected $guarded = ['id']; | ||||
|     protected $casts = [ | ||||
|         'created_at' => 'timestamp', | ||||
|         'updated_at' => 'timestamp' | ||||
|     ]; | ||||
| } | ||||
|   | ||||
| @@ -196,7 +196,7 @@ class OrderService | ||||
|     private function orderIsUsed(Order $order):bool | ||||
|     { | ||||
|         $month = self::STR_TO_TIME[$order->cycle]; | ||||
|         $orderExpireDay = strtotime('+' . $month . ' month', $order->created_at->timestamp); | ||||
|         $orderExpireDay = strtotime('+' . $month . ' month', $order->created_at); | ||||
|         if ($orderExpireDay < time()) return true; | ||||
|         return false; | ||||
|     } | ||||
|   | ||||
| @@ -1,31 +1,35 @@ | ||||
| { | ||||
|     "name": "v2board/v2board", | ||||
|     "type": "project", | ||||
|     "description": "v2board is a v2ray manage.", | ||||
|     "description": "v2board is a proxy protocol manage.", | ||||
|     "keywords": [ | ||||
|         "v2board", | ||||
|         "v2ray", | ||||
|         "shadowsocks", | ||||
|         "trojan", | ||||
|         "laravel" | ||||
|     ], | ||||
|     "license": "MIT", | ||||
|     "require": { | ||||
|         "php": "^7.2", | ||||
|         "fideloper/proxy": "^4.0", | ||||
|         "php": "^7.2.5|^8.0", | ||||
|         "fideloper/proxy": "^4.4", | ||||
|         "fruitcake/laravel-cors": "^2.0", | ||||
|         "guzzlehttp/guzzle": "^6.3.1|^7.0.1", | ||||
|         "laravel/framework": "^7.29", | ||||
|         "laravel/tinker": "^2.5", | ||||
|         "google/recaptcha": "^1.2", | ||||
|         "laravel/framework": "^6.0", | ||||
|         "laravel/tinker": "^1.0", | ||||
|         "lokielse/omnipay-alipay": "3.0.6", | ||||
|         "lokielse/omnipay-alipay": "3.1.2", | ||||
|         "lokielse/omnipay-wechatpay": "^3.0", | ||||
|         "php-curl-class/php-curl-class": "^8.6", | ||||
|         "stripe/stripe-php": "^7.36.1", | ||||
|         "symfony/yaml": "^4.3" | ||||
|     }, | ||||
|     "require-dev": { | ||||
|         "facade/ignition": "^1.4", | ||||
|         "fzaninotto/faker": "^1.4", | ||||
|         "mockery/mockery": "^1.0", | ||||
|         "nunomaduro/collision": "^3.0", | ||||
|         "phpunit/phpunit": "^8.0" | ||||
|         "facade/ignition": "^2.0", | ||||
|         "fakerphp/faker": "^1.9.1", | ||||
|         "mockery/mockery": "^1.3.1", | ||||
|         "nunomaduro/collision": "^4.3", | ||||
|         "phpunit/phpunit": "^8.5.8|^9.3.3" | ||||
|     }, | ||||
|     "config": { | ||||
|         "optimize-autoloader": true, | ||||
|   | ||||
							
								
								
									
										34
									
								
								config/cors.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								config/cors.php
									
									
									
									
									
										Normal 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/*'], | ||||
|  | ||||
|     'allowed_methods' => ['*'], | ||||
|  | ||||
|     'allowed_origins' => ['*'], | ||||
|  | ||||
|     'allowed_origins_patterns' => [], | ||||
|  | ||||
|     'allowed_headers' => ['*'], | ||||
|  | ||||
|     'exposed_headers' => [], | ||||
|  | ||||
|     'max_age' => 0, | ||||
|  | ||||
|     'supports_credentials' => false, | ||||
|  | ||||
| ]; | ||||
| @@ -428,3 +428,7 @@ ALTER TABLE `v2_user` | ||||
|  | ||||
| ALTER TABLE `v2_order` | ||||
|     ADD `paid_at` int(11) NULL AFTER `commission_balance`; | ||||
|  | ||||
| ALTER TABLE `v2_server_log` | ||||
|     ADD INDEX `user_id` (`user_id`), | ||||
| ADD INDEX `server_id` (`server_id`); | ||||
|   | ||||
| @@ -21,7 +21,7 @@ define('LARAVEL_START', microtime(true)); | ||||
| | | ||||
| */ | ||||
|  | ||||
| require __DIR__ . '/../vendor/autoload.php'; | ||||
| require __DIR__.'/../vendor/autoload.php'; | ||||
|  | ||||
| /* | ||||
| |-------------------------------------------------------------------------- | ||||
| @@ -35,7 +35,7 @@ require __DIR__ . '/../vendor/autoload.php'; | ||||
| | | ||||
| */ | ||||
|  | ||||
| $app = require_once __DIR__ . '/../bootstrap/app.php'; | ||||
| $app = require_once __DIR__.'/../bootstrap/app.php'; | ||||
|  | ||||
| /* | ||||
| |-------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| git fetch --all && git reset --hard origin/master && git pull origin master | ||||
| rm -rf composer.lock | ||||
| php composer.phar update -vvv | ||||
| php artisan v2board:update | ||||
| php artisan config:cache | ||||
|   | ||||
							
								
								
									
										6
									
								
								update_dev.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								update_dev.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| git fetch --all && git reset --hard origin/dev && git pull origin dev | ||||
| rm -rf composer.lock | ||||
| php composer.phar update -vvv | ||||
| php artisan v2board:update | ||||
| php artisan config:cache | ||||
| pm2 restart pm2.yaml | ||||
		Reference in New Issue
	
	Block a user