Skip to content

Commit 5db9940

Browse files
done
1 parent 74f5ce7 commit 5db9940

22 files changed

Lines changed: 327 additions & 86 deletions

app/Console/Commands/NewRecord.php

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
use Illuminate\Console\Command;
5+
6+
class SyncGateways extends Command {
7+
8+
protected $signature = 'gateway:sync {--store= : Store id (e.g. 1, 2}';
9+
protected $description = 'Sync gateways from config to database';
10+
11+
protected function sync () {
12+
13+
$storeId = integer($this->option('store'));
14+
return app(\App\Services\SeedingService::class)->gateways(\App\Models\Store::findOrFail($storeId));
15+
16+
}
17+
public function handle () {
18+
19+
$this->sync();
20+
$this->info("✅ gateways synced successfully .");
21+
return Command::SUCCESS;
22+
23+
}
24+
25+
}

app/Console/Commands/SyncPermissions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SyncPermissions extends Command {
88

99
protected $signature = 'permission:sync
1010
{--name= : Entity name (e.g. admin, user)}
11-
{--path= : Path to config (default: settings.permission)}
11+
{--path= : Path to config (default: settings.permissions)}
1212
{--store= : Store id (e.g. 1, 2}
1313
{--force : Force reset special permissions}
1414
{--all : Sync all entities from config}}';
@@ -27,7 +27,7 @@ protected function sync () {
2727
$store = integer($this->option('store'));
2828
$force = bool($this->option('force'));
2929
$all = bool($this->option('all'));
30-
$path = string($this->option('path') ?? 'settings.permission');
30+
$path = string($this->option('path') ?? 'settings.permissions');
3131

3232
$modelClass = $this->model($name);
3333
if ( !class_exists($modelClass) ) return $this->error("Model [$modelClass] not found .");
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
use Illuminate\Console\Command;
5+
6+
class SyncSettings extends Command {
7+
8+
protected $signature = 'setting:sync {--store= : Store id (e.g. 1, 2}';
9+
protected $description = 'Sync settings from config to database';
10+
11+
protected function sync () {
12+
13+
$storeId = integer($this->option('store'));
14+
return app(\App\Services\SeedingService::class)->settings(\App\Models\Store::findOrFail($storeId));
15+
16+
}
17+
public function handle () {
18+
19+
$this->sync();
20+
$this->info("✅ settings synced successfully .");
21+
return Command::SUCCESS;
22+
23+
}
24+
25+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
use Illuminate\Http\Request;
5+
use App\Services\EntityService;
6+
7+
class EntityController extends Controller {
8+
9+
public function __construct ( protected EntityService $entityService ) {
10+
11+
parent::__construct($entityService);
12+
13+
}
14+
public function assignPermission ( Request $req, int $id, string $permission = null ) {
15+
16+
return $this->entityService->assignPermission($id, $permission, $req->all());
17+
18+
}
19+
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
use Illuminate\Http\Request;
5+
use App\Services\PermissionService;
6+
7+
class PermissionController extends Controller {
8+
9+
public function __construct ( protected PermissionService $permissionService ) {
10+
11+
parent::__construct($permissionService);
12+
13+
}
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
class EntityResource extends BaseResource {
6+
7+
public function tiny ( $data ) {
8+
9+
return [
10+
'name' => $data->name,
11+
];
12+
13+
}
14+
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Http\Resources;
4+
5+
class PermissionResource extends BaseResource {
6+
7+
public function tiny ( $data ) {
8+
9+
return [
10+
'name' => $data->name,
11+
'allow' => $data->allow,
12+
'description' => $data->description,
13+
];
14+
15+
}
16+
public function relations () {
17+
18+
return [
19+
'entity' => EntityResource::info( $this->entity ),
20+
];
21+
22+
}
23+
24+
}

app/Http/Resources/SettingResource.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ class SettingResource extends BaseResource {
77
public function data () {
88

99
return [
10-
'balance' => $this->balance,
11-
'deposits' => $this->deposits,
12-
'withdraws' => $this->withdraws,
13-
'referral_amount' => $this->referral_amount,
14-
'referral_percentage' => $this->referral_percentage,
15-
'commission_amount' => $this->commission_amount,
16-
'commission_percentage' => $this->commission_percentage,
10+
'group' => $this->group,
11+
'key' => $this->key,
12+
'value' => $this->value,
13+
'json_value' => $this->json_value,
14+
];
15+
16+
}
17+
public function relations () {
18+
19+
return [
20+
$this->getRelatedName() => $this->getRelatedResource(),
1721
];
1822

1923
}

app/Models/Permission.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ class Permission extends Model {
88

99
use HasBaseModel;
1010

11+
public function entity () { return $this->belongsTo(Entity::class); }
12+
1113
}

0 commit comments

Comments
 (0)