mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Try/catch barcodes so they don’t shit up the logs
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
ca8b152549
commit
069e9e52fe
|
@ -14,6 +14,7 @@ use App\Models\Setting;
|
|||
use App\Models\User;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use DB;
|
||||
use Gate;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -486,10 +487,16 @@ class AssetsController extends Controller
|
|||
$barcode_width = ($settings->labels_width - $settings->labels_display_sgutter) * 96.000000000001;
|
||||
|
||||
$barcode = new \Com\Tecnick\Barcode\Barcode();
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode,$asset->asset_tag,($barcode_width < 300 ? $barcode_width : 300),50);
|
||||
try {
|
||||
$barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode,$asset->asset_tag,($barcode_width < 300 ? $barcode_width : 300),50);
|
||||
file_put_contents($barcode_file, $barcode_obj->getPngData());
|
||||
return response($barcode_obj->getPngData())->header('Content-type', 'image/png');
|
||||
} catch(\Exception $e) {
|
||||
\Log::debug('The barcode format is invalid.');
|
||||
return response(file_get_contents(public_path('uploads/barcodes/invalid_barcode.gif')))->header('Content-type', 'image/gif');
|
||||
}
|
||||
|
||||
|
||||
file_put_contents($barcode_file, $barcode_obj->getPngData());
|
||||
return response($barcode_obj->getPngData())->header('Content-type', 'image/png');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,11 @@ Form::macro('alt_barcode_types', function ($name = "alt_barcode", $selected = nu
|
|||
'C39',
|
||||
'PDF417',
|
||||
'EAN5',
|
||||
'EAN13',
|
||||
'UPCA',
|
||||
'UPCE',
|
||||
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue