提交代码
This commit is contained in:
99
vendor/encore/laravel-admin/tests/controllers/FileController.php
vendored
Normal file
99
vendor/encore/laravel-admin/tests/controllers/FileController.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Encore\Admin\Controllers\ModelForm;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Tests\Models\File;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
use ModelForm;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->grid());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($id) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->form()->edit($id));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('Upload file');
|
||||
|
||||
$content->body($this->form());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Admin::grid(File::class, function (Grid $grid) {
|
||||
$grid->id('ID')->sortable();
|
||||
|
||||
$grid->created_at();
|
||||
$grid->updated_at();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Admin::form(File::class, function (Form $form) {
|
||||
$form->display('id', 'ID');
|
||||
|
||||
$form->file('file1');
|
||||
$form->file('file2');
|
||||
$form->file('file3');
|
||||
$form->file('file4');
|
||||
$form->file('file5');
|
||||
$form->file('file6');
|
||||
|
||||
$form->display('created_at', 'Created At');
|
||||
$form->display('updated_at', 'Updated At');
|
||||
});
|
||||
}
|
||||
}
|
||||
103
vendor/encore/laravel-admin/tests/controllers/ImageController.php
vendored
Normal file
103
vendor/encore/laravel-admin/tests/controllers/ImageController.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Encore\Admin\Controllers\ModelForm;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Tests\Models\Image;
|
||||
|
||||
class ImageController extends Controller
|
||||
{
|
||||
use ModelForm;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->grid());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($id) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->form()->edit($id));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('Upload image');
|
||||
|
||||
$content->body($this->form());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Admin::grid(Image::class, function (Grid $grid) {
|
||||
$grid->id('ID')->sortable();
|
||||
|
||||
$grid->created_at();
|
||||
$grid->updated_at();
|
||||
|
||||
$grid->disableFilter();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Admin::form(Image::class, function (Form $form) {
|
||||
$form->display('id', 'ID');
|
||||
|
||||
$form->image('image1');
|
||||
$form->image('image2')->rotate(90);
|
||||
$form->image('image3')->flip('v');
|
||||
$form->image('image4')->move(null, 'renamed.jpeg');
|
||||
$form->image('image5')->name(function ($file) {
|
||||
return 'asdasdasdasdasd.'.$file->guessExtension();
|
||||
});
|
||||
$form->image('image6')->uniqueName();
|
||||
|
||||
$form->display('created_at', 'Created At');
|
||||
$form->display('updated_at', 'Updated At');
|
||||
});
|
||||
}
|
||||
}
|
||||
96
vendor/encore/laravel-admin/tests/controllers/MultipleImageController.php
vendored
Normal file
96
vendor/encore/laravel-admin/tests/controllers/MultipleImageController.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Encore\Admin\Controllers\ModelForm;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Tests\Models\MultipleImage;
|
||||
|
||||
class MultipleImageController extends Controller
|
||||
{
|
||||
use ModelForm;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->grid());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($id) {
|
||||
$content->header('header');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->form()->edit($id));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('Upload image');
|
||||
|
||||
$content->body($this->form());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Admin::grid(Image::class, function (Grid $grid) {
|
||||
$grid->id('ID')->sortable();
|
||||
|
||||
$grid->created_at();
|
||||
$grid->updated_at();
|
||||
|
||||
$grid->disableFilter();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Admin::form(MultipleImage::class, function (Form $form) {
|
||||
$form->display('id', 'ID');
|
||||
|
||||
$form->multipleImage('pictures');
|
||||
|
||||
$form->display('created_at', 'Created At');
|
||||
$form->display('updated_at', 'Updated At');
|
||||
});
|
||||
}
|
||||
}
|
||||
164
vendor/encore/laravel-admin/tests/controllers/UserController.php
vendored
Normal file
164
vendor/encore/laravel-admin/tests/controllers/UserController.php
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Encore\Admin\Controllers\ModelForm;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Tests\Models\Tag;
|
||||
use Tests\Models\User;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
use ModelForm;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('All users');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->grid());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($id) {
|
||||
$content->header('Edit user');
|
||||
$content->description('description');
|
||||
|
||||
$content->body($this->form()->edit($id));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @return Content
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return Admin::content(function (Content $content) {
|
||||
$content->header('Create user');
|
||||
|
||||
$content->body($this->form());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Admin::grid(User::class, function (Grid $grid) {
|
||||
$grid->id('ID')->sortable();
|
||||
|
||||
$grid->username();
|
||||
$grid->email();
|
||||
$grid->mobile();
|
||||
$grid->full_name();
|
||||
$grid->avatar()->display(function ($avatar) {
|
||||
return "<img src='{$avatar}' />";
|
||||
});
|
||||
$grid->profile()->postcode('Post code');
|
||||
$grid->profile()->address();
|
||||
$grid->position('Position');
|
||||
$grid->column('profile.color');
|
||||
$grid->profile()->start_at('开始时间');
|
||||
$grid->profile()->end_at('结束时间');
|
||||
|
||||
$grid->column('column1_not_in_table')->display(function () {
|
||||
return 'full name:'.$this->full_name;
|
||||
});
|
||||
|
||||
$grid->column('column2_not_in_table')->display(function () {
|
||||
return $this->email.'#'.$this->profile['color'];
|
||||
});
|
||||
|
||||
$grid->tags()->display(function ($tags) {
|
||||
$tags = collect($tags)->map(function ($tag) {
|
||||
return "<code>{$tag['name']}</code>";
|
||||
})->toArray();
|
||||
|
||||
return implode('', $tags);
|
||||
});
|
||||
|
||||
$grid->created_at();
|
||||
$grid->updated_at();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->like('username');
|
||||
$filter->like('email');
|
||||
$filter->like('profile.postcode');
|
||||
$filter->between('profile.start_at')->datetime();
|
||||
$filter->between('profile.end_at')->datetime();
|
||||
});
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
if ($actions->getKey() % 2 == 0) {
|
||||
$actions->append('<a href="/" class="btn btn-xs btn-danger">detail</a>');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
Form::extend('map', Form\Field\Map::class);
|
||||
Form::extend('editor', Form\Field\Editor::class);
|
||||
|
||||
return Admin::form(User::class, function (Form $form) {
|
||||
$form->disableDeletion();
|
||||
|
||||
$form->display('id', 'ID');
|
||||
$form->text('username');
|
||||
$form->email('email')->rules('required');
|
||||
$form->mobile('mobile');
|
||||
$form->image('avatar')->help('上传头像', 'fa-image');
|
||||
$form->ignore(['password_confirmation']);
|
||||
$form->password('password')->rules('confirmed');
|
||||
$form->password('password_confirmation');
|
||||
|
||||
$form->divider();
|
||||
|
||||
$form->text('profile.first_name');
|
||||
$form->text('profile.last_name');
|
||||
$form->text('profile.postcode')->help('Please input your postcode');
|
||||
$form->textarea('profile.address')->rows(15);
|
||||
$form->map('profile.latitude', 'profile.longitude', 'Position');
|
||||
$form->color('profile.color');
|
||||
$form->datetime('profile.start_at');
|
||||
$form->datetime('profile.end_at');
|
||||
|
||||
$form->multipleSelect('tags', 'Tags')->options(Tag::all()->pluck('name', 'id')); //->rules('max:10|min:3');
|
||||
|
||||
$form->display('created_at', 'Created At');
|
||||
$form->display('updated_at', 'Updated At');
|
||||
|
||||
$form->html('<a html-field>html...</a>');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user