Skip to content

Commit c0d0edc

Browse files
committed
WIP
1 parent 46e11aa commit c0d0edc

35 files changed

+393
-444
lines changed

app/Crud/CouponCrud.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ class CouponCrud extends CrudService
125125
public function __construct()
126126
{
127127
parent::__construct();
128-
129-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
130128
}
131129

132130
/**
@@ -660,7 +658,7 @@ public function getColumns(): array
660658
/**
661659
* Define actions
662660
*/
663-
public function setActions( CrudEntry $entry, $namespace ): CrudEntry
661+
public function setActions( CrudEntry $entry ): CrudEntry
664662
{
665663
switch ( $entry->type ) {
666664
case 'percentage_discount':

app/Crud/CustomerAccountCrud.php

+17-19
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ public function __construct()
134134
{
135135
parent::__construct();
136136

137-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
138-
139137
/**
140138
* We'll define custom export columns
141139
*/
@@ -494,7 +492,7 @@ public function getColumns(): array
494492
/**
495493
* Define actions
496494
*/
497-
public function setActions( CrudEntry $entry, $namespace )
495+
public function setActions( CrudEntry $entry ): CrudEntry
498496
{
499497
$entry->{ 'order_code' } = $entry->{ 'order_code' } === null ? __( 'N/A' ) : $entry->{ 'order_code' };
500498
$entry->operation = $this->customerService->getCustomerAccountOperationLabel( $entry->operation );
@@ -503,22 +501,22 @@ public function setActions( CrudEntry $entry, $namespace )
503501
$entry->next_amount = (string) ns()->currency->define( $entry->next_amount );
504502

505503
// you can make changes here
506-
$entry->addAction( 'edit', [
507-
'label' => __( 'Edit' ),
508-
'namespace' => 'edit',
509-
'type' => 'GOTO',
510-
'url' => ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id ),
511-
] );
512-
513-
$entry->addAction( 'delete', [
514-
'label' => __( 'Delete' ),
515-
'namespace' => 'delete',
516-
'type' => 'DELETE',
517-
'url' => ns()->url( '/api/crud/ns.customers-account-history/' . $entry->id ),
518-
'confirm' => [
519-
'message' => __( 'Would you like to delete this ?' ),
520-
],
521-
] );
504+
$entry->action(
505+
identifier: 'edit',
506+
label: __('Edit'),
507+
type: 'GOTO',
508+
url: ns()->url('/dashboard/' . $this->slug . '/edit/' . $entry->id)
509+
);
510+
511+
$entry->action(
512+
identifier: 'delete',
513+
label: __('Delete'),
514+
type: 'DELETE',
515+
url: ns()->url('/api/crud/ns.customers-account-history/' . $entry->id),
516+
confirm: [
517+
'message' => __('Would you like to delete this?'),
518+
]
519+
);
522520

523521
return $entry;
524522
}

app/Crud/CustomerCouponCrud.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ class CustomerCouponCrud extends CrudService
114114
public function __construct()
115115
{
116116
parent::__construct();
117-
118-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
119117
}
120118

121119
/**
@@ -364,7 +362,7 @@ public function getColumns(): array
364362
/**
365363
* Define actions
366364
*/
367-
public function setActions( CrudEntry $entry, $namespace )
365+
public function setActions( CrudEntry $entry ): CrudEntry
368366
{
369367
$entry->user_username = $entry->user_username ?: __( 'N/A' );
370368

@@ -379,30 +377,32 @@ public function setActions( CrudEntry $entry, $namespace )
379377

380378
$entry->coupon_type = $entry->coupon_type === 'percentage_discount' ? __( 'Percentage' ) : __( 'Flat' );
381379

380+
// Snippet 1: No changes needed, assuming 'identifier' is already in place
382381
$entry->action(
383382
label: __( 'Usage History' ),
384383
type: 'GOTO',
385384
url: ns()->url( '/dashboard/customers/' . $entry->customer_id . '/coupons/' . $entry->id . '/history/' ),
386-
identifier: 'usage.history'
385+
identifier: 'usage.history'
387386
);
388387

389-
// you can make changes here
390-
$entry->addAction( 'edit', [
391-
'label' => __( 'Edit' ),
392-
'namespace' => 'edit',
393-
'type' => 'GOTO',
394-
'url' => ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id ),
395-
] );
388+
// Snippet 2: 'namespace' likely needs replacement
389+
$entry->action(
390+
label: __( 'Edit' ),
391+
identifier: 'edit', // Replace 'namespace' with 'identifier'
392+
type: 'GOTO',
393+
url: ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id )
394+
);
396395

397-
$entry->addAction( 'delete', [
398-
'label' => __( 'Delete' ),
399-
'namespace' => 'delete',
400-
'type' => 'DELETE',
401-
'url' => ns()->url( '/api/crud/ns.customers-coupons/' . $entry->id ),
402-
'confirm' => [
396+
// Snippet 3: 'namespace' likely needs replacement
397+
$entry->action(
398+
label: __( 'Delete' ),
399+
identifier: 'delete', // Replace 'namespace' with 'identifier'
400+
type: 'DELETE',
401+
url: ns()->url( '/api/crud/ns.customers-coupons/' . $entry->id ),
402+
confirm: [
403403
'message' => __( 'Would you like to delete this ?' ),
404404
],
405-
] );
405+
);
406406

407407
return $entry;
408408
}

app/Crud/CustomerCouponHistoryCrud.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ class CustomerCouponHistoryCrud extends CrudService
141141
public function __construct()
142142
{
143143
parent::__construct();
144-
145-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'addActions' ], 10, 2 );
146144
}
147145

