Home >PHP Framework >Laravel >The new expansion system is online! Release Dcat Admin v2.0.0-BETA version~
The following is the tutorial column of Laravel to introduce the release of Dcat Admin v2.0.0-BETA. I hope it will be helpful to friends in need!
PrefaceHi, hello classmates! After many days, Dcat Admin
finally ushered in the first version of2.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
What are the changes?
1. Extension We have focused on optimizing the extension
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 andcomposer installation methods. The
App Market function 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 capabilitiesIn 2.0
, we have The block layout 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'); }); });
##2.0 is also supported in
Nested layouts use column
and rows
layouts, such as This function supports both
data forms
Tool form3. Refactor the form response method
$form->tab('标题', function (Form $form) { $form->column(6, function (Form $form) { ... }); $form->column(6, function (Form $form) { ... });});
in version1.0 The response methods of the form are only
success, error
and redirect
, which cannot meet some more complex scenarios. In 2.0
we let the form The response methods of action
are unified to support more functions and reduce the learning cost of developers. In the data form
<pre class="brush:php;toolbar:false">$form->saving(function (Form $form) {
return $form
->response()
->success('保存成功')
->script('console.log("执行JS代码")')
->redirect('auth/users');});</pre>
In the tool form
public function handle(array $input){ ... return $this ->response() ->alert() ->success('成功') ->detail('详细内容');}4. Separation of JS code and PHP code
This function is a follow-up to the new features of laravel-admin2.0 version. In 2.0, it is recommended to put the
JS code into the view file, example The code in <pre class='brush:php;toolbar:false;'><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></pre>
<script></script>
and
The above is the detailed content of The new expansion system is online! Release Dcat Admin v2.0.0-BETA version~. For more information, please follow other related articles on the PHP Chinese website!