Commit 424fb513 by mushishixian

生成用户地址管理后台代码

parent 55d87a48
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\UserAddress;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class UserAddressController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new UserAddress(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('user_id');
$grid->column('country');
$grid->column('first_name');
$grid->column('last_name');
$grid->column('address_line1');
$grid->column('address_line2');
$grid->column('city');
$grid->column('postal_code');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new UserAddress(), function (Show $show) {
$show->field('id');
$show->field('user_id');
$show->field('country');
$show->field('first_name');
$show->field('last_name');
$show->field('address_line1');
$show->field('address_line2');
$show->field('city');
$show->field('postal_code');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new UserAddress(), function (Form $form) {
$form->display('id');
$form->text('user_id');
$form->text('country');
$form->text('first_name');
$form->text('last_name');
$form->text('address_line1');
$form->text('address_line2');
$form->text('city');
$form->text('postal_code');
$form->display('created_at');
$form->display('updated_at');
});
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\UserAddress as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class UserAddress extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class UserAddress extends Model
{
use HasDateTimeFormatter;
protected $table = 'user_addresses';
}
<?php
return [
'labels' => [
'UserAddress' => 'UserAddress',
'user-address' => 'UserAddress',
],
'fields' => [
'user_id' => '用户ID',
'country' => '国家',
'first_name' => '名字',
'last_name' => '姓氏',
'address_line1' => '地址',
'address_line2' => '地址',
'city' => '城市',
'postal_code' => '邮政编码',
],
'options' => [
],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment