-
composer require milon/barcode 5.3
class CodeController extends Controller
{
//
public function yicode(Request $request){
$cc = new DNS1D();
i
m
g
=
"
d
a
t
a
:
i
m
a
g
e
/
p
n
g
;
b
a
s
e
64
,
"
.
img = "data:image/png;base64,".
img="data:image/png;base64,".cc->getBarcodePNG(
r
e
q
u
e
s
t
−
>
n
u
m
,
request->num,
request−>num,request->type);
return $img;
}
}
num为传入的号码 ,type为条形码类型
PS:http://www.luohun.org/index.php/archives/33/
https://laravel-china.org/index.php/courses/laravel-package/bar-code-generation-tool-milonbarcode/2037
http://www.luohun.org/index.php/archives/33/#comment-27
PLAN B:
use Milon\Barcode\DNS1D;
class BarcodeController extends Controller
{
//生成条形码
public function index(Request $request){
$cc = new DNS1D();
t
i
t
l
e
=
s
u
b
s
t
r
(
title = substr(
title=substr(request->title,0,14); //截取title长度
for(
i
=
0
;
i=0;
i=0;i<44;$i++){
//
a
r
r
=
[
1
,
5
,
9
,
13
,
17
,
21
,
25
,
29
,
33
,
37
,
41
]
;
i
f
(
arr = [1,5,9,13,17,21,25,29,33,37,41]; if(
arr=[1,5,9,13,17,21,25,29,33,37,41];if(i%4==0||
i
e
c
h
o
′
<
d
i
v
s
t
y
l
e
=
"
w
i
d
t
h
:
155
p
x
;
f
l
o
a
t
:
r
i
g
h
t
;
m
a
r
g
i
n
:
1
p
x
017
p
x
8
p
x
;
p
a
d
d
i
n
g
−
l
e
f
t
:
3
p
x
"
>
<
d
i
v
>
<
i
m
g
s
t
y
l
e
=
"
w
i
d
t
h
:
a
u
t
o
;
m
a
x
−
w
i
d
t
h
:
95
i%3==0){ echo '<div style="width: 155px; float: right;margin:1px 0 17px 8px;padding-left: 3px"><div><img style="width: auto;max-width: 95%" src="data:image/png;base64,' .
iecho′<divstyle="width:155px;float:right;margin:1px017px8px;padding−left:3px"><div><imgstyle="width:auto;max−width:95cc->getBarcodePNG($request->num,
r
e
q
u
e
s
t
−
>
t
y
p
e
)
.
′
"
a
l
t
=
"
b
a
r
c
o
d
e
"
/
>
<
/
d
i
v
>
<
d
i
v
s
t
y
l
e
=
"
w
i
d
t
h
:
155
p
x
;
t
e
x
t
−
a
l
i
g
n
:
c
e
n
t
e
r
"
>
′
.
request->type) . '" alt="barcode" /></div><div style="width: 155px;text-align: center">'.
request−>type).′"alt="barcode"/></div><divstyle="width:155px;text−align:center">′.request->fn_sku.’
}
}
}
}
二维码生成
use Milon\Barcode\DNS1D;
use Milon\Barcode\DNS2D;
//生成二维码
public function qrCode(){
KaTeX parse error: Expected 'EOF', got '&' at position 49: …br><br><br><br>&̲nbsp; &nbs…cc->getBarcodeSVG(“AZ:X4CTAAHKI5A6TEYW9RCJNFOFWI”, “DATAMATRIX”);
}