148146
/**
@@ -321,7 +319,7 @@ public function getColumns(): array
321319
/**
322320
* Define row actions.
323321
*/
324-
public function addActions( CrudEntry $entry, $namespace ): CrudEntry
322+
public function setActions( CrudEntry $entry ): CrudEntry
325323
{
326324
$entry->value = (string) ns()->currency->define( $entry->value );
327325

@@ -331,8 +329,8 @@ public function addActions( CrudEntry $entry, $namespace ): CrudEntry
331329
$entry->action(
332330
identifier: 'edit',
333331
label: __( 'Edit' ),
334-
url: ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id )
335-
);
332+
url: ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id )
333+
);
336334

337335
$entry->action(
338336
identifier: 'delete',

app/Crud/CustomerCrud.php

-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ public function __construct()
132132

133133
$this->options = app()->make( Options::class );
134134
$this->customerService = app()->make( CustomerService::class );
135-
136-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
137135
}
138136

139137
/**

app/Crud/CustomerGroupCrud.php

+16-20
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ class CustomerGroupCrud extends CrudService
7575
public function __construct()
7676
{
7777
parent::__construct();
78-
79-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
8078
}
8179

8280
protected $permissions = [
@@ -300,29 +298,27 @@ public function getColumns(): array
300298
/**
301299
* Define actions
302300
*/
303-
public function setActions( CrudEntry $entry, $namespace )
301+
public function setActions( CrudEntry $entry ): CrudEntry
304302
{
305303
$entry->reward_system_id = $entry->reward_system_id === 0 ? __( 'N/A' ) : $entry->reward_system_id;
306304

307-
$entry->addAction( 'edit_customers_groups', [
308-
'label' => __( 'Edit' ),
309-
'namespace' => 'edit_customers_group',
310-
'type' => 'GOTO',
311-
'index' => 'id',
312-
'url' => ns()->url( 'dashboard/customers/groups/edit/' . $entry->id ),
313-
] );
314-
315-
$entry->addAction( 'delete', [
316-
'label' => __( 'Delete' ),
317-
'namespace' => 'delete',
318-
'type' => 'DELETE',
319-
'index' => 'id',
320-
'url' => ns()->url( '/api/crud/ns.customers-groups/' . $entry->id ),
321-
'confirm' => [
305+
$entry->action(
306+
identifier: 'edit_customers_group',
307+
label: __( 'Edit' ),
308+
type: 'GOTO',
309+
url: ns()->url( 'dashboard/customers/groups/edit/' . $entry->id )
310+
);
311+
312+
$entry->action(
313+
identifier: 'delete',
314+
label: __( 'Delete' ),
315+
type: 'DELETE',
316+
url: ns()->url( '/api/crud/ns.customers-groups/' . $entry->id ),
317+
confirm: [
322318
'message' => __( 'Would you like to delete this ?' ),
323319
'title' => __( 'Delete a licence' ),
324-
],
325-
] );
320+
]
321+
);
326322

327323
$entry->reward_name = $entry->reward_name ?: __( 'N/A' );
328324

app/Crud/CustomerRewardCrud.php

+18-19
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ class CustomerRewardCrud extends CrudService
108108
public function __construct()
109109
{
110110
parent::__construct();
111-
112-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
113111
}
114112

115113
/**
@@ -339,25 +337,26 @@ public function hook( $query ): void
339337
/**
340338
* Define actions
341339
*/
342-
public function setActions( CrudEntry $entry, $namespace )
340+
public function setActions( CrudEntry $entry ): CrudEntry
343341
{
344-
// you can make changes here
345-
$entry->addAction( 'edit', [
346-
'label' => __( 'Edit' ),
347-
'namespace' => 'edit',
348-
'type' => 'GOTO',
349-
'url' => ns()->url( '/dashboard/' . $this->getSlug() . '/edit/' . $entry->id ),
350-
] );
351-
352-
$entry->addAction( 'delete', [
353-
'label' => __( 'Delete' ),
354-
'namespace' => 'delete',
355-
'type' => 'DELETE',
356-
'url' => ns()->url( '/api/crud/ns.customers-rewards/' . $entry->id ),
357-
'confirm' => [
342+
// Snippet 1
343+
$entry->action(
344+
identifier: 'edit',
345+
label: __( 'Edit' ),
346+
type: 'GOTO',
347+
url: ns()->url( '/dashboard/' . $this->getSlug() . '/edit/' . $entry->id )
348+
);
349+
350+
// Snippet 2
351+
$entry->action(
352+
identifier: 'delete',
353+
label: __( 'Delete' ),
354+
type: 'DELETE',
355+
url: ns()->url( '/api/crud/ns.customers-rewards/' . $entry->id ),
356+
confirm: [
358357
'message' => __( 'Would you like to delete this ?' ),
359-
],
360-
] );
358+
]
359+
);
361360

362361
return $entry;
363362
}

app/Crud/GlobalProductHistoryCrud.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ class GlobalProductHistoryCrud extends CrudService
138138
public function __construct()
139139
{
140140
parent::__construct();
141-
142-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
143141
}
144142

145143
/**
@@ -373,7 +371,7 @@ public function getColumns(): array
373371
/**
374372
* Define actions
375373
*/
376-
public function setActions( CrudEntry $entry, $namespace )
374+
public function setActions( CrudEntry $entry ): CrudEntry
377375
{
378376
$entry->procurement_name = $entry->procurement_name ?: __( 'N/A' );
379377
$entry->order_code = $entry->order_code ?: __( 'N/A' );

app/Crud/HoldOrderCrud.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ public function __construct()
111111
{
112112
parent::__construct();
113113

114-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
115-
116114
$this->bulkActions = [];
117115
}
118116

@@ -459,7 +457,7 @@ public function getColumns(): array
459457
/**
460458
* Define actions
461459
*/
462-
public function setActions( CrudEntry $entry, $namespace )
460+
public function setActions( CrudEntry $entry ): CrudEntry
463461
{
464462
$entry->action(
465463
label: __( 'Continue' ),

app/Crud/OrderCrud.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ public function __construct()
112112
{
113113
parent::__construct();
114114

115-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
116-
117115
/**
118116
* This will allow module to change the bound
119117
* class for the default User model.
@@ -535,7 +533,7 @@ public function hook( $query ): void
535533
/**
536534
* Define actions
537535
*/
538-
public function setActions( CrudEntry $entry, $namespace )
536+
public function setActions( CrudEntry $entry ): CrudEntry
539537
{
540538
$entry->{ '$cssClass' } = match ( $entry->__raw->payment_status ) {
541539
Order::PAYMENT_PAID => 'success border text-sm',

app/Crud/OrderInstalmentCrud.php

+16-18
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ class OrderInstalmentCrud extends CrudService
115115
public function __construct()
116116
{
117117
parent::__construct();
118-
119-
Hook::addFilter( $this->namespace . '-crud-actions', [ $this, 'setActions' ], 10, 2 );
120118
}
121119

122120
/**
@@ -355,29 +353,29 @@ public function getColumns(): array
355353
/**
356354
* Define actions
357355
*/
358-
public function setActions( CrudEntry $entry, $namespace )
356+
public function setActions( CrudEntry $entry ): CrudEntry
359357
{
360358
$entry->amount = (string) ns()->currency->define( $entry->amount );
361359
$entry->{ '$cssClass' } = $entry->paid == 0 ? 'error' : 'success';
362360
$entry->paid = (bool) $entry->paid ? __( 'Yes' ) : __( 'No' );
363361
$entry->date = ns()->date->getFormatted( $entry->date );
364362
// you can make changes here
365-
$entry->addAction( 'edit', [
366-
'label' => __( 'Edit' ),
367-
'namespace' => 'edit',
368-
'type' => 'GOTO',
369-
'url' => ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id ),
370-
] );
371-
372-
$entry->addAction( 'delete', [
373-
'label' => __( 'Delete' ),
374-
'namespace' => 'delete',
375-
'type' => 'DELETE',
376-
'url' => ns()->url( '/api/crud/ns.orders-instalments/' . $entry->id ),
377-
'confirm' => [
363+
$entry->action(
364+
identifier: 'edit',
365+
label: __( 'Edit' ),
366+
type: 'GOTO',
367+
url: ns()->url( '/dashboard/' . $this->slug . '/edit/' . $entry->id ),
368+
);
369+
370+
$entry->action(
371+
identifier: 'delete',
372+
label: __( 'Delete' ),
373+
type: 'DELETE',
374+
url: ns()->url( '/api/crud/ns.orders-instalments/' . $entry->id ),
375+
confirm: [
378376
'message' => __( 'Would you like to delete this ?' ),
379-
],
380-
] );
377+
]
378+
);
381379

382380
return $entry;
383381
}

0 commit comments

Comments
 (0)