李帅

1.新增字体管理。

1 +<?php
2 +
3 +namespace App\Admin\Controllers;
4 +
5 +use App\Models\Font;
6 +use Dcat\Admin\Form;
7 +use Dcat\Admin\Grid;
8 +use Dcat\Admin\Show;
9 +use Dcat\Admin\Http\Controllers\AdminController;
10 +use Illuminate\Support\Facades\Storage;
11 +
12 +class FontController extends AdminController
13 +{
14 + /**
15 + * Make a grid builder.
16 + *
17 + * @return Grid
18 + */
19 + protected function grid()
20 + {
21 + return Grid::make(new Font(), function (Grid $grid) {
22 + $grid->column('id')->sortable();
23 + $grid->column('name');
24 + $grid->column('file','字体')->display(function ($item){
25 + $url = Storage::disk('public')->url($item);
26 + return "<style>
27 +@font-face {
28 + font-family: 'ParlandoFont{$this->id}';
29 + src: url('{$url}') format('truetype');
30 + font-weight: normal;
31 + font-style: normal;
32 +}
33 +.mfont{
34 + font-family: 'ParlandoFont{$this->id}';
35 + color: red;
36 +
37 +}
38 +</style><span class='mfont fa-2x'>字体示例:这里是临境有感</span>";
39 +
40 + });
41 + $grid->column('created_at');
42 + $grid->column('updated_at')->sortable();
43 +
44 + $grid->filter(function (Grid\Filter $filter) {
45 + $filter->equal('id');
46 +
47 + });
48 + });
49 + }
50 +
51 + /**
52 + * Make a show builder.
53 + *
54 + * @param mixed $id
55 + *
56 + * @return Show
57 + */
58 + protected function detail($id)
59 + {
60 + return Show::make($id, new Font(), function (Show $show) {
61 + $show->field('id');
62 + $show->field('id');
63 + $show->field('name');
64 + $show->field('file');
65 + $show->field('created_at');
66 + $show->field('updated_at');
67 + });
68 + }
69 +
70 + /**
71 + * Make a form builder.
72 + *
73 + * @return Form
74 + */
75 + protected function form()
76 + {
77 + return Form::make(new Font(), function (Form $form) {
78 + $form->display('id');
79 + $form->text('name','名称标识');
80 +
81 + $form->file('file','上传字体')
82 + ->accept('ttf,woff,woff2,otf,eot')
83 + ->autoUpload()
84 + ->uniqueName()
85 + ->maxSize('128000');
86 +
87 + $form->display('created_at');
88 + $form->display('updated_at');
89 + });
90 + }
91 +}
...@@ -26,6 +26,7 @@ Route::group([ ...@@ -26,6 +26,7 @@ Route::group([
26 26
27 /** 临境*/ 27 /** 临境*/
28 $router->group(['prefix'=>'/linjing'],function (Router $router){ 28 $router->group(['prefix'=>'/linjing'],function (Router $router){
29 + $router->resource('/font', 'FontController');
29 $router->resource('/template', 'VideoTempController'); 30 $router->resource('/template', 'VideoTempController');
30 $router->resource('/official', 'AdminMakeVideoController'); 31 $router->resource('/official', 'AdminMakeVideoController');
31 }); 32 });
......
1 +<?php
2 +
3 +namespace App\Models;
4 +
5 +use Dcat\Admin\Traits\HasDateTimeFormatter;
6 +
7 +use Illuminate\Database\Eloquent\Model;
8 +
9 +class Font extends Model
10 +{
11 + use HasDateTimeFormatter;
12 + protected $table = 'font';
13 +
14 +}
1 +<?php
2 +
3 +use Illuminate\Support\Facades\Schema;
4 +use Illuminate\Database\Schema\Blueprint;
5 +use Illuminate\Database\Migrations\Migration;
6 +
7 +class CreateFontTable extends Migration
8 +{
9 + /**
10 + * Run the migrations.
11 + *
12 + * @return void
13 + */
14 + public function up()
15 + {
16 + Schema::create('font', function (Blueprint $table) {
17 + $table->increments('id');
18 + $table->string('name')->default('')->comment('名称标识');
19 + $table->string('file')->default('')->comment('文件地址');
20 + $table->timestamps();
21 + });
22 + }
23 +
24 + /**
25 + * Reverse the migrations.
26 + *
27 + * @return void
28 + */
29 + public function down()
30 + {
31 + Schema::dropIfExists('font');
32 + }
33 +}