Skip to content

Commit 56f06af

Browse files
authored
Merge pull request #953 from Blair2004/v4.8.x
V4.8.x
2 parents 94fda0d + a1a5b54 commit 56f06af

File tree

268 files changed

+8870
-8336
lines changed

Some content is hidden

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

268 files changed

+8870
-8336
lines changed

app/Console/Commands/CreateUserCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ public function checkEmail()
196196
$this->email = $this->ask( 'New Account Email. [Q] Quit.' );
197197

198198
$validator = Validator::make([
199-
'email' => $this->email,
199+
'email' => $this->email,
200200
], [
201-
'email' => 'required|email',
201+
'email' => 'required|email',
202202
]);
203203

204204
if ( $this->email === 'Q' ) {
@@ -223,9 +223,9 @@ public function checkUsername()
223223
$this->username = $this->ask( 'New Account Username. [Q] Quit.' );
224224

225225
$validator = Validator::make([
226-
'username' => $this->username,
226+
'username' => $this->username,
227227
], [
228-
'username' => 'required|min:5',
228+
'username' => 'required|min:5',
229229
]);
230230

231231
if ( $this->username === 'Q' ) {

app/Console/Commands/CrudGeneratorCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function generateCrud()
246246
$fileName,
247247
view( 'generate.crud', array_merge(
248248
$this->crudDetails, [
249-
'module' => $module,
249+
'module' => $module,
250250
]
251251
) )
252252
);

app/Console/Commands/DoctorCommand.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Models\OrderProduct;
56
use App\Services\DoctorService;
7+
use App\Services\ProductService;
68
use Illuminate\Console\Command;
79

810
class DoctorCommand extends Command
@@ -12,7 +14,7 @@ class DoctorCommand extends Command
1214
*
1315
* @var string
1416
*/
15-
protected $signature = 'ns:doctor {--fix-roles} {--fix-users-attributes}';
17+
protected $signature = 'ns:doctor {--fix-roles} {--fix-users-attributes} {--fix-orders-products}';
1618

1719
/**
1820
* The console command description.
@@ -54,5 +56,23 @@ public function handle()
5456

5557
return $this->info( 'The users attributes were fixed.' );
5658
}
59+
60+
if ( $this->option( 'fix-orders-products' ) ) {
61+
$products = OrderProduct::where( 'total_purchase_price', 0 )->get();
62+
63+
/**
64+
* @var ProductService
65+
*/
66+
$productService = app()->make( ProductService::class );
67+
68+
$this->withProgressBar( $products, function( OrderProduct $orderProduct ) use ( $productService ) {
69+
$orderProduct->total_purchase_price = $productService->getLastPurchasePrice( $orderProduct->product ) * $orderProduct->quantity;
70+
$orderProduct->save();
71+
});
72+
73+
$this->newLine();
74+
75+
$this->info( 'The products were succesfully updated' );
76+
}
5777
}
5878
}

app/Console/Commands/MakeModuleServiceProviderCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function handle()
6868
Storage::disk( 'ns-modules' )->put(
6969
$filePath,
7070
view( 'generate.modules.providers', [
71-
'module' => $module,
72-
'className' => $fileName,
71+
'module' => $module,
72+
'className' => $fileName,
7373
])
7474
);
7575

app/Console/Commands/MigrateForgetCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function handle()
6363
->where( 'file', $this->option( 'file' ) )
6464
->delete();
6565

66-
Artisan::call( 'cache:clear', [ '--force' => true ] );
66+
Artisan::call( 'cache:clear' );
6767

