添加后台APP版本管理
parent
20bebbdb3f
commit
741cdfb7fb
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Repositories\AppVersion;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Show;
|
||||
|
||||
class AppVersionController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new AppVersion(), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('name');
|
||||
$grid->column('v');
|
||||
$grid->column('cate')->using([
|
||||
1=>'ios',
|
||||
2=>'android',
|
||||
]);
|
||||
$grid->column('is_force')->bool();
|
||||
$grid->column('link');
|
||||
$grid->column('created_at')->sortable();
|
||||
|
||||
//排序
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
/** 操作 **/
|
||||
//新增
|
||||
if (Admin::user()->can('dcat.admin.app_versions.create')) {
|
||||
$grid->disableCreateButton(false);
|
||||
$grid->enableDialogCreate();
|
||||
}
|
||||
//修改
|
||||
$grid->showQuickEditButton(Admin::user()->can('dcat.admin.app_versions.edit'));
|
||||
//删除以及自定义操作
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableDelete(Admin::user()->cannot('dcat.admin.app_versions.destroy'));
|
||||
});
|
||||
|
||||
/** 查询 **/
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->panel();
|
||||
$filter->equal('name')->width(3);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new AppVersion(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('name');
|
||||
$show->field('v');
|
||||
$show->field('cate');
|
||||
$show->field('is_force');
|
||||
$show->field('link');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new AppVersion(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('name')->required();
|
||||
$form->number('v')->min(0);
|
||||
$form->radio('cate')->options([
|
||||
1=>'ios',
|
||||
2=>'android',
|
||||
]);
|
||||
$form->switch('is_force');
|
||||
$form->text('link')->required();
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\AppVersion as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class AppVersion extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
|
|
@ -103,6 +103,10 @@ Route::group([
|
|||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||
])->names('order_reduce_ranges');
|
||||
|
||||
$router->resource('app_versions', 'AppVersionController')->only([
|
||||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||
])->names('app_versions');
|
||||
|
||||
/** api接口 **/
|
||||
$router->get('api/product-categories', 'ProductCategoryController@categories')->name('api.product_categories');
|
||||
$router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppVersion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasDateTimeFormatter;
|
||||
|
||||
protected $casts = [
|
||||
'is_force' => 'bool',
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAppVersionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('app_versions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->comment('版本名称');
|
||||
$table->unsignedBigInteger('v')->comment('版本号');
|
||||
$table->unsignedTinyInteger('cate')->comment('类别:1ios,2android');
|
||||
$table->unsignedTinyInteger('is_force')->default(0)->comment('是否强制更新');
|
||||
$table->text('link')->comment('资源链接');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('app_versions');
|
||||
}
|
||||
}
|
||||
|
|
@ -75,6 +75,11 @@ class AdminMenuSeeder extends Seeder
|
|||
'icon' => '',
|
||||
'uri' => 'shipping-templates',
|
||||
],
|
||||
[
|
||||
'title' => 'App版本管理',
|
||||
'icon' => '',
|
||||
'uri' => 'app_versions',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -210,6 +210,10 @@ class AdminPermissionSeeder extends Seeder
|
|||
'failed' => ['name' =>'作废'],
|
||||
],
|
||||
],
|
||||
'app_versions'=>[
|
||||
'name' =>'App版本管理',
|
||||
'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'],
|
||||
],
|
||||
];
|
||||
try {
|
||||
DB::begintransaction();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ namespace Dcat\Admin {
|
|||
* @property Grid\Column|Collection state
|
||||
* @property Grid\Column|Collection remarks
|
||||
* @property Grid\Column|Collection tracking_number
|
||||
* @property Grid\Column|Collection v
|
||||
* @property Grid\Column|Collection cate
|
||||
* @property Grid\Column|Collection is_force
|
||||
* @property Grid\Column|Collection link
|
||||
* @property Grid\Column|Collection is_recommend
|
||||
* @property Grid\Column|Collection _lft
|
||||
* @property Grid\Column|Collection _rgt
|
||||
|
|
@ -228,6 +232,10 @@ namespace Dcat\Admin {
|
|||
* @method Grid\Column|Collection state(string $label = null)
|
||||
* @method Grid\Column|Collection remarks(string $label = null)
|
||||
* @method Grid\Column|Collection tracking_number(string $label = null)
|
||||
* @method Grid\Column|Collection v(string $label = null)
|
||||
* @method Grid\Column|Collection cate(string $label = null)
|
||||
* @method Grid\Column|Collection is_force(string $label = null)
|
||||
* @method Grid\Column|Collection link(string $label = null)
|
||||
* @method Grid\Column|Collection is_recommend(string $label = null)
|
||||
* @method Grid\Column|Collection _lft(string $label = null)
|
||||
* @method Grid\Column|Collection _rgt(string $label = null)
|
||||
|
|
@ -400,6 +408,10 @@ namespace Dcat\Admin {
|
|||
* @property Show\Field|Collection state
|
||||
* @property Show\Field|Collection remarks
|
||||
* @property Show\Field|Collection tracking_number
|
||||
* @property Show\Field|Collection v
|
||||
* @property Show\Field|Collection cate
|
||||
* @property Show\Field|Collection is_force
|
||||
* @property Show\Field|Collection link
|
||||
* @property Show\Field|Collection is_recommend
|
||||
* @property Show\Field|Collection _lft
|
||||
* @property Show\Field|Collection _rgt
|
||||
|
|
@ -567,6 +579,10 @@ namespace Dcat\Admin {
|
|||
* @method Show\Field|Collection state(string $label = null)
|
||||
* @method Show\Field|Collection remarks(string $label = null)
|
||||
* @method Show\Field|Collection tracking_number(string $label = null)
|
||||
* @method Show\Field|Collection v(string $label = null)
|
||||
* @method Show\Field|Collection cate(string $label = null)
|
||||
* @method Show\Field|Collection is_force(string $label = null)
|
||||
* @method Show\Field|Collection link(string $label = null)
|
||||
* @method Show\Field|Collection is_recommend(string $label = null)
|
||||
* @method Show\Field|Collection _lft(string $label = null)
|
||||
* @method Show\Field|Collection _rgt(string $label = null)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
return [
|
||||
'labels' => [
|
||||
'AppVersion' => 'AppVersion',
|
||||
'app-version' => 'AppVersion',
|
||||
],
|
||||
'fields' => [
|
||||
'name' => '版本名称',
|
||||
'v' => '版本号',
|
||||
'cate' => '类别',
|
||||
'is_force' => '强制更新',
|
||||
'link' => '资源链接',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue