episode->name;
}
protected function content(Content $content, $episodeId = 0)
{
$this->episode = Episode::find($episodeId);
return $content
->translation($this->translation())
->breadcrumb(
['text' => $this->episode->name],
['text' => '短剧上传'],
)
->title($this->title())
->description('短剧上传');
}
public function index(Content $content,$episodeId = 0)
{
return $this->content($content,$episodeId)
->body($this->grid());
}
public function create(Content $content,$episodeId = 0)
{
return $this->content($content,$episodeId)
->body($this->form());
}
public function update($episodeId, $id = 0)
{
$this->episode = Episode::find($episodeId);
return $this->form()->update($id);
}
public function store($episodeId = 0)
{
$this->episode = Episode::find($episodeId);
return $this->form()->store();
}
public function edit($episodeId, Content $content, $id = 0)
{
return $this->content($content,$episodeId)
->body($this->form()->edit($id));
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(EpisodesList::with(['episode'])->where('episodes_id', $this->episode->id), function (Grid $grid) {
//$grid->column('id');
$grid->column('sort')->display(function (){
return '第'.$this->sort.'集';
})->editable();
$grid->column('episode.name','短剧名称');
$grid->column('is_free')
->using(config('global.episode_free'))
->label(['success', 'primary'])->sortable();
$grid->column('origin_price')->editable();
$grid->column('sale_price')->editable();
$grid->column('url')->display(function (){
return '视频链接';
});
$url = admin_url('/episodes/batch/'.$this->episode->id.'/upload');
$grid->tools('
批量上传');
$grid->hideColumns(['id']);
$grid->batchActions([new BatchEditEpisodeList()]);
$grid->disableViewButton();
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new EpisodesList(), function (Form $form) {
$sort = EpisodesList::where('episodes_id',$this->episode->id)->max('sort');
$form->hidden('id');
$form->hidden('episodes_id')->value();
$form->number('sort')->default($sort + 1)->min(1);
$form->radio('is_free')
->options(config('global.episode_free'))
->when(0, function (Form $form) {
$form->number('sale_price')->min(1);;
})->default(1);
$form->file('url')->chunkSize(1024)->maxSize(1024 * 1024)->saveFullUrl()
->uniqueName()->autoUpload()
->autoSave(false)
->removable(false)
->width(4)->required();;
$form->display('created_at');
$form->disableViewButton();
$form->disableDeleteButton();
$form->disableListButton();
$form->disableEditingCheck();
$form->disableViewCheck();
$form->disableCreatingCheck();
});
}
}