Skip to content

Commit

Permalink
feature: use primarykey not id
Browse files Browse the repository at this point in the history
  • Loading branch information
krissss committed Nov 1, 2022
1 parent 8ac9796 commit 7e1209a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Controller/AmisSourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ protected function amisCrud(Request $request): Amis\Crud
->config($this->crudConfig())
->schema([
'primaryField' => $this->repository()->getPrimaryKey(),
'api' => 'get:' . $routePrefix . '?_ajax=1',
//'quickSaveApi' => 'put:' . $routePrefix . '/all, // 目前没有批量保存接口
'quickSaveItemApi' => 'put:' . $routePrefix . '/${id}', // 需要 column 配置为 'quickEdit' => ['saveImmediately' => true]
'api' => "get:{$routePrefix}?_ajax=1",
//'quickSaveApi' => "put:{$routePrefix}/all", // 目前没有批量保存接口
'quickSaveItemApi' => "put:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}", // 需要 column 配置为 'quickEdit' => ['saveImmediately' => true]
'bulkActions' => $this->gridBatchActions(),
])
->withColumns(array_merge(
Expand All @@ -125,7 +125,7 @@ protected function crudConfig(): array
protected function grid(): array
{
return [
Amis\GridColumn::make()->name('id'),
Amis\GridColumn::make()->name($this->repository()->getPrimaryKey()),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Traits/AmisSourceController/DeleteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function addDeleteAction(Amis\GridColumnActions $actions, string $rout
{
if ($this->authDestroy()) {
$actions->withDelete(
"delete:{$routePrefix}/\${id}",
"delete:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}",
$this->authDestroyVisible()
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Traits/AmisSourceController/DetailTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function addDetailAction(Amis\GridColumnActions $actions, string $rout
if ($this->authDetail()) {
$actions->withDetail(
$this->buildDetailAttributes($this->detail()),
"get:{$routePrefix}/\${id}",
"get:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}",
$this->authDetailVisible()
);
}
Expand All @@ -67,7 +67,7 @@ protected function addDetailAction(Amis\GridColumnActions $actions, string $rout
protected function detail(): array
{
return [
Amis\DetailAttribute::make()->name('id'),
Amis\DetailAttribute::make()->name($this->repository()->getPrimaryKey()),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function addRecoveryAction(Amis\GridColumnActions $actions, string $ro
{
if ($this->authRecovery()) {
$actions->withRecovery(
"put:{$routePrefix}/\${id}/recovery",
"put:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}/recovery",
$this->authRecoveryVisible()
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Traits/AmisSourceController/UpdateTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected function addUpdateAction(Amis\GridColumnActions $actions, string $rout
if ($this->authUpdate()) {
$actions->withUpdate(
$this->buildFormFields($this->form(static::SCENE_UPDATE)),
"put:{$routePrefix}/\${id}",
"get:{$routePrefix}/\${id}",
"put:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}",
"get:{$routePrefix}/\${{$this->repository()->getPrimaryKey()}}",
$this->authUpdateVisible()
);
}
Expand Down

0 comments on commit 7e1209a

Please sign in to comment.