lasthourcloud/app/Models/S3Storage.php

35 lines
749 B
PHP
Raw Normal View History

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