<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\BilibiliVideos;
|
|
use Encore\Admin\Controllers\AdminController;
|
|
use Encore\Admin\Form;
|
|
use Encore\Admin\Grid;
|
|
use Encore\Admin\Show;
|
|
|
|
class BilibiliVideoController extends AdminController
|
|
{
|
|
/**
|
|
* Title for current resource.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $title = 'App\BilibiliVideos';
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$grid = new Grid(new BilibiliVideos());
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->column('id', __('Id'));
|
|
$grid->column('aid', __('Aid'));
|
|
$grid->column('title', __('Title'));
|
|
$grid->column('from_type', __('From type'));
|
|
$grid->column('from_collection_name', __('收藏夹'))->filter();
|
|
$grid->column('from_up_name', __('Up'))->filter();
|
|
$grid->column('is_download', __('是否要下载'))->editable('select', [1 => '下载', 0 => '不下载'])->filter();
|
|
$grid->column('is_downloaded', __('是否已下载'))->editable('select', [1 => '已下载', 0 => '未下载'])->filter()->sortable();
|
|
$grid->column('total_parts', __('分 P 数'));
|
|
$grid->column('created_at', __('Created at'))->sortable();
|
|
$grid->column('updated_at', __('Updated at'));
|
|
$grid->quickSearch('title', 'from_collection_name', 'from_up_name');
|
|
|
|
return $grid;
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
$show = new Show(BilibiliVideos::findOrFail($id));
|
|
|
|
$show->field('id', __('Id'));
|
|
$show->field('aid', __('Aid'));
|
|
$show->field('title', __('Title'));
|
|
$show->field('from_type', __('From type'));
|
|
$show->field('from_collection_name', __('From collection name'));
|
|
$show->field('from_up_name', __('From up name'));
|
|
$show->field('is_download', __('Is download'));
|
|
$show->field('is_downloaded', __('Is downloaded'));
|
|
$show->field('total_parts', __('Total parts'));
|
|
$show->field('created_at', __('Created at'));
|
|
$show->field('updated_at', __('Updated at'));
|
|
|
|
return $show;
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
$form = new Form(new BilibiliVideos());
|
|
|
|
$form->number('aid', __('Aid'));
|
|
$form->text('title', __('Title'));
|
|
$form->switch('from_type', __('From type'));
|
|
$form->text('from_collection_name', __('From collection name'));
|
|
$form->text('from_up_name', __('From up name'));
|
|
$form->switch('is_download', __('Is download'))->default(1);
|
|
$form->switch('is_downloaded', __('Is downloaded'));
|
|
$form->switch('total_parts', __('Total parts'))->default(1);
|
|
|
|
return $form;
|
|
}
|
|
}
|