增加悬浮

This commit is contained in:
2020-09-21 16:39:52 +08:00
parent 0d44bcda5a
commit c120c05e9b
8 changed files with 142 additions and 62 deletions

View File

@@ -35,7 +35,7 @@ class IndexController extends AdminController
$grid->column('cover', '图片')->image('', 60, 60);
$grid->column('category.title', '分类名称');
$grid->column('title', '图片名称');
$grid->column('url', '地址');
// $grid->column('url', '地址')->width(80);
$grid->column('sort', '排序');
return $grid;

View File

@@ -7,6 +7,7 @@ use App\Models\Category;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
class IndexController extends AdminController
{
@@ -76,4 +77,16 @@ class IndexController extends AdminController
return $form;
}
public function detail($id)
{
$show = new Show(Article::findOrFail($id));
$show->field('id', 'ID');
$show->field('title', '标题');
$show->field('content', '内容');
$show->field('created_at');
return $show;
}
}

View File

@@ -1,60 +1,60 @@
<?php
namespace App\Http\Controllers;
use App\Models\Patent;
use App\Models\Category;
use Illuminate\Http\Request;
class PatentController extends Controller
{
//显示论文详情
public function show(Patent $patent)
{
$next = Patent::where('id', '>', $patent->id)->where('status', 1)->first();
return view('patents.show', compact('patent', 'next'));
}
//显示文章列表
public function list(Request $request)
{
$type = $request->type;
$title = $request->title;
$number = $request->number;
$category_id = $request->category_id;
$nickname = $request->nickname;
$publication = $request->publication;
$year = $request->year;
$patents = Patent::where('status', 1)
->when($type, function ($q) use ($type) {
$q->where('type', $type);
})
->when($title, function ($q) use ($title) {
$q->where('title', 'like', "%{$title}%");
})
->when($number, function ($q) use ($number) {
$q->where('number', $number);
})
->when($category_id, function ($q) use ($category_id) {
$q->where('category_id', $category_id);
})
->when($nickname, function ($q) use ($nickname) {
$q->where('nickname', 'like', "%{$nickname}%");
})
->when($publication, function ($q) use ($publication) {
$q->where('publication', $publication);
})
->when($year, function ($q) use ($year) {
$q->where('year', 'like', "%{$year}%");
})
->latest('sort')
->latest()
->paginate(2);
return view('patents.list', compact('patents'));
}
}
<?php
namespace App\Http\Controllers;
use App\Models\Patent;
use App\Models\Category;
use Illuminate\Http\Request;
class PatentController extends Controller
{
//显示论文详情
public function show(Patent $patent)
{
$next = Patent::where('id', '>', $patent->id)->where('status', 1)->first();
return view('patents.show', compact('patent', 'next'));
}
//显示文章列表
public function list(Request $request)
{
$type = $request->type;
$title = $request->title;
$number = $request->number;
$category_id = $request->category_id;
$nickname = $request->nickname;
$publication = $request->publication;
$year = $request->year;
$patents = Patent::where('status', 1)
->when($type, function ($q) use ($type) {
$q->where('type', $type);
})
->when($title, function ($q) use ($title) {
$q->where('title', 'like', "%{$title}%");
})
->when($number, function ($q) use ($number) {
$q->where('number', $number);
})
->when($category_id, function ($q) use ($category_id) {
$q->where('category_id', $category_id);
})
->when($nickname, function ($q) use ($nickname) {
$q->where('nickname', 'like', "%{$nickname}%");
})
->when($publication, function ($q) use ($publication) {
$q->where('publication', $publication);
})
->when($year, function ($q) use ($year) {
$q->where('year', 'like', "%{$year}%");
})
->latest('sort')
->latest()
->paginate();
return view('patents.list', compact('patents'));
}
}