Skip to content

Commit 610e265

Browse files
authored
Merge pull request #2230 from Blair2004/v5.0.x
V5.0.x
2 parents 850ec8d + 1495819 commit 610e265

File tree

200 files changed

+9707
-9831
lines changed

Some content is hidden

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

200 files changed

+9707
-9831
lines changed

app/Casts/ProductTypeCast.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public function get( Model|CrudEntry $model, string $key, mixed $value, array $a
2121
default => 'text-info-tertiary'
2222
};
2323

24-
$productTypes = Hook::filter( 'ns-products-type', [
24+
$productTypes = Hook::filter( 'ns-products-type', [
2525
'materialized' => __( 'Materialized Product' ),
2626
'dematerialized' => __( 'Dematerialized Product' ),
2727
'grouped' => __( 'Grouped Product' ),
28-
]);
28+
] );
2929

3030
if ( isset( $productTypes[ $value ] ) ) {
3131
return '<strong class="' . $class . ' ">' . $productTypes[ $value ] . '</strong>';

app/Classes/Model.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
2+
23
namespace App\Classes;
34

4-
class Model
5+
class Model
56
{
67
/**
78
* Define a dependant relationship.
89
*/
9-
public static function dependant( string $local_name, string $foreign_index, string $foreign_name = null, array $related = [], string $local_index = 'id' )
10+
public static function dependant( string $local_name, string $foreign_index, ?string $foreign_name = null, array $related = [], string $local_index = 'id' )
1011
{
1112
return [
1213
'local_index' => $local_index,
@@ -20,7 +21,7 @@ public static function dependant( string $local_name, string $foreign_index, str
2021
/**
2122
* Define a related relationship.
2223
*/
23-
public static function related( string $model, string $foreign_index, string $local_name, callable| null $prefix = null, string $local_index = 'id' )
24+
public static function related( string $model, string $foreign_index, string $local_name, ?callable $prefix = null, string $local_index = 'id' )
2425
{
2526
return [
2627
'model' => $model,
@@ -30,4 +31,4 @@ public static function related( string $model, string $foreign_index, string $lo
3031
'prefix' => $prefix,
3132
];
3233
}
33-
}
34+
}

app/Console/Commands/ModuleKernel.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ class ModuleKernel extends Command
2727
*/
2828
public function handle()
2929
{
30-
$moduleService = app()->make( ModulesService::class );
31-
$moduleIdentifier = $this->argument('module');
30+
$moduleService = app()->make( ModulesService::class );
31+
$moduleIdentifier = $this->argument( 'module' );
3232

33-
$modulePath = base_path('modules/' . $moduleIdentifier);
33+
$modulePath = base_path( 'modules/' . $moduleIdentifier );
3434

3535
if ( ! $module = $moduleService->get( $moduleIdentifier ) ) {
36-
$this->error('Module not found.');
36+
$this->error( 'Module not found.' );
3737
}
3838

39-
$filePath = $modulePath . '/Console/Kernel.php';
39+
$filePath = $modulePath . '/Console/Kernel.php';
4040

4141
if ( file_exists( $filePath ) && ! $this->option( 'force' ) ) {
42-
return $this->error('Kernel file not found for the module.');
42+
return $this->error( 'Kernel file not found for the module.' );
4343
}
4444

4545
$content = View::make( 'generate.modules.kernel', compact( 'module' ) )->render();

app/Console/Commands/ModuleMigrations.php

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ public function getModule()
7676
$this->module = $modules->get( $this->argument( 'namespace' ) );
7777

7878
if ( $this->module ) {
79-
if ( $this->passDeleteMigration() ) {
79+
if ( $this->option( 'forget' ) ) {
80+
$this->forgetMigration();
81+
} else {
8082
$this->createMigration();
8183
}
8284
} else {
@@ -89,39 +91,36 @@ public function getModule()
8991
*
9092
* @return bool
9193
*/
92-
public function passDeleteMigration()
94+
public function forgetMigration()
9395
{
94-
if ( $this->option( 'forget' ) ) {
95-
96-
/**
97-
* This will revert the migration
98-
* for a specific module.
99-
*
100-
* @var ModulesService
101-
*/
102-
$moduleService = app()->make( ModulesService::class );
96+
/**
97+
* This will revert the migration
98+
* for a specific module.
99+
*
100+
* @var ModulesService
101+
*/
102+
$moduleService = app()->make( ModulesService::class );
103103

104-
$moduleMigrations = $moduleService->getAllModuleMigrationFiles( $this->module );
104+
$moduleMigrations = $moduleService->getAllModuleMigrationFiles( $this->module );
105105

106-
if ( count( $moduleMigrations ) == 0 ) {
107-
$this->info( sprintf( 'No migration found for the module %s.', $this->module[ 'name' ] ) );
106+
if ( count( $moduleMigrations ) == 0 ) {
107+
$this->info( sprintf( 'No migration found for the module %s.', $this->module[ 'name' ] ) );
108108

109-
return false;
110-
}
109+
return false;
110+
}
111111

112-
/**
113-
* The user might want to forget all migration.
114-
* We'll then prepend an option for it.
115-
*/
116-
array_unshift( $moduleMigrations, __( 'All' ) );
112+
/**
113+
* The user might want to forget all migration.
114+
* We'll then prepend an option for it.
115+
*/
116+
array_unshift( $moduleMigrations, __( 'All' ) );
117117

118-
$deleteChoice = $this->choice( __( 'Which file would you like to forget' ), $moduleMigrations, 0 );
118+
$deleteChoice = $this->choice( __( 'Which file would you like to forget' ), $moduleMigrations, 0 );
119119

120-
if ( $deleteChoice === __( 'All' ) ) {
121-
return $this->revertAllModuleMigrations( $this->module );
122-
} else {
123-
return $this->deleteSpecificMigrationPath( $deleteChoice );
124-
}
120+
if ( $deleteChoice === __( 'All' ) ) {
121+
return $this->revertAllModuleMigrations( $this->module );
122+
} else {
123+
return $this->deleteSpecificMigrationPath( $deleteChoice );
125124
}
126125
}
127126

app/Crud/ProductCrud.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ public function getForm( $entry = null )
204204
errors: [],
205205
label: __( 'Sale Price' ),
206206
name: 'sale_price_edit',
207-
value: 0,
207+
value: 0,
208208
description: __( 'Define the regular selling price.' ),
209209
validation: 'required',
210210
),
211211
FormInput::number(
212212
errors: [],
213213
label: __( 'Wholesale Price' ),
214214
name: 'wholesale_price_edit',
215-
value: 0,
215+
value: 0,
216216
description: __( 'Define the wholesale price.' ),
217217
validation: 'required',
218218
),
@@ -468,7 +468,7 @@ public function getForm( $entry = null )
468468

469469
return $field;
470470
} ),
471-
'closable' => true,
471+
'closable' => true,
472472
'label' => $optionLabel,
473473
];
474474
} ) : [] ),

app/Forms/UserProfileForm.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ public function saveForm( Request $request )
4646
$results[] = $this->processOptions( $request );
4747
$results[] = $this->processAddresses( $request );
4848
$results[] = $this->processAttribute( $request );
49-
$results = collect( $results )->filter( fn( $result ) => ! empty( $result ) )->values()->map( function( $result ) {
49+
$results = collect( $results )->filter( fn( $result ) => ! empty( $result ) )->values()->map( function ( $result ) {
5050
if ( $result instanceof HttpJsonResponse ) {
5151
return $result->getData();
5252
}
53+
5354
return $result;
54-
});
55+
} );
5556

5657
return JsonResponse::success(
5758
data: compact( 'results', 'validator' ),

app/Http/Controllers/Dashboard/CrudController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @todo review for api-server
45
*/

app/Http/Controllers/Dashboard/ModulesController.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,21 @@ public function uploadModule( ModuleUploadRequest $request )
124124
{
125125
$result = $this->modules->upload( $request->file( 'module' ) );
126126

127-
/**
128-
* if the module upload was successful
129-
*/
130-
if ( $result[ 'status' ] === 'success' ) {
131-
return redirect( ns()->route( 'ns.dashboard.modules-list' ) )->with( $result );
127+
if ( $request->acceptsJson() ) {
128+
return response()->json( $result );
132129
} else {
133-
$validator = Validator::make( $request->all(), [] );
134-
$validator->errors()->add( 'module', $result[ 'message' ] );
135-
136-
return redirect( ns()->route( 'ns.dashboard.modules-upload' ) )->withErrors( $validator );
130+
/**
131+
* if the module upload was successful
132+
*/
133+
if ( $result[ 'status' ] === 'success' ) {
134+
return redirect( ns()->route( 'ns.dashboard.modules-list' ) )->with( $result );
135+
} else {
136+
$validator = Validator::make( $request->all(), [] );
137+
$validator->errors()->add( 'module', $result[ 'message' ] );
138+
139+
return redirect( ns()->route( 'ns.dashboard.modules-upload' ) )->withErrors( $validator );
140+
}
137141
}
142+
138143
}
139144
}

app/Http/Controllers/Dashboard/OrdersController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ public function orderReceipt( Order $order )
265265
$order->load( 'shipping_address' );
266266
$order->load( 'billing_address' );
267267
$order->load( 'user' );
268+
$order->load( 'settings' );
269+
$order->load( 'tax_group' );
268270

269271
return View::make( 'pages.dashboard.orders.templates.receipt', [
270272
'order' => $order,

app/Http/Controllers/Dashboard/ProcurementController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,6 @@ public function preload( $uuid )
333333

334334
public function storePreload( Request $request )
335335
{
336-
return $this->procurementService->storePreload( Str::uuid(), $request->only([ 'products' ]) );
336+
return $this->procurementService->storePreload( Str::uuid(), $request->only( [ 'products' ] ) );
337337
}
338338
}

0 commit comments

Comments
 (0)