Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-06-16 18:41:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8ccf94925ed94d59c85112c660b225a1b176d7da
8ccf9492
1 parent
ab6b96e1
1.新增字体管理。
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
0 deletions
app/Admin/Controllers/FontController.php
app/Admin/routes.php
app/Models/Font.php
database/migrations/2022_06_16_172936_create_font_table.php
app/Admin/Controllers/FontController.php
0 → 100755
View file @
8ccf949
<?php
namespace
App\Admin\Controllers
;
use
App\Models\Font
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Illuminate\Support\Facades\Storage
;
class
FontController
extends
AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected
function
grid
()
{
return
Grid
::
make
(
new
Font
(),
function
(
Grid
$grid
)
{
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'name'
);
$grid
->
column
(
'file'
,
'字体'
)
->
display
(
function
(
$item
){
$url
=
Storage
::
disk
(
'public'
)
->
url
(
$item
);
return
"<style>
@font-face {
font-family: 'ParlandoFont
{
$this
->
id
}
';
src: url('
{
$url
}
') format('truetype');
font-weight: normal;
font-style: normal;
}
.mfont{
font-family: 'ParlandoFont
{
$this
->
id
}
';
color: red;
}
</style><span class='mfont fa-2x'>字体示例:这里是临境有感</span>"
;
});
$grid
->
column
(
'created_at'
);
$grid
->
column
(
'updated_at'
)
->
sortable
();
$grid
->
filter
(
function
(
Grid\Filter
$filter
)
{
$filter
->
equal
(
'id'
);
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected
function
detail
(
$id
)
{
return
Show
::
make
(
$id
,
new
Font
(),
function
(
Show
$show
)
{
$show
->
field
(
'id'
);
$show
->
field
(
'id'
);
$show
->
field
(
'name'
);
$show
->
field
(
'file'
);
$show
->
field
(
'created_at'
);
$show
->
field
(
'updated_at'
);
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected
function
form
()
{
return
Form
::
make
(
new
Font
(),
function
(
Form
$form
)
{
$form
->
display
(
'id'
);
$form
->
text
(
'name'
,
'名称标识'
);
$form
->
file
(
'file'
,
'上传字体'
)
->
accept
(
'ttf,woff,woff2,otf,eot'
)
->
autoUpload
()
->
uniqueName
()
->
maxSize
(
'128000'
);
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
}
}
app/Admin/routes.php
View file @
8ccf949
...
...
@@ -26,6 +26,7 @@ Route::group([
/** 临境*/
$router
->
group
([
'prefix'
=>
'/linjing'
],
function
(
Router
$router
){
$router
->
resource
(
'/font'
,
'FontController'
);
$router
->
resource
(
'/template'
,
'VideoTempController'
);
$router
->
resource
(
'/official'
,
'AdminMakeVideoController'
);
});
...
...
app/Models/Font.php
0 → 100755
View file @
8ccf949
<?php
namespace
App\Models
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Model
;
class
Font
extends
Model
{
use
HasDateTimeFormatter
;
protected
$table
=
'font'
;
}
database/migrations/2022_06_16_172936_create_font_table.php
0 → 100755
View file @
8ccf949
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
CreateFontTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'font'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
string
(
'name'
)
->
default
(
''
)
->
comment
(
'名称标识'
);
$table
->
string
(
'file'
)
->
default
(
''
)
->
comment
(
'文件地址'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'font'
);
}
}
Please
register
or
login
to post a comment