-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global storage-providers and notification channels
- Loading branch information
1 parent
e031baf
commit 7ae619e
Showing
26 changed files
with
388 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Actions\NotificationChannels; | ||
|
||
use App\Models\NotificationChannel; | ||
use App\Models\User; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\ValidationException; | ||
|
||
class EditChannel | ||
{ | ||
public function edit(NotificationChannel $notificationChannel, User $user, array $input): void | ||
{ | ||
$this->validate($input); | ||
|
||
$notificationChannel->label = $input['label']; | ||
$notificationChannel->project_id = isset($input['global']) && $input['global'] ? null : $user->current_project_id; | ||
|
||
$notificationChannel->save(); | ||
} | ||
|
||
/** | ||
* @throws ValidationException | ||
*/ | ||
private function validate(array $input): void | ||
{ | ||
$rules = [ | ||
'label' => [ | ||
'required', | ||
], | ||
]; | ||
Validator::make($input, $rules)->validate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Actions\StorageProvider; | ||
|
||
use App\Models\StorageProvider; | ||
use App\Models\User; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\ValidationException; | ||
|
||
class EditStorageProvider | ||
{ | ||
public function edit(StorageProvider $storageProvider, User $user, array $input): void | ||
{ | ||
$this->validate($input); | ||
|
||
$storageProvider->profile = $input['name']; | ||
$storageProvider->project_id = isset($input['global']) && $input['global'] ? null : $user->current_project_id; | ||
|
||
$storageProvider->save(); | ||
} | ||
|
||
/** | ||
* @throws ValidationException | ||
*/ | ||
private function validate(array $input): void | ||
{ | ||
$rules = [ | ||
'name' => [ | ||
'required', | ||
], | ||
]; | ||
Validator::make($input, $rules)->validate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_06_24_211155_add_project_id_to_notification_channels_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::table('notification_channels', function (Blueprint $table) { | ||
$table->unsignedBigInteger('project_id')->nullable(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('notification_channels', function (Blueprint $table) { | ||
$table->dropColumn('project_id'); | ||
}); | ||
} | ||
}; |
22 changes: 22 additions & 0 deletions
22
database/migrations/2024_06_25_202655_add_project_id_to_storage_providers_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::table('storage_providers', function (Blueprint $table) { | ||
$table->unsignedBigInteger('project_id')->nullable(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('storage_providers', function (Blueprint $table) { | ||
$table->dropColumn('project_id'); | ||
}); | ||
} | ||
}; |
Oops, something went wrong.