wip: migrate to livewire 3
This commit is contained in:
61
app/Livewire/Team/Storage/Form.php
Normal file
61
app/Livewire/Team/Storage/Form.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Team\Storage;
|
||||
|
||||
use App\Models\S3Storage;
|
||||
use Livewire\Component;
|
||||
|
||||
class Form extends Component
|
||||
{
|
||||
public S3Storage $storage;
|
||||
protected $rules = [
|
||||
'storage.is_usable' => 'nullable|boolean',
|
||||
'storage.name' => 'nullable|min:3|max:255',
|
||||
'storage.description' => 'nullable|min:3|max:255',
|
||||
'storage.region' => 'required|max:255',
|
||||
'storage.key' => 'required|max:255',
|
||||
'storage.secret' => 'required|max:255',
|
||||
'storage.bucket' => 'required|max:255',
|
||||
'storage.endpoint' => 'required|url|max:255',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'storage.is_usable' => 'Is Usable',
|
||||
'storage.name' => 'Name',
|
||||
'storage.description' => 'Description',
|
||||
'storage.region' => 'Region',
|
||||
'storage.key' => 'Key',
|
||||
'storage.secret' => "Secret",
|
||||
'storage.bucket' => 'Bucket',
|
||||
'storage.endpoint' => 'Endpoint',
|
||||
];
|
||||
|
||||
public function test_s3_connection()
|
||||
{
|
||||
try {
|
||||
$this->storage->testConnection(shouldSave: true);
|
||||
return $this->dispatch('success', 'Connection is working. Tested with "ListObjectsV2" action.');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
try {
|
||||
$this->storage->delete();
|
||||
return redirect()->route('team.storages.all');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
try {
|
||||
$this->test_s3_connection();
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user