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
李帅
2023-03-20 18:07:02 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
434aba01bac2bf09392efe477cf9cbb758c2ee4e
434aba01
1 parent
e2b4c623
1.重构一言表
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
175 additions
and
6 deletions
app/Admin/Controllers/OnePoemController.php
app/Admin/Renderable/VerseTable.php
app/Http/Controllers/V1/HomeController.php
app/Models/OnePoem2.php
database/migrations/2023_03_20_214554_create_one_poem2_table.php
database/migrations/2023_03_20_214555_create_verse_one_poem2_table.php
app/Admin/Controllers/OnePoemController.php
View file @
434aba0
...
...
@@ -2,6 +2,7 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Renderable\VerseTable
;
use
App\Admin\Repositories\OnePoem
;
use
App\Admin\Repositories\Verse
;
use
App\Models\Author
;
...
...
@@ -11,7 +12,7 @@ use Dcat\Admin\Grid;
use
Dcat\Admin\Layout\Content
;
use
Dcat\Admin\Show
;
use
Dcat\Admin\Http\Controllers\AdminController
;
use
Dcat\Admin\Widgets\Card
;
use
Illuminate\Http\Request
;
class
OnePoemController
extends
AdminController
{
...
...
@@ -70,7 +71,7 @@ class OnePoemController extends AdminController
->
title
(
$this
->
title
())
->
description
(
'注意:基础库中内容只做参考,创建的一言与其他表数据不耦合!理论上可自行组装句子,也可按诗词原文复制。'
)
// ->description($this->description()['create'] ?? trans('admin.create'))
->
body
(
Card
::
make
(
$this
->
PoetryGrid
()))
//
->body(Card::make($this->PoetryGrid()))
->
body
(
$this
->
form
());
}
...
...
@@ -85,16 +86,33 @@ class OnePoemController extends AdminController
$form
->
display
(
'id'
);
$form
->
text
(
'title'
);
$form
->
text
(
'author'
);
$form
->
textarea
(
'content'
);
$form
->
text
(
'annotate'
);
$form
->
text
(
'spelling'
);
$form
->
text
(
'en'
);
$form
->
hasMany
(
'components'
,
'诗句组'
,
function
(
Form\NestedForm
$form
)
{
$form
->
selectTable
(
'font_file'
,
'诗句'
)
->
title
(
'字体选择'
)
->
from
(
VerseTable
::
make
())
->
model
(
\App\Models\Verse
::
class
,
'id'
,
'stanza'
);
});
// $form->textarea('content');
// $form->text('annotate');
// $form->text('spelling');
// $form->text('en');
$form
->
display
(
'created_at'
);
$form
->
display
(
'updated_at'
);
});
}
public
function
store
()
{
return
request
()
->
all
();
// return $this->form()->store();
}
protected
function
PoetryGrid
()
{
return
Grid
::
make
(
new
Verse
(),
function
(
Grid
$grid
)
{
...
...
app/Admin/Renderable/VerseTable.php
0 → 100644
View file @
434aba0
<?php
/**
* Created by PhpStorm.
* User: lishuai
* Date: 2022/1/10
* Time: 5:57 PM
*/
namespace
App\Admin\Renderable
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Grid\LazyRenderable
;
use
App\Models\Author
;
use
App\Models\Poetry
;
use
App\Models\Verse
;
class
VerseTable
extends
LazyRenderable
{
public
function
grid
()
:
Grid
{
return
Grid
::
make
(
new
Verse
(),
function
(
Grid
$grid
)
{
$grid
->
model
()
->
with
([
'poetry'
]);
$grid
->
column
(
'id'
)
->
sortable
();
$grid
->
column
(
'author_id'
)
->
display
(
function
(){
$id
=
$this
->
poetry_id
;
$poetry
=
Poetry
::
query
()
->
find
(
$id
);
$author_id
=
$poetry
->
author_id
;
$author
=
Author
::
query
()
->
find
(
$author_id
);
return
$author
->
name
;
})
->
copyable
();
$grid
->
column
(
'poetry.name'
)
->
copyable
();
$grid
->
column
(
'stanza'
)
->
copyable
();
$grid
->
column
(
'annotate'
)
->
copyable
();
$grid
->
column
(
'spelling'
)
->
copyable
();
$grid
->
column
(
'en'
)
->
copyable
();
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid
->
withBorder
();
$grid
->
quickSearch
([
'stanza'
])
->
placeholder
(
'快捷搜索诗句(节)'
);
$grid
->
paginate
(
5
);
$grid
->
simplePaginate
();
$grid
->
disableActions
();
$grid
->
disableCreateButton
();
$grid
->
expandFilter
();
// 默认展开搜索
$grid
->
filter
(
function
(
Grid\Filter
$filter
)
{
// $filter->where('author_id',function ($query){
// $author = Author::query()->where('name','like',"%{$this->input}%")->get()->pluck('id');
// $poetry =Poetry::query()->whereIn('author_id',$author)->get()->pluck('id');
// $query->whereIn('poetry_id',$poetry);
// })->width(3);
$filter
->
like
(
'poetry.name'
)
->
width
(
6
);
// $filter->like('stanza')->width(4);
$filter
->
panel
();
});
});
}
}
\ No newline at end of file
app/Http/Controllers/V1/HomeController.php
View file @
434aba0
...
...
@@ -73,6 +73,7 @@ class HomeController extends Controller
public
function
poem
(
$id
)
{
// todo 多对多关系
try
{
return
Response
::
success
(
OnePoem
::
query
()
->
find
(
$id
));
}
catch
(
\Exception
$exception
){
...
...
app/Models/OnePoem2.php
0 → 100755
View file @
434aba0
<?php
namespace
App\Models
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Model
;
class
OnePoem2
extends
Model
{
use
HasDateTimeFormatter
;
protected
$table
=
'one_poem2'
;
public
function
admin_make_video
()
{
return
$this
->
belongsTo
(
AdminMakeVideo
::
class
,
'poem_id'
);
}
}
database/migrations/2023_03_20_214554_create_one_poem2_table.php
0 → 100644
View file @
434aba0
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateOnePoem2Table
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'one_poem2'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'title'
)
->
default
(
''
)
->
comment
(
'一言标题'
);
$table
->
string
(
'author'
)
->
default
(
''
)
->
comment
(
'作者'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'one_poem2'
);
}
}
database/migrations/2023_03_20_214555_create_verse_one_poem2_table.php
0 → 100644
View file @
434aba0
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateOnePoem2Table
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'verse_poem2'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'verse_id'
)
->
comment
(
'诗句id'
);
$table
->
integer
(
'poem_id'
)
->
comment
(
'一言id'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'verse_poem2'
);
}
}
Please
register
or
login
to post a comment