Skip to content

Commit 76cf8a8

Browse files
done
1 parent ed82d15 commit 76cf8a8

9 files changed

Lines changed: 67 additions & 15 deletions

app/Http/Controllers/WithdrawTransactionController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
namespace App\Http\Controllers;
44
use Illuminate\Http\Request;
5-
use App\Http\Requests\WithdrawTransactionRequest;
65
use App\Services\WithdrawTransactionService;
76

87
class WithdrawTransactionController extends Controller {
98

10-
protected function requestForm () { return WithdrawTransactionRequest::class; }
11-
129
public function __construct ( WithdrawTransactionService $withdrawTransactionService ) {
1310

1411
parent::__construct($withdrawTransactionService);
12+
$this->applyScopes(strict: true);
1513

1614
}
1715

app/Http/Resources/WithdrawMethodResource.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,16 @@ public function tiny ( $data ) {
1414
];
1515

1616
}
17+
public function relations () {
18+
19+
$transactions = $this->withdrawTransactions;
20+
21+
return [
22+
'transactions' => $transactions->count(),
23+
'total_amounts' => $transactions->sum('amount'),
24+
'pending_amounts' => $transactions->filter(fn($item) => $item->status === 'pending')->sum('amount'),
25+
];
26+
27+
}
1728

1829
}

app/Http/Resources/WithdrawTransactionResource.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ public function tiny ( $data ) {
1616
public function data () {
1717

1818
return [
19-
'recipient' => $this->recipient,
20-
'deleted' => $this->deleted,
19+
'recipient' => $this->recipient,
20+
'description' => $this->description,
21+
'deleted' => $this->deleted,
2122
];
2223

2324
}
2425
public function relations () {
2526

2627
return [
27-
'method' => WithdrawMethodResource::info( $this->withdrawMethod ),
28+
'user' => UserResource::info( $this->user ),
29+
'withdraw_method' => WithdrawMethodResource::info( $this->withdrawMethod ),
2830
];
2931

3032
}

app/Repositories/WithdrawMethodRepository.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,15 @@ class WithdrawMethodRepository extends BaseRepository {
77

88
public function __construct ( WithdrawMethod $model ) { parent::__construct($model); }
99

10+
public function fields ( array $data = [] ) {
11+
12+
return [
13+
'name' => string(data_get($data, 'name')),
14+
'description' => string(data_get($data, 'description')),
15+
'notes' => string(data_get($data, 'notes')),
16+
'fields' => data_get($data, 'fields'),
17+
];
18+
19+
}
20+
1021
}

app/Repositories/WithdrawTransactionRepository.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,19 @@ class WithdrawTransactionRepository extends BaseRepository {
77

88
public function __construct ( WithdrawTransaction $model ) { parent::__construct($model); }
99

10+
public function fields ( array $data = [] ) {
11+
12+
return [
13+
'withdraw_method_id' => integer(data_get($data, 'withdraw_method_id')),
14+
'user_id' => integer(data_get($data, 'user_id')),
15+
'currency' => string(data_get($data, 'currency') ?? 'USD'),
16+
'amount' => float(data_get($data, 'amount')),
17+
'description' => string(data_get($data, 'description')),
18+
'notes' => string(data_get($data, 'notes')),
19+
'status' => string(data_get($data, 'status') ?? 'pending'),
20+
'recipient' => data_get($data, 'recipient'),
21+
];
22+
23+
}
24+
1025
}

app/Services/WithdrawTransactionService.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55

66
class WithdrawTransactionService extends BaseService {
77

8-
public function __construct ( WithdrawTransactionRepository $withdrawTransactionRepository ) {
9-
10-
parent::__construct($withdrawTransactionRepository);
11-
12-
}
8+
public function __construct (
9+
protected WithdrawTransactionRepository $withdrawTransactionRepository,
10+
) { parent::__construct($withdrawTransactionRepository); }
1311

1412
}

config/settings/permissions.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
['name' => 'allow_gateways', 'default' => true], ['name' => 'allow_entities', 'default' => true],
4343
['name' => 'allow_permissions', 'default' => true], ['name' => 'allow_identities', 'default' => true],
4444
['name' => 'allow_verifications', 'default' => true], ['name' => 'allow_followers', 'default' => true],
45+
['name' => 'allow_withdraw_methods', 'default' => true], ['name' => 'allow_withdraw_transactions', 'default' => true],
4546
['name' => 'allow_views', 'default' => true],
4647

4748
],
@@ -85,6 +86,7 @@
8586
['name' => 'allow_gateways', 'default' => true], ['name' => 'allow_entities', 'default' => true],
8687
['name' => 'allow_permissions', 'default' => true], ['name' => 'allow_identities', 'default' => true],
8788
['name' => 'allow_verifications', 'default' => true], ['name' => 'allow_followers', 'default' => true],
89+
['name' => 'allow_withdraw_methods', 'default' => true], ['name' => 'allow_withdraw_transactions', 'default' => true],
8890
['name' => 'allow_views', 'default' => true],
8991
],
9092
'admin' => [
@@ -245,7 +247,13 @@
245247

246248
['name' => 'view_socials', 'default' => true], ['name' => 'add_socials', 'default' => true],
247249
['name' => 'edit_socials', 'default' => true], ['name' => 'delete_socials', 'default' => true],
248-
250+
251+
['name' => 'view_withdraw_methods', 'default' => true], ['name' => 'add_withdraw_methods', 'default' => true],
252+
['name' => 'edit_withdraw_methods', 'default' => true], ['name' => 'delete_withdraw_methods', 'default' => true],
253+
254+
['name' => 'view_withdraw_transactions', 'default' => true], ['name' => 'add_withdraw_transactions', 'default' => true],
255+
['name' => 'edit_withdraw_transactions', 'default' => true], ['name' => 'delete_withdraw_transactions', 'default' => true],
256+
249257
['name' => 'view_carts', 'default' => true], ['name' => 'delete_carts', 'default' => true],
250258
['name' => 'view_followers', 'default' => true], ['name' => 'delete_followers', 'default' => true],
251259
['name' => 'view_favorites', 'default' => true], ['name' => 'delete_favorites', 'default' => true],
@@ -427,5 +435,9 @@
427435
['name' => 'allow_likes', 'default' => true], ['name' => 'allow_dislikes', 'default' => true],
428436
['name' => 'allow_imports', 'default' => true],
429437
],
438+
'withdraw_method' => [
439+
['name' => 'allow_withdraw_transactions', 'default' => true], ['name' => 'allow_reports', 'default' => true],
440+
['name' => 'allow_imports', 'default' => true],
441+
],
430442

