Skip to content

Commit 4959a4b

Browse files
authored
Merge pull request #422 from Blair2004/v4.6.x
V4.6.x
2 parents 5502d8e + 19860f0 commit 4959a4b

Some content is hidden

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

58 files changed

+679
-286963
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ PUSHER_APP_CLUSTER=mt1
4646

4747
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
4848
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
49-
SANCTUM_STATEFUL_DOMAINS=http://127.0.0.1:8000/,http://localhost/,http://127.0.0.1/
49+
SANCTUM_STATEFUL_DOMAINS=http://127.0.0.1:8000/,http://localhost/,http://127.0.0.1/
50+
NS_ENV=production
51+
TELESCOPE_ENABLED=false

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public/css/*.map
3434
public/lang
3535
public/modules-lang/*
3636
!public/modules-lang/index.html
37-
public/mix-manifest.json
3837
public/mapping.json
3938
storage/module.zip
4039
tests/database.sqlite

app/Console/Commands/ModuleMigrations.php

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ModuleMigrations extends Command
1919
*
2020
* @var string
2121
*/
22-
protected $signature = 'modules:migration {namespace} {--delete=} {--forget}';
22+
protected $signature = 'modules:migration {namespace} {--forget=}';
2323

2424
/**
2525
* The console command description.
@@ -72,19 +72,7 @@ public function getModule()
7272
*/
7373
public function passDeleteMigration()
7474
{
75-
/**
76-
* if we would like to delete all migrations
77-
*/
78-
if ( $this->option( 'delete' ) == 'all' ) {
79-
Storage::disk( 'ns-modules' )->deleteDirectory( $this->module[ 'namespace' ] . DIRECTORY_SEPARATOR . 'Migrations' );
80-
Storage::disk( 'ns-modules' )->makeDirectory( $this->module[ 'namespace' ] . DIRECTORY_SEPARATOR . 'Migrations' );
81-
$this->info( sprintf( 'All %s migration folders has been deleted !', $this->module[ 'name' ] ) );
82-
return false;
83-
} else if( $this->option( 'delete' ) != '' ) {
84-
Storage::disk( 'ns-modules' )->deleteDirectory( $this->module[ 'namespace' ] . DIRECTORY_SEPARATOR . 'Migrations' . DIRECTORY_SEPARATOR . $this->option( 'delete' ) );
85-
$this->info( sprintf( 'The migration directory %s has been deleted.', $this->option( 'delete' ) ) );
86-
return false;
87-
} else if ( $this->option( 'forget' ) ) {
75+
if ( $this->option( 'forget' ) === 'all' ) {
8876
/**
8977
* This will revert the migration
9078
* for a specific module.
@@ -106,6 +94,35 @@ public function passDeleteMigration()
10694
*/
10795
Artisan::call( 'cache:clear' );
10896

97+
return false;
98+
} else if ( ! empty( $this->option( 'forget' ) ) ) {
99+
100+
$path = str_replace( 'modules/', '', $this->option( 'forget' ) );
101+
102+
/**
103+
* This will revert the migration
104+
* for a specific module.
105+
* @var ModulesService
106+
*/
107+
$moduleService = app()->make( ModulesService::class );
108+
$moduleService->revertMigrations( $this->module, [ $path ]);
109+
110+
/**
111+
* We'll make sure to clear the migration as
112+
* being executed on the system.
113+
*/
114+
ModuleMigration::where( 'namespace', $this->module[ 'namespace' ] )
115+
->where( 'file', $path )
116+
->delete();
117+
118+
$this->info( sprintf( 'The migration "%s" for the module %s has been forgotten.', $path, $this->module[ 'name' ] ) );
119+
120+
/**
121+
* because we use the cache to prevent the system for overusing the
122+
* database with too many requests.
123+
*/
124+
Artisan::call( 'cache:clear' );
125+
109126
return false;
110127
}
111128

app/Crud/ExpenseCategoryCrud.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class ExpenseCategoryCrud extends CrudService
2020
/**
2121
* base route name
2222
*/
23-
protected $mainRoute = 'ns.expenses-categories';
23+
protected $mainRoute = 'ns.accounting-accounts';
2424

2525
/**
2626
* Define namespace
2727
* @param string
2828
*/
29-
protected $namespace = 'ns.expenses-categories';
29+
protected $namespace = 'ns.accounting-accounts';
3030

3131
/**
3232
* Model Used
@@ -83,15 +83,15 @@ public function __construct()
8383
public function getLabels()
8484
{
8585
return [
86-
'list_title' => __( 'Expenses Categories List' ),
87-
'list_description' => __( 'Display All Expense Categories.' ),
88-
'no_entry' => __( 'No Expense Category has been registered' ),
89-
'create_new' => __( 'Add a new Expense Category' ),
90-
'create_title' => __( 'Create a new Expense Category' ),
91-
'create_description' => __( 'Register a new Expense Category and save it.' ),
92-
'edit_title' => __( 'Edit Expense Category' ),
93-
'edit_description' => __( 'Modify An Expense Category.' ),
94-
'back_to_list' => __( 'Return to Expense Categories' ),
86+
'list_title' => __( 'Accounts List' ),
87+
'list_description' => __( 'Display All Accounts.' ),
88+
'no_entry' => __( 'No Account has been registered' ),
89+
'create_new' => __( 'Add a new Account' ),
90+
'create_title' => __( 'Create a new Account' ),
91+
'create_description' => __( 'Register a new Account and save it.' ),
92+
'edit_title' => __( 'Edit Account' ),
93+
'edit_description' => __( 'Modify An Account.' ),
94+
'back_to_list' => __( 'Return to Accounts' ),
9595
];
9696
}
9797

@@ -252,7 +252,7 @@ public function canAccess( $fields )
252252
* @return void
253253
*/
254254
public function beforeDelete( $namespace, $id, $model ) {
255-
if ( $namespace == 'ns.expenses-categories' ) {
255+
if ( $namespace == 'ns.accounting-accounts' ) {
256256
$this->allowedTo( 'delete' );
257257
}
258258
}
@@ -308,12 +308,12 @@ public function setActions( $entry, $namespace )
308308
'namespace' => 'edit',
309309
'type' => 'GOTO',
310310
'index' => 'id',
311-
'url' => ns()->url( '/dashboard/' . 'expenses/categories' . '/edit/' . $entry->id )
311+
'url' => ns()->url( '/dashboard/' . 'accounting/accounts' . '/edit/' . $entry->id )
312312
], [
313313
'label' => __( 'Delete' ),
314314
'namespace' => 'delete',
315315
'type' => 'DELETE',
316-
'url' => ns()->url( '/api/nexopos/v4/crud/ns.expenses-categories/' . $entry->id ),
316+
'url' => ns()->url( '/api/nexopos/v4/crud/ns.accounting-accounts/' . $entry->id ),
317317
'confirm' => [
318318
'message' => __( 'Would you like to delete this ?' ),
319319
]
@@ -371,11 +371,11 @@ public function bulkAction( Request $request )
371371
public function getLinks()
372372
{
373373
return [
374-
'list' => ns()->url( 'dashboard/' . 'expenses/categories' ),
375-
'create' => ns()->url( 'dashboard/' . 'expenses/categories/create' ),
376-
'edit' => ns()->url( 'dashboard/' . 'expenses/categories/edit/' ),
377-
'post' => ns()->url( 'api/nexopos/v4/crud/ns.expenses-categories' ),
378-
'put' => ns()->url( 'api/nexopos/v4/crud/ns.expenses-categories/{id}' ),
374+
'list' => ns()->url( 'dashboard/' . 'accounting/accounts' ),
375+
'create' => ns()->url( 'dashboard/' . 'accounting/accounts/create' ),
376+
'edit' => ns()->url( 'dashboard/' . 'accounting/accounts/edit/' ),
377+
'post' => ns()->url( 'api/nexopos/v4/crud/ns.accounting-accounts' ),
378+
'put' => ns()->url( 'api/nexopos/v4/crud/ns.accounting-accounts/{id}' ),
379379
];
380380
}
381381

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Broadcasting\PresenceChannel;
8+
use Illuminate\Broadcasting\PrivateChannel;
9+
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
10+
use Illuminate\Foundation\Events\Dispatchable;
11+
use Illuminate\Queue\SerializesModels;
12+
13+
class CrudAfterDeleteEvent
14+
{
15+
use Dispatchable, InteractsWithSockets, SerializesModels;
16+
17+
/**
18+
* @param CrudService
19+
*/
20+
public $resource;
21+
22+
/**
23+
* Create a new event instance.
24+
*
25+
* @return void
26+
*/
27+
public function __construct( $resource )
28+
{
29+
$this->resource = $resource;
30+
}
31+
32+
/**
33+
* Get the channels the event should broadcast on.
34+
*
35+
* @return \Illuminate\Broadcasting\Channel|array
36+
*/
37+
public function broadcastOn()
38+
{
39+
return new PrivateChannel('channel-name');
40+
}
41+
}

app/Http/Controllers/Dashboard/CrudController.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44
*/
55
namespace App\Http\Controllers\Dashboard;
66

7+
use App\Events\CrudAfterDeleteEvent;
78
use App\Exceptions\NotFoundException;
89
use Illuminate\Http\Request;
9-
use Illuminate\Support\Facades\Event;
1010
use Illuminate\Support\Str;
11-
use Symfony\Component\HttpFoundation\RedirectResponse;
1211
use Exception;
1312
use App\Http\Controllers\DashboardController;
1413
use App\Http\Requests\CrudPostRequest;
1514
use App\Http\Requests\CrudPutRequest;
1615
use App\Services\CrudService;
1716
use TorMorten\Eventy\Facades\Events as Hook;
18-
use Illuminate\Support\Facades\Auth;
1917
use Illuminate\Support\Facades\Cache;
2018
use Illuminate\Support\Facades\Storage;
2119
use PhpOffice\PhpSpreadsheet\Spreadsheet;
22-
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
2320
use PhpOffice\PhpSpreadsheet\Writer\Csv;
2421

2522
class CrudController extends DashboardController
@@ -62,6 +59,11 @@ public function crudDelete( $namespace, $id )
6259

6360
$model->delete();
6461

62+
/**
63+
* That will trigger everytime an instance is deleted.
64+
*/
65+
CrudAfterDeleteEvent::dispatch( $resource );
66+
6567
return [
6668
'status' => 'success',
6769
'message' => __( 'The entry has been successfully deleted.' )
@@ -287,6 +289,12 @@ public function getFormConfig( string $namespace, $id = null )
287289
], 403 );
288290
}
289291

292+
/**
293+
* Export the entries as a CSV file
294+
* @param string $namespace
295+
* @param Request $request
296+
* @return array $response
297+
*/
290298
public function exportCrud( $namespace, Request $request )
291299
{
292300
$crudClass = Hook::filter( 'ns-crud-resource', $namespace );

app/Http/Controllers/Dashboard/ExpensesCategoriesController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
use App\Services\Options;
1515
use Illuminate\Support\Facades\View;
1616

17-
// use Tendoo\Core\Services\Page;
18-
1917
class ExpensesCategoriesController extends DashboardController
2018
{
2119
public function __construct( Options $options )

app/Http/Controllers/Dashboard/HomeController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class HomeController extends DashboardController
1717
{
1818
public function welcome()
1919
{
20-
return View::make( 'welcome' );
20+
return View::make( 'welcome', [
21+
'title' => sprintf( __( 'Welcome &mdash; NexoPOS %s'), config( 'nexopos.version' ) )
22+
]);
2123
}
2224
}

app/Http/Controllers/UpdateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function runMigration( Request $request )
4343
$file = ns()->update->getMatchingFullPath(
4444
$request->input( 'file' )
4545
);
46-
46+
4747
Artisan::call( 'migrate --path=' . $file );
4848
}
4949

app/Models/CashFlow.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ public function expense()
2828

2929
public function scopeFrom( $query, $date )
3030
{
31-
return $query->where( 'created_at', '<=', $date );
31+
return $query->where( 'created_at', '>=', $date );
32+
}
33+
34+
public function scopeOperation( $query, $operation )
35+
{
36+
return $query->where( 'operation', $operation );
3237
}
3338

3439
public function scopeTo( $query, $date )
3540
{
36-
return $query->where( 'created_at', '>=', $date );
41+
return $query->where( 'created_at', '<=', $date );
3742
}
3843
}

0 commit comments

Comments
 (0)