Home> PHP Framework> Laravel> body text

The new expansion system is online! Release Dcat Admin v2.0.0-BETA version~

藏色散人
Release: 2020-10-20 13:53:03
forward
3984 people have browsed it

The following is the tutorial column ofLaravelto introduce the release of Dcat Admin v2.0.0-BETA. I hope it will be helpful to friends in need!

The new expansion system is online! Release Dcat Admin v2.0.0-BETA version~

PrefaceHi, hello classmates! After many days,Dcat Admin

finally ushered in the first version of

2.0. Here is a brief introduction to the main changes. Everyone is welcome to install and experience it. If there are any problems, they will be fixed immediately~Installation

The v2.0.1-beta version has been released

composer require dcat/laravel-admin:v2.0.1-beta -vvv
Copy after login

What are the changes?

1. ExtensionWe have focused on optimizing theextension

function in this version, mainly simplifying The extension usage process allows users to install, uninstall, and upgrade extensions through the page, and supports both page compression and

composerinstallation methods. TheApp Marketfunction will be launched when the official version is released, so stay tuned~The detailed usage documentation will be gradually updated this week~

2. Enhance form layout capabilitiesIn2.0

, we have

The blocklayout function has been refactored to support more complex layouts. Example

$form->block(8, function (Form\BlockForm $form) { $form->title('基本设置'); $form->showFooter(); $form->width(9, 2); $form->column(6, function (Form\BlockForm $form) { $form->display('id'); $form->text('name'); $form->email('email'); $form->image('avatar'); $form->password('password'); }); $form->column(6, function (Form\BlockForm $form) { $form->text('username'); $form->email('mobile'); $form->textarea('description'); }); }); $form->block(4, function (Form\BlockForm $form) { $form->title('分块2'); $form->text('nickname'); $form->number('age'); $form->radio('status')->options(['1' => '默认', 2 => '冻结'])->default(1); $form->next(function (Form\BlockForm $form) { $form->title('分块3'); $form->date('birthday'); $form->date('created_at'); }); });
Copy after login

##2.0is also supported in

tab

Nested layouts usecolumnandrowslayouts, such asThis function supports bothdata forms

and
Tool form

$form->tab('标题', function (Form $form) { $form->column(6, function (Form $form) { ... }); $form->column(6, function (Form $form) { ... });});
Copy after login

3. Refactor the form response method

in version1.0The response methods of the form are only

success

,errorandredirect, which cannot meet some more complex scenarios. In2.0we let the form The response methods ofactionare unified to support more functions and reduce the learning cost of developers.In the data form

$form->saving(function (Form $form) { return $form ->response() ->success('保存成功') ->script('console.log("执行JS代码")') ->redirect('auth/users');});
Copy after login
In the tool form

public function handle(array $input){ ... return $this ->response() ->alert() ->success('成功') ->detail('详细内容');}
Copy after login

4. Separation of JS code and PHP code

This function is a follow-up to the new features of laravel-admin2.0 version. In2.0, it is recommended to put the

JS

code into the view file, exampleThe code in

<style> .popover{z-index:29891015} </style> <div class="{{$viewClass[&#39;form-group&#39;]}}"> <div for="{{ $id }}" class="{{$viewClass[&#39;label&#39;]}} control-label"> <span>{!! $label !!}</span> </div> <div class="{{$viewClass[&#39;field&#39;]}}"> @include(&#39;admin::form.error&#39;) <div class="input-group"> <span class="input-group-prepend"><span class="input-group-text bg-white" style="padding: 4px"><i style="width: 24px;height: 100%;background: {!! $value !!}"></i></span></span> <input {!! $attributes !!} /> @if ($append) <span class="input-group-append">{!! $append !!}</span> @endif </div> @include(&#39;admin::form.help-block&#39;) </div> </div> <script require="@color"> $(&#39;{{ $selector }}&#39;).colorpicker({!! json_encode($options) !!}).on(&#39;colorpickerChange&#39;, function(event) { $(this).parents(&#39;.input-group&#39;).find(&#39;.input-group-prepend i&#39;).css(&#39;background-color&#39;, event.color.toString()); }); </script>
Copy after login