6868
return $this->info(
6969
sprintf(
@@ -73,7 +73,7 @@ public function handle()
7373
);
7474
} else {
7575
$deleted = Migration::where( 'migration', $this->option( 'file' ) )->delete();
76-
Artisan::call( 'cache:clear', [ '--force' => true ] );
76+
Artisan::call( 'cache:clear' );
7777

7878
return $this->info(
7979
sprintf(
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Services\ModulesService;
6+
use Illuminate\Console\Command;
7+
use Illuminate\Support\Facades\Storage;
8+
use Illuminate\Support\Str;
9+
10+
class ModuleCommandGenerator extends Command
11+
{
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'modules:command {namespace} {argument} {--force}';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Generate a command for a module.';
25+
26+
/**
27+
* Execute the console command.
28+
*
29+
* @return int
30+
*/
31+
public function handle()
32+
{
33+
$modules = app()->make( ModulesService::class );
34+
35+
/**
36+
* Check if module is defined
37+
*/
38+
if ( $module = $modules->get( $this->argument( 'namespace' ) ) ) {
39+
/**
40+
* Define the file name
41+
*/
42+
$commandsPath = $module[ 'namespace' ] . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'Commands' . DIRECTORY_SEPARATOR;
43+
$name = ucwords( Str::camel( $this->argument( 'argument' ) ) );
44+
$fileName = $commandsPath . $name;
45+
$namespace = $this->argument( 'namespace' );
46+
$fileExists = Storage::disk( 'ns-modules' )->exists(
47+
$fileName . '.php'
48+
);
49+
50+
if ( ! $fileExists || ( $fileExists && $this->option( 'force' ) ) ) {
51+
Storage::disk( 'ns-modules' )->put(
52+
$fileName . '.php', view( 'generate.modules.command', compact(
53+
'modules', 'module', 'name', 'namespace'
54+
) ) );
55+
56+
return $this->info( sprintf(
57+
__( 'The command has been created for the module "%s"!' ),
58+
$module[ 'name' ]
59+
) );
60+
}
61+
62+
return $this->error( sprintf( 'A similar file is already found at the location: %s.', $fileName . '.php' ) );
63+
}
64+
65+
return $this->error( 'Unable to located the module !' );
66+
}
67+
}

app/Console/Commands/ModuleMigrations.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ public function streamContent( $content )
142142
switch ( $content ) {
143143
case 'migration':
144144
return view( 'generate.modules.migration', [
145-
'module' => $this->module,
146-
'migration' => $this->migration,
147-
'table' => $this->table,
148-
'schema' => $this->schema,
145+
'module' => $this->module,
146+
'migration' => $this->migration,
147+
'table' => $this->table,
148+
'schema' => $this->schema,
149149
]);
150150
}
151151
}

app/Console/Commands/ModuleRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function streamContent( $content )
7070
switch ( $content ) {
7171
case 'migration':
7272
return view( 'generate.modules.request', [
73-
'module' => $this->module,
74-
'name' => $this->argument( 'name' ),
73+
'module' => $this->module,
74+
'name' => $this->argument( 'name' ),
7575
]);
7676
}
7777
}

app/Console/Commands/ProductCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function handle()
5454
$this->productService = app()->make( ProductService::class );
5555

5656
match ( $this->argument( 'action' ) ) {
57-
'update' => $this->updateProducts(),
58-
'refresh-barcode' => $this->refreshBarcodes()
57+
'update' => $this->updateProducts(),
58+
'refresh-barcode' => $this->refreshBarcodes()
5959
};
6060
}
6161

@@ -89,14 +89,14 @@ private function updateProducts()
8989
$subItems = ProductSubItem::where( 'product_id', $product->id )->get();
9090

9191
$this->productService->update( $product, array_merge( $product->toArray(), [
92-
'units' => [
93-
'unit_group' => $product->unit_group,
94-
'accurate_tracking' => $product->accurate_tracking,
95-
'selling_group' => $units->map( fn( $unitQuantity ) => $unitQuantity->toArray() )->toArray(),
92+
'units' => [
93+
'unit_group' => $product->unit_group,
94+
'accurate_tracking' => $product->accurate_tracking,
95+
'selling_group' => $units->map( fn( $unitQuantity ) => $unitQuantity->toArray() )->toArray(),
9696
],
97-
'images' => $gallery->map( fn( $gallery ) => $gallery->toArray() )->toArray(),
98-
'groups' => [
99-
'product_subitems' => $subItems->map( fn( $subItem ) => $subItem->toArray() )->toArray(),
97+
'images' => $gallery->map( fn( $gallery ) => $gallery->toArray() )->toArray(),
98+
'groups' => [
99+
'product_subitems' => $subItems->map( fn( $subItem ) => $subItem->toArray() )->toArray(),
100100
],
101101
]) );
102102
});

app/Console/Commands/ResetCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public function handle()
6969
$this->softReset();
7070
$this->initializeRole();
7171
$this->demoService->run([
72-
'mode' => 'grocery',
73-
'create_sales' => true,
74-
'create_procurements' => true,
72+
'mode' => 'grocery',
73+
'create_sales' => true,
74+
'create_procurements' => true,
7575
]);
7676
$this->info( __( 'The demo has been enabled.' ) );
7777
break;

0 commit comments

Comments
 (0)