Skip to content

Commit

Permalink
Upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ss098 committed Jan 30, 2024
1 parent 1c9e1c3 commit ecae909
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 175 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[{*.yml,*.json}]
indent_size = 2
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_SIMPLE_ANALYTICS_ENABLE=false
MIX_NOTICE_ENABLE=false
MIX_NOTICE_TITLE=
MIX_NOTICE_TEXT=

MIX_DETAIL_TEXT=

SENTRY_LARAVEL_DSN=null
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Work 的核心目的是略过技术,设计出一个功能简单易用兼容移

配置 `.env` 文件中的数据库信息:

如需由 Sentry 提供的错误信息收集服务,可以配置 `SENTRY_LARAVEL_DSN`

如需由 Simple Analytics 提供的隐私友好型分析,可以配置 `MIX_SIMPLE_ANALYTICS_ENABLE``true`

cp .env.example .env

php artisan key:generate
Expand Down
7 changes: 5 additions & 2 deletions app/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class Attachment extends Model
{
Expand All @@ -13,13 +14,15 @@ class Attachment extends Model
// 存储文件到磁盘
public function store($attachment)
{
$record_id = $attachment['record_id'];
$content = base64_decode(preg_replace('#^data:(.+);base64,#iU', '', $attachment['data']));

$extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);
$filename = str_random(32) . '.' . $extension;
$filename = $record_id . '/' . Str::random(8) . '.' . $extension;

Storage::put($filename, $content);

$this->record_id = $attachment['record_id'];
$this->record_id = $record_id;
$this->name = $filename;
$this->size = Storage::size($filename);
}
Expand Down
6 changes: 2 additions & 4 deletions app/Console/Commands/TraceForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ public function handle()
foreach ($forms as $form) {
$records = $form->record;

foreach ($records as $record)
{
foreach ($record->attachment as $attachment)
{
foreach ($records as $record) {
foreach ($record->attachment as $attachment) {
echo 'delete attachment:' . $attachment->id . PHP_EOL;

if (Storage::exists($attachment->name)) {
Expand Down
43 changes: 9 additions & 34 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,29 @@

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
* The list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
if (app()->bound('sentry') && $this->shouldReport($exception)){
app('sentry')->captureException($exception);
}

parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
* Register the exception handling callbacks for the application.
*/
public function render($request, Exception $exception)
public function register(): void
{
return parent::render($request, $exception);
$this->reportable(function (Throwable $e) {
//
});
}
}
39 changes: 15 additions & 24 deletions app/Http/Controllers/RecycleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use App\Record;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use ZipArchive;

class RecycleController extends Controller
{
Expand All @@ -19,8 +21,7 @@ public function overview(Request $request)
$record = Record::with('attachment')
->where('form_id', $id);

if (in_array($order_by, ['code', 'updated_at']))
{
if (in_array($order_by, ['code', 'updated_at'])) {
$record->orderBy($order_by);
}

Expand All @@ -43,12 +44,10 @@ public function recycle(Request $request)
->where('code', $recycle['code'])
->first();

if (!$record)
{
if (!$record) {
$record = new Record();
} else {
$record->attachment->each(function ($attachment)
{
$record->attachment->each(function ($attachment) {
$attachment->delete_file();
$attachment->delete();
});
Expand All @@ -59,8 +58,7 @@ public function recycle(Request $request)
$record->code = $recycle['code'];
$record->save();

foreach ($recycle['attachment'] as $attachment_data)
{
foreach ($recycle['attachment'] as $attachment_data) {
$attachment_data['record_id'] = $record->id;

$attachment = new Attachment();
Expand All @@ -87,39 +85,32 @@ public function export(Request $request)
$id = $request->input('id');
$format = $request->input('format');
$form = Form::find($id);
$filename = storage_path(str_random(32) . '.zip');
$filename = storage_path(Str::random(8) . '.zip');

if (empty($format)) {
$format = 'name code';
}

$zipper = new \Chumper\Zipper\Zipper;
$zipper->make($filename);
$zipper = new ZipArchive();
$zipper->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE);

foreach ($form->record as $record)
{
foreach ($record->attachment as $index => $attachment)
{
$zipper->home();
foreach ($form->record as $record) {
foreach ($record->attachment as $index => $attachment) {
$extension = pathinfo($attachment->name, PATHINFO_EXTENSION);

$attachment_name = str_replace('name', $record->name, $format);
$attachment_name = str_replace('code', $record->code, $attachment_name);

if ($record->attachment->count() > 1)
{
$folder = $zipper->folder($attachment_name);

$folder->add(storage_path('app/' . $attachment->name), ($index + 1).'.'.$extension);
if ($record->attachment->count() > 1) {
$zipper->addFile(storage_path('app/' . $attachment->name), $attachment_name . '/' . ($index + 1) . '.' . $extension);
} else {
$zipper->add(storage_path('app/' . $attachment->name), $attachment_name . '.' . $extension);
$zipper->addFile(storage_path('app/' . $attachment->name), $attachment_name . '.' . $extension);
}
}

}

$zipper->close();

return response()->download($filename, $form->name . '.zip')->deleteFileAfterSend(true);
return response()->download($filename, $form->name . '.zip')->deleteFileAfterSend();
}
}
125 changes: 64 additions & 61 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"chumper/zipper": "^1.0",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"sentry/sentry-laravel": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^8.2",
"intervention/image": "^2.4",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/octane": "^2.2",
"laravel/sanctum": "^3.3",
"laravel/tinker": "^2.8",
"ext-zip": "*"
},
"require-dev": {
"brianium/paratest": "^7.3",
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"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"
]
"classmap": [
"database/seeds",
"database/factories"
]
},
"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"
]
}
}
2 changes: 0 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

Chumper\Zipper\ZipperServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,

],

/*
Expand Down
17 changes: 0 additions & 17 deletions config/sentry.php

This file was deleted.

Loading

0 comments on commit ecae909

Please sign in to comment.