mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
init
This commit is contained in:
30
app/Actions/StorageProvider/AddStorageProvider.php
Normal file
30
app/Actions/StorageProvider/AddStorageProvider.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\StorageProvider;
|
||||
|
||||
use App\Models\StorageProvider;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class AddStorageProvider
|
||||
{
|
||||
use ValidateProvider;
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function add(User $user, array $input): mixed
|
||||
{
|
||||
$this->validate($user, $input);
|
||||
|
||||
$storageProvider = new StorageProvider([
|
||||
'user_id' => $user->id,
|
||||
'provider' => $input['provider'],
|
||||
'label' => $input['label'],
|
||||
'connected' => false,
|
||||
]);
|
||||
$storageProvider->save();
|
||||
|
||||
return $storageProvider->provider()->connect();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user