mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 01:41:36 +00:00
35 lines
848 B
PHP
35 lines
848 B
PHP
<?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();
|
|
}
|
|
}
|