Skip to content

Instantly share code, notes, and snippets.

View GithubMrxia's full-sized avatar

Mrxia GithubMrxia

View GitHub Profile
@GithubMrxia
GithubMrxia / SmsVerificationCode.php
Last active April 23, 2020 08:21
短信验证码
<?php
namespace App\Libs\Sms;
use App\Libs\Sms\Sms;
use App\Libs\RedisLib;
class SmsVerificationCode
{
protected $seedLimit = 60;
@GithubMrxia
GithubMrxia / excel.php
Last active February 28, 2020 10:34
php操作excel
<?php
$spreadsheet = @IOFactory::load(storage_path('app/public/template/开票申请单模板.xls'));
$spreadsheet->setActiveSheetIndex(0);
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->getCell('C2')->setValue(date('Y'));
$worksheet->getCell('C2')->setValue(date('Y'));
$worksheet->getCell('E2')->setValue(date('m'));
$worksheet->getCell('G2')->setValue(date('d'));
$(function () {
// ajax 全局设置
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
// 'Content-type': 'multipart/form-data',
// "Content-type": "multipart/form-data; charset=utf-8; boundary=" + Math.random().toString().substr(2)),
},
beforeSend: function () {
$('[type="submit"]').attr('disabled', true);
<?php
namespace App\Libs;
use Illuminate\Support\Facades\Redis;
class RedisLib
{
/**
* 加锁
<?php
// 生成流水号
if (! function_exists('generateSN')) {
function generateSN($prefix = '', int $length = 30) {
if (empty($prefix)) {
$prefix = 'PF';
}
$length = max(20, $length);
return str_pad($prefix . uniqid(date('YmdHis')), $length, mt_rand(0, 10000));
@GithubMrxia
GithubMrxia / zip.php
Last active February 28, 2020 10:32
php解压zip文件并把所有图片放到制定目录下
<?php
$za = new ZipArchive();
$res = $za->open('test.zip');
if (!$res) {
return $this->respApiRequestFail('解压失败');
}
$path = storage_path('/path/to');
for ($i = 0; $i < $za->numFiles; $i++) {
$fileInfo = $za->statIndex($i);
@GithubMrxia
GithubMrxia / regex.md
Last active May 6, 2020 09:22
常用正则表达式

类型|正则|备注 ---|---| 手机号| ^1[3456789]\d{9}$ 身份证号| ^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|x|X)$ 两位小数 | ^\d+(\.\d{1,2})?$| 可以为整数 两位小数 | (^(\d{2,}|[1-9])+(\.\d{1,2})?$)|(^0\.((\d[1-9])|([1-9]0?))$) | 可以为整数,最小0.01

@GithubMrxia
GithubMrxia / select2封装
Last active October 30, 2020 12:44
封装
$.fn.extend({
/**
* select2 ajax封装
* @param string url
* @param obj transfer 转换响应数据 {id:'',text''}
* @param obj addQuery 增加的查询条件
* @param obj params select2配置,可覆盖默认配置
* @param string searchField 查询字段名
* @param int limit 每页显示数量
*/
@GithubMrxia
GithubMrxia / Auth.php
Last active March 26, 2020 06:44
Auth.php
<?php
namespace App\Libs\Auth;
use App\Libs\Auth\Jwt;
use App\Libs\RedisLib;
class Auth
{
<button class="btn-primary btn" data-toggle="modal" data-contract_no="{{ $contract->contract_no }}" type="button" data-target="#refund"><i class="fa"></i> 退款处理</button>
<div class="modal fade" id="refund" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title">退款处理</h4>