431443
];

database/migrations/2025_09_26_091354_create_withdraw_methods_table.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public function up () {
1212
$table->id();
1313
$table->integer('store_id')->default(0);
1414
$table->string('name');
15-
$table->json('fields');
15+
$table->json('fields')->nullable();
16+
$table->text('description')->nullable();
17+
$table->text('notes')->nullable();
1618
$table->boolean('active')->default(true);
1719
$table->timestamps();
1820
$table->softDeletes();

database/migrations/2025_09_27_034450_create_withdraw_transactions_table.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ public function up () {
1111
Schema::create('withdraw_transactions', function ( Blueprint $table ) {
1212
$table->id();
1313
$table->integer('store_id')->default(0);
14+
$table->integer('user_id')->default(0);
1415
$table->integer('withdraw_method_id')->default(0);
15-
$table->decimal('amount', 15, 2)->default(0);
1616
$table->string('currency')->default('USD');
17+
$table->decimal('amount', 15, 2)->default(0);
18+
$table->text('description')->nullable();
19+
$table->text('notes')->nullable();
1720
$table->json('recipient')->nullable();
18-
$table->enum('status', ['pending', 'approved', 'rejected']);
21+
$table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
1922
$table->boolean('deleted')->default(false);
2023
$table->boolean('active')->default(true);
2124
$table->timestamps();

0 commit comments

Comments
 (0)