2023-08-07 15:31:42 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
|
|
|
class S3Storage extends BaseModel
|
|
|
|
{
|
|
|
|
use HasFactory;
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-08-07 15:31:42 +02:00
|
|
|
protected $guarded = [];
|
2023-08-07 18:46:40 +02:00
|
|
|
protected $casts = [
|
|
|
|
'key' => 'encrypted',
|
|
|
|
'secret' => 'encrypted',
|
|
|
|
];
|
2023-08-07 15:31:42 +02:00
|
|
|
|
|
|
|
static public function ownedByCurrentTeam(array $select = ['*'])
|
|
|
|
{
|
|
|
|
$selectArray = collect($select)->concat(['id']);
|
2023-08-22 17:44:49 +02:00
|
|
|
return S3Storage::whereTeamId(currentTeam()->id)->select($selectArray->all())->orderBy('name');
|
2023-08-07 15:31:42 +02:00
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
|
|
|
public function awsUrl()
|
|
|
|
{
|
2023-08-07 15:31:42 +02:00
|
|
|
return "{$this->endpoint}/{$this->bucket}";
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
|
|
|
public function testConnection()
|
|
|
|
{
|
2023-08-07 15:31:42 +02:00
|
|
|
set_s3_target($this);
|
|
|
|
return \Storage::disk('custom-s3')->files();
|
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
}
|