Skip to content

Commit 1de67de

Browse files
[6.x] $tableName must be required (#1691)
* Fix tableName tests * Update dependencies
1 parent ca64bd7 commit 1de67de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+466
-316
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
],
2020
"require": {
2121
"php": "^8.2",
22-
"livewire/livewire": "^3.5.6",
22+
"livewire/livewire": "^3.5.8",
2323
"laravel/prompts": "^0.1.25"
2424
},
2525
"require-dev": {
2626
"composer/composer": "^2.7.9",
2727
"laravel/pint": "1.17",
28-
"laradumps/laradumps-core": "^2.2.1",
28+
"laradumps/laradumps-core": "^2.2.2",
2929
"larastan/larastan": "^2.9.8",
30-
"pestphp/pest": "^2.35",
30+
"pestphp/pest": "^2.35.1",
3131
"orchestra/testbench": "^9.4",
3232
"laradumps/laradumps": "^3.2",
33-
"laravel/scout": "^10.11.2",
33+
"laravel/scout": "^10.11.3",
3434
"openspout/openspout": "^4.24.5"
3535
},
3636
"suggest": {

dist/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"/powergrid.js": "/powergrid.js?id=85ea731ef43f4f2726f191a79396ab7b",
2+
"/powergrid.js": "/powergrid.js?id=370e1616c92a03ffc8b55433d3b75b54",
33
"/bootstrap5.css": "/bootstrap5.css?id=a27af22343149104b2aa3283d8fd502b",
44
"/tailwind.css": "/tailwind.css?id=924477e2afcb2cb56aa392e266ee56ca"
55
}

dist/powergrid.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/pg-render-actions.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ export default (params) => ({
3131
return value;
3232
}
3333

34-
const actions = this.rowId
35-
? window[`pgActions_${this.parentId ?? this.$wire.id}`][this.rowId]
36-
: window[`pgActionsHeader_${this.$wire.id}`];
34+
let actions = null;
3735

38-
if (typeof actions !== "object") {
36+
if (this.rowId) {
37+
const wireId = this.parentId ?? this.$wire.id;
38+
const pgActions = window[`pgActions_${wireId}`];
39+
40+
if (pgActions && pgActions[this.rowId] !== undefined) {
41+
actions = pgActions[this.rowId];
42+
}
43+
44+
const pgActionsHeader = window[`pgActionsHeader_${this.$wire.id}`];
45+
if (!actions && pgActionsHeader !== undefined) {
46+
actions = pgActionsHeader;
47+
}
48+
}
49+
50+
if (typeof actions !== "object" || actions === null) {
3951
return '';
4052
}
4153

resources/stubs/table.collection.stub

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use PowerComponents\LivewirePowerGrid\PowerGridComponent;
1111

1212
final class {{ componentName }} extends PowerGridComponent
1313
{
14-
public function datasource(): ?Collection
14+
public string $tableName = '{{ tableName }}';
15+
16+
public function datasource(): Collection
1517
{
1618
return collect([
1719
['id' => 1, 'name' => 'Name 1', 'price' => 1.58, 'created_at' => now(),],

resources/stubs/table.model.fillable.stub

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use PowerComponents\LivewirePowerGrid\PowerGridComponent;
1414

1515
final class {{ componentName }} extends PowerGridComponent
1616
{
17+
public string $tableName = '{{ tableName }}';
18+
1719
public function setUp(): array
1820
{
1921
$this->showCheckBox();

resources/stubs/table.model.stub

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use PowerComponents\LivewirePowerGrid\PowerGridComponent;
1515

1616
final class {{ componentName }} extends PowerGridComponent
1717
{
18+
public string $tableName = '{{ tableName }}';
19+
1820
public function setUp(): array
1921
{
2022
$this->showCheckBox();

resources/stubs/table.query-builder.fillable.stub

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use PowerComponents\LivewirePowerGrid\PowerGridComponent;
1515

1616
final class {{ componentName }} extends PowerGridComponent
1717
{
18+
public string $tableName = '{{ tableName }}';
19+
1820
public function setUp(): array
1921
{
2022
$this->showCheckBox();

resources/stubs/table.query-builder.stub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use PowerComponents\LivewirePowerGrid\PowerGridComponent;
1414

1515
final class {{ componentName }} extends PowerGridComponent
1616
{
17+
public string $tableName = '{{ tableName }}';
1718
public function setUp(): array
1819
{
1920
$this->showCheckBox();

src/Commands/Support/PowerGridComponentMaker.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ final class PowerGridComponentMaker
4848

4949
private string $modelFqn = '';
5050

51+
private string $tableName = '';
52+
5153
private bool $autoCreateColumns = false;
5254

5355
private bool $usesCustomStub = false;
@@ -59,7 +61,8 @@ public function __construct(string $name)
5961
$this->resolveNameFolderFilename(SanitizeComponentName::handle($name))
6062
->resolveNamespace()
6163
->resolveFqn()
62-
->resolveHtmlTag();
64+
->resolveHtmlTag()
65+
->resolveTableName();
6366
}
6467

6568
public static function make(string $name): self
@@ -177,6 +180,7 @@ private function process(): self
177180
{
178181
$this->stub->setVar('namespace', $this->namespace);
179182
$this->stub->setVar('componentName', $this->name);
183+
$this->stub->setVar('tableName', $this->tableName);
180184

181185
$this->stub->setVar('model', $this->model);
182186
$this->stub->setVar('modelFqn', $this->modelFqn);
@@ -242,9 +246,9 @@ private function resolveFqn(): self
242246
public function createdPath(): string
243247
{
244248
return str($this->namespace)
245-
->replace('App', 'app')
246-
->append('\\' . $this->filename)
247-
->replace('\\', '/');
249+
->replace('App', 'app')
250+
->append('\\' . $this->filename)
251+
->replace('\\', '/');
248252
}
249253

250254
private function resolveHtmlTag(): self
@@ -261,6 +265,17 @@ private function resolveHtmlTag(): self
261265
return $this;
262266
}
263267

268+
private function resolveTableName(): self
269+
{
270+
$this->tableName = str($this->name)
271+
->kebab()
272+
->append('-' . Str::random(6))
273+
->append('-table')
274+
->lower();
275+
276+
return $this;
277+
}
278+
264279
private function livewireNamespace(): string
265280
{
266281
return strval(config('livewire.class_namespace'));

0 commit comments

Comments
 